Debugging C++ Applications Using HP WDB (766162-001, March 2014)
Introduction
HP Wildebeest Debugger (WDB) is an HP-supported implementation of the GNU Project Debugger
(GDB). HP WDB debugs applications written in C, C++, and FORTRAN. HP WDB also supports
Java core-file debugging and mixed-language debugging for C, C++ and Java.
HP WDB debugs C++ programs compiled using HP aC++ compiler on Itanium®-based systems
running HP-UX 11i v2 or HP-UX 11i v3 operating systems, and HP 9000 systems running HP-UX
11i v1, HP-UX 11i v2, or HP-UX 11i v3 operating systems.
The C++ debugging facilities are jointly implemented by the C++ compiler and the HP WDB.
Therefore, to debug your C++ programs effectively using the HP WDB, you must compile your
C++ programs with the HP aC++ compiler. On HP Integrity systems, the HP aC++ compiler produces
the debugging information in DWARF-2 format, which is used by HP WDB debugger.
This document describes HP WDB commands used to debug common issues found in C++ programs.
It also mentions the limitations of using HP WDB to debug C++ applications. Using this document,
you can minimize the time to reach the root cause of the issues in a C++ application.
C++ Expressions supported in WDB expressions
HP WDB expressions can interpret most C++ expressions as illustrated in the following points.
• HP WDB supports the C++ scope resolution operator (::). Your expressions can use the scope
resolution operator just like the expressions in your program. For more information, see
“Debugging scope resolution operator” (page 7).
• HP WDB supports member function calls that can be used as shown below:
count = paml->GetOriginal(x, y)
count = aml.GetOriginal(x, y)
For more information, see “Debugging member function” (page 12).
• While a member function is active in the selected stack frame, your expressions must have
the same namespace available as the member function. HP WDB allows implicit references
to the class instance for this pointer following the same rules as C++. For more information,
see “Debugging member function” (page 12).
• You can call overloaded functions; HP WDB resolves the function call to the exact definition
with some restrictions. For more information, see “Resolving ambiguous references to
overloaded functions” (page 24).
• HP WDB interprets 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 HP WDB displays a frame, the values of reference variables are not displayed (unlike
other variables); this avoids clutter, since references are often used for large structures. The
address of a reference variable is always shown, unless you have specified set print
address off.
• HP WDB supports calling virtual functions correctly, printing virtual base of an object, calling
functions in a base subobject, and casting objects. For more information, see “Debugging a
virtual function” (page 23).
Displaying mangled or demangled names
Name mangling is a way of encoding additional information in the name of a function, structure,
class, or another datatype in order to pass more semantic information from the compiler to the
linker. In C++, name mangling is performed to obtain unique identifiers to support features, such
as storing information about classes, operator overloading, templates, and so on.
With HP WDB, you can debug using the actual name instead of the mangled name without knowing
the underlying naming system of the C++ compiler. To debug using the actual name, you must
6