Can anyone tell me what's the difference between break and tbreak regarding watchpoints ?
A have a simple test code :
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv) {
int toto;
toto = 1;
toto = 2;
toto = 3;
return (EXIT_SUCCESS);
}
When i use break on main(), then watch, toto seem to switch from 0 to 2 :
(gdb) break main
Breakpoint 1 at 0x804839a: file pp.c, line 6.
(gdb) r
Starting program: /mnt/mega20/SRC/C/gdb/pp
Breakpoint 1, main (argc=1, argv=0xbffff4f4) at pp.c:6
6 toto = 1;
(gdb) watch toto
Hardware watchpoint 2: toto
(gdb) c
Continuing.
Hardware watchpoint 2: toto
Old value = 0
New value = 2
main (argc=1, argv=0xbffff4f4) at pp.c:8
8 toto = 3;
(gdb)
But when i use tbreak, watc开发者_如何学JAVAh seem to work :
(gdb) tbreak main
Temporary breakpoint 1 at 0x804839a: file pp.c, line 6.
(gdb) r
Starting program: /mnt/mega20/SRC/C/gdb/pp
Temporary breakpoint 1, main (argc=1, argv=0xbffff4f4) at pp.c:6
6 toto = 1;
(gdb) watch toto
Hardware watchpoint 2: toto
(gdb) c
Continuing.
Hardware watchpoint 2: toto
Old value = 0
New value = 1
main (argc=1, argv=0xbffff4f4) at pp.c:7
7 toto = 2;
(gdb) c
Continuing.
Hardware watchpoint 2: toto
Old value = 1
New value = 2
main (argc=1, argv=0xbffff4f4) at pp.c:8
8 toto = 3;
(gdb)
Same results with the start command, it works.
I suggest you to read this:
Breakpoints and Watchpoints
精彩评论