Debugging C++ Applications Using HP WDB (766162-001, March 2014)
lookup within a namespace. It also recognizes using directives and aliases, and using declarations
within namespaces.
Example 9 shows how scope resolution operator is used for debugging programs having different
namespaces:
Example 9 Using Scope Resolution Operator to Debug Programs having Different Namespaces
When the debugger has a list of possible resolutions for a given symbol, it displays a menu that
shows all names fully qualified whenever namespaces are involved. You can choose the appropriate
symbol from the list. For example, if you stop the debugger in a function that contains an int i
using directive for a namespace, such as:
using namespace A::AB::ABC::ABCD
You can use the print i command and if the only possible resolution for i is
A::AB::ABC::ABCD::i, the debugger prints the name of the symbol and its value. However,
if a global i exists, the debugger displays a menu from which to choose as shown:
(1) i
(2) A::AB::ABC::ABCD::i
>
Similarly, you can set the breakpoints on functions or call a function from command line in WDB.
NOTE: The debugger also supports semi-qualified names. For example, if you stop in a function
in namespace B, which is nested in namespace A, and namespace A has an int i, you
can use print B::i command to display the value of A::B::i.
Following are some commands that can be used for debugging semi-qualified names:
Enable/Disable namespace support.set namespaces-enabled [on | off]
The default value is on.
Display the current WDB namespace support status.show namespaces-enabled
Example 10 shows a sample program and output log for debugging namespaces.
Debugging namespaces 17