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

resolve ambiguous references to overloaded function name func by setting breakpoints in any of
the following ways:
By specifying the particular version of the function with arguments, such as break
func(types).
By specifying the break func, which causes WDB to offer a menu of numbered choices for
all versions of function func present in the program, and then prompt you to make the choice
with the `>' prompt.
Example 15 shows a sample program for debugging overloaded functions.
Example 15 Sample Program for Debugging Overloaded Functions
1 #include <iostream˙>
2 using namespace std;
3
4 void func(int i) {
5 cout << " Here is int " << i << endl;
6 }
7 void func(double f) {
8 cout << " Here is float " << f << endl;
9 }
10
11 void func(char* c) {
12 cout << " Here is char* " << c << endl;
13 }
14
15 int main() {
16 func(10);
17 func(10.10);
18 func("ten");
19 }
------------------------------------
helper.C
----------
#include <iostream>
using namespace std;
static void func(int i) {
cout << " Here is int " << i << endl;
}
------------------------------------
The WDB output snippet for this program is as shown below:
(gdb) b func(char*)
Breakpoint 1 at 0x4003490:2: file func_overload.C, line 12 from /C++WhitePaper/func_overload.
(gdb) b func
[0] cancel
[1] all
[2] func(char*) at func_overload.C:12
[3] func(double) at func_overload.C:8
[4] func(int) at func_overload.C:5
[5] func(int) at helper.C:5
> 3 4 5
Breakpoint 2 at 0x4003050:0: file func_overload.C, line 8 from /C++WhitePaper/func_overload.
Breakpoint 3 at 0x4001be0:2: file func_overload.C, line 5 from /C++WhitePaper/func_overload.
Breakpoint 4 at 0x4004ee0:2: file helper.C, line 5 from /C++WhitePaper/func_overload.
Multiple breakpoints were set.
Use the "delete" command to delete unwanted breakpoints.
In addition to the C++ overloaded functions, other functions having different file scope are also
listed in the above example as 4th and 5th options.
To set breakpoint to all available versions of function func at once, you can use the rbreak
func command.
Resolving ambiguous references to overloaded functions 25