Unix – gdb: breakpoint when register will have value 0xffaa

debugginggdbunix

Can I set the breakpoint/watchpoint/smth else in gdb for register value?

I want to break when $eax will have value 0x0000ffaa.

Is it possible with gdb or dbx or any other unix debugger?

Best Answer

Yes in gdb you would set a watchpoint like so:

watch $eax == 0x0000ffaa

But it is dependent on watchpoint support being available for the target. You should note that this may slow down execution significantly.

If you would like to break in a certain location you can do so, by setting a conditional breakpoint:

break test.c:120 if $eax == 0x0000ffaa