With GDB I can watch i
, to break whenever i
changes. The problem is that I have multiple functions using the name i
, so GDB breaks inside of all those functions.
Is it possible to break whenever i
changes, but only inside a given function?
I guess you are watching a global variable and hence it stops in all functions where this variable is modified which is the logical and expected behaviour. If you want to break only inside a given function whenever i
changes, dont set the breakpoint for i
. Instead set a breakpoint for the desired function. When this breakpoint is hit, now set the watch for i
so that you know for sure that the next breakpoint will be hit when i
is modified in the desired function (Ignoring possible recursions and the like)
I guessed that you may not be watching a local variable inside every function with the same name because you cannot set a breakpoint on a local variable until you are in the scope of that particular function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With