0
誰能告訴我關於watchpoint的break和tbreak有什麼區別?gdb,break vs tbreak和watchpoint
A具有一個簡單的測試代碼:
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv) {
int toto;
toto = 1;
toto = 2;
toto = 3;
return (EXIT_SUCCESS);
}
當我使用上main()中,然後觀察斷裂,TOTO似乎切換爲0〜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)
但是當我使用手錶似乎工作:
(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)
與啓動命令相同的結果,它的工作原理。
而且......你有什麼用編譯開關?什麼gdb版本?你是否查詢過gdb命令的含義? ... – t0mm13b 2011-06-06 11:54:48
「gcc -g3 -O0」在Debian上使用gdb 7.2,是的。 – Lefinnois 2011-06-06 12:37:58
如果在main上添加斷點,運行,刪除斷點,則在toto上添加觀察點並繼續,完全沒有問題。僅當在main上定義斷點時纔會錯過toto = 1的觀察點。 – Lefinnois 2011-06-07 07:10:19