Debugging C++ Applications Using HP WDB (766162-001, March 2014)

specify the name of the variable or the object to be mentioned in the program with appropriate
scoping in the WDB command. HP WDB can also display mangled or demangled name as per
your requirement.
Table 3 shows the commands to display mangled or demangled names.
Table 1 Commands to Display Mangled or Demangled Names
PurposeCommand
Displays the C++ symbols in mangled or demangled form.set print demangle [on |
off]
The default value is on. C++ symbols will be displayed as demangled.
show print demangle
Displays the C++ symbols in mangled or demangled form in disassembly output.set print asm-demangle [on
| off]
The default value is on.
show print asm-demangle
Example 1 shows the sample output log for debugging mangled names.
Example 1 Sample Output Log for Debugging Mangled Names
(gdb) set print demangle on
(gdb) info functions func
All functions matching regular expression "func":
File helper.C:
static void func(int);
File func_overload.C:
void func(char*);
void func(double);
void func(int);
...
(gdb) set print demangle off
(gdb) info functions func
All functions matching regular expression "func":
File helper.C:
static void _Z4funci(int);
File func_overload.C:
void _Z4funcPc(char *);
void _Z4funcd(double);
void _Z4funci(int);
...
Debugging scope resolution operator
Scope is an enclosing context where values and expressions are associated. The scope resolution
operator helps you to identify and specify the context to which an identifier refers. The scope
resolution operator (::) in C is used to define the already declared member functions (in the header
file with the .hpp or the .h extension) of the class. In C++, you can define the normal functions or
the member functions of the class. To differentiate between the normal functions and the member
functions of the class, you must use the scope resolution operator (::) in between the class name
and the member function name. For example, if the function is declared as car::foo(), the car
is the name of the class and foo() is the member function and :: is the scope resolution operator
that is also used to access data members of base class from derived class pointer.
C++ has its own scope rules. HP WDB conforms to C++ scope rules by allowing access to identifiers
either directly from within its scope or by means of the C++ scoping operator (::) from outside its
scope.
Debugging scope resolution operator 7