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?
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?
I was unable to get it to watch eax directly, so I inserted a few asm instructions to store the required value to a junk variable and watch that. I was unable to convince gcc to use eax, so this code "watches" ebx instead.
#include <stdio.h>
int tmp;
int main(void)
{
int i;
printf("tmp is originally %d\n",tmp);
for(i=0;i<20;i++)
{
asm (
"cmpl $10,%ebx\n"
"jne dont\n"
"movl %ebx,tmp\n"
"dont:\n"
);
printf("%d\n",i);
printf("\nnow tmp is %d\n",tmp);
return 0;
}
Now you can "watch tmp"
Yes in gdb you would set a watchpoint for like so:
watch $eax == 0x0000ffaa
But it is dependent on watchpoint support 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