2

So I was wondering how to stop gdb every time my variable (test_v) changes

I know

 watch test_v

Do I do

 watch test_v
 stop

To stop the program every time the variable test_v changes?

1

You don't need to use stop to make the program stop when the variable changes. Just watch test_v is enough.

stop command is not for stopping the program, but only meant to be hooked so you can execute some commands automatically when the program stops. Example usage from the gdb manual:

define hook-stop
handle SIGALRM nopass
end

define hook-run
handle SIGALRM pass
end

define hook-continue
handle SIGALRM pass
end

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.