Setting breakpoints in C++ member functions is illustrated using the following program:
(idb) list 3:25
3 class C {
4 public:
5 void foo();
6 void foo(int);
7 void foo(float);
8 int foo(double *);
9 };
10
11 C o;
12 C* p = new C;
13 int t = 0;
14 int state = 1;
15
16 main(){
17 t++;
18 o.foo();
19
20 }
21
22 void C::foo() { t = 0; state++; return; }
23 void C::foo(int i) { state++; return; }
24 void C::foo(float f) { state++; return; }
25 int C::foo(double *) { return state;}
You must name member functions in a way that makes them visible at the current position, according to the normal C++ visibility rules. For example:
(idb) stop in main
[#1: stop in int main(void)]
(idb) run
[1] stopped at [int main(void):17 0x08048704]
17 t++;
(idb) stop in foo
Symbol "foo" is not defined.
foo has no valid breakpoint address
Warning: Breakpoint not set
If not positioned within a member function of a class, it is generally necessary to name the desired member function using type qualification, an object of the class type, or a pointer to an object of the class type. For example:
(idb) stop in C::foo
Select from
----------------------------------------------------
1 int C::foo(double*)
2 void C::foo(float)
3 void C::foo(int)
4 void C::foo(void)
5 None of the above
----------------------------------------------------
3
[#5: stop in void C::foo(int)]
(idb) stop in o.foo
Select from
----------------------------------------------------
1 int C::foo(double*)
2 void C::foo(float)
3 void C::foo(int)
4 void C::foo(void)
5 None of the above
----------------------------------------------------
1
[#6: stop in int C::foo(double*)]
(idb) stop in p->foo
Select from
----------------------------------------------------
1 int C::foo(double*)
2 void C::foo(float)
3 void C::foo(int)
4 void C::foo(void)
5 None of the above
----------------------------------------------------
4
[#7: stop in void C::foo(void)]
You can avoid the ambiguity associated with an overloaded function by specifying a complete signature for the function name. For example:
(idb) stop in C::foo(void)
[#8: stop in void C::foo(void)]
(idb) stop in C::foo(int)
[#9: stop in void C::foo(int)]