HP (Hewlett-Packard) 5992-4701 Computer Hardware User Manual


 
9.4.1.3 C++ expressions
GDB expression handling can interpret most C++ expressions.
WARNING! GDB can only debug C++ code if you use the proper compiler. Typically,
C++ debugging depends on the use of additional debugging information in the symbol
table, and thus requires special support. In particular, if your compiler generates a.out,
MIPS ECOFF, RS/6000 XCOFF, or ELF with stabs extensions to the symbol table, these
facilities are all available. (With GNU CC, you can use the '-gstabs' option to request
stabs debugging extensions explicitly.) Where the object code format is standard COFF
or DWARF in ELF, on the other hand, most of the C++ support in GDB does not work.
1. Member function calls are allowed; you can use expressions like
count = aml->GetOriginal(x, y)
2. While a member function is active (in the selected stack frame), your expressions
have the same namespace available as the member function; that is, GDB allows
implicit references to the class instance pointer this following the same rules as
C++.
3. You can call overloaded functions; GDB resolves the function call to the right
definition, with some restrictions. GDB does not perform overload resolution
involving user-defined type conversions, calls to constructors, or instantiations of
templates that do not exist in the program. It also cannot handle ellipsis argument
lists or default arguments.
It does perform integral conversions and promotions, floating-point promotions,
arithmetic conversions, pointer conversions, conversions of class objects to base
classes, and standard conversions such as those of functions or arrays to pointers;
it requires an exact match on the number of function arguments.
Overload resolution is always performed, unless you have specified set
overload-resolution off. See “GDB features for C++” (page 111).
You must specify set overload-resolution off in order to use an explicit
function signature to call an overloaded function, as in
p 'foo(char,int)'('x', 13)
The GDB command-completion facility can simplify this. Refer to “Command
completion” (page 33).
4. GDB understands variables declared as C++ references; you can use them in
expressions just as you do in C++ source―they are automatically dereferenced.
In the parameter list shown when GDB displays a frame, the values of reference
variables are not displayed (unlike other variables); this avoids clutter, since
9.4 Supported languages 109