How do I set persistent and conditional watchpoints on locally scoped variables?

I agree with Dave that a conditional breakpoint is the way to go.

However, to do what you asked, you can use GDB’s commands command to set a list of GDB commands to execute whenever a breakpoint is hit. I find this incredibly useful.

I suggest writing your GDB commands into a file so that they are easy to edit and easy to reload with the source command. Or you can specify command files to load on the GDB command line or use .gdbinit to make them load automatically.

An example of a good use of commands:
Suppose that I have a function format that is called by a lot of other functions. I want to break on it, but only after function do_step_3 has been called.

break do_step_3
commands
  break format
  continue
end

You could use this for your problem with something like:

break func
commands
  watch var
  continue
end

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)