Search code examples
c++gdbbreakpoints

How do I set a breakpoint for operator() in gdb for C++?


I have 2 methods in C++ class as follows:

 class myClass {
     public:
         void operator()( string myString ) {
             // Some code
         }
         void myMethod() { ... }
 }

For a regular method, I can simply set the breakpoint in GDB as:

b myClass::myMethod

But how do I set the breakpoint for the first method?

UPDATE:

The suggestions from initial answers (b myClass ::operator()) does not work :(

b myClass::operator()
Function "myClass::operator()" not defined.

Thanks!


Solution

  • gdb will also take breakpoints at specific line numbers. For example b file.cc:45