gdb、break 与 tbreak 和观察点
谁能告诉我关于观察点的break和tbreak之间有什么区别?
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() 上使用 break,然后 watch,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)
但是当我使用 tbreak 时,watch 似乎工作:
(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)
与 start 命令的结果相同,它工作。
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, watch 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论