c++gdbbreakpointswatchpoint

How set breakpoint to class member variable in gdb


How can I set breakpoint (or watchpoint) to member variable in class for all instances of this class?

I have tried set breakpoint on line in class with this member variable but this is not working.


Solution

  • You can set breakpoint to the setter and getter function as shown below

    break TestClass::setVal(int)
    break TestClass::getVal()
    

    Note that, we have to specify the type of arguments that the function is receiving.

    Find more details here