0

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.

Marcin
  • 422
  • 6
  • 17
  • try to grep source code for all occurrences of your variable, set breakpoints everywere where it is modified line by line. – Nikita May 27 '15 at 11:23
  • I cannot set breakpoint on getter and setter in header. – Marcin May 27 '15 at 12:10
  • Do you have implementations of your getter/setter in header? What gdb command do you use? Do you compile with -g option? – Nikita May 27 '15 at 12:12
  • Implementations of getter and setter are in header. It is possible to add breakpoint in cpp file. I use "breakpoint ". – Marcin May 27 '15 at 12:42

1 Answers1

0

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

Rohit Walavalkar
  • 790
  • 9
  • 28