Debugging with GDB Manual HP WDB v6.3 (5900-2180, August 2012)
`RWCollectableDate d3(15,5,2001);'
printing the variable or class returns:
(gdb) p d3
$3 = {<No data fields>}
(gdb) ptype RWCollectableDate
type = class RWCollectableDate {
<no data fields>
9.4.1.4 C and C++ defaults
If you allow GDB to set type and range checking automatically, they both default to off whenever
the working language changes to C or C++. This happens regardless of whether you or GDB
selects the working language.
If you allow GDB to set the language automatically, it recognizes source files whose names end
with '.c', '.C', or '.cc', and so on, and when GDB enters code compiled from one of these files,
it sets the working language to C or C++. Refer to See “Having GDB infer the source language”
(page 78), for further details.
9.4.1.5 C and C++ type and range checks
By default, when GDB parses C or C++ expressions, type checking is not used. However, if you
turn type checking on, GDB considers two variable types equivalent if:
• The two variables are structured and have the same structure, union, or enumerated tag.
• The two variables have the same type name, or types that have been declared equivalent
through typedef.
Range checking, if turned on, is done on mathematical operations. Array indices are not checked,
since they are often used to index a pointer that is not itself an array.
9.4.1.6 GDB and C
The set print union and show print union commands apply to the union type. When
set to 'on', any union that is inside a struct or class is also printed. Otherwise, it appears
as '{...}'.
The @ operator aids in the debugging of dynamic arrays, formed with pointers and a memory
allocation function. See “Expressions” (page 63).
9.4.1.7 GDB features for C++
Some GDB commands are particularly useful with C++, and some are designed specifically for
use with C++. Here is a summary:
breakpoint menus When you want a breakpoint in a function whose name is
overloaded, GDB breakpoint menus help you specify which
function definition you want. See “Breakpoint menus”
(page 47).
rbreak regex Setting breakpoints using regular expressions is helpful for
setting breakpoints on overloaded functions that are not
members of any special classes. See “Setting breakpoints”
(page 39).
catch throw, catch catch Debug C++ exception handling using these commands. See
“Setting catchpoints” (page 42).
ptype typename Print inheritance relationships as well as other information
for type. typename. See Chapter 10 (page 87).
84 Using GDB with Different Languages