当前位置:  开发笔记 > 后端 > 正文

我如何使用"观看"GDB?

如何解决《我如何使用"观看"GDB?》经验,为你挑选了1个好方法。



1> Employed Rus..:

指定您的平台,GDB版本以及您使用的GDB命令的确切顺序可能会有所帮助.

这是我看到的(GDB似乎工作得很好):

$ gcc -g test.c

$ gdb a.out
GNU gdb (GDB) 6.8.50.20090430-cvs
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
...
(gdb) list
1       #include 
2       #include 
3
4       int main(int argc, char** argv){
5         printf("Hello world\n");
6
7         int a = 12;
8         a = 10;                                                                                                                                                                      
9         return 0; 
10      }
11
(gdb) b 5
Breakpoint 1 at 0x4004a7: file test.c, line 5.
(gdb) r

Breakpoint 1, main (argc=1, argv=0x7fffffffdb28) at test.c:5
5         printf("Hello world\n");
(gdb) watch a
Hardware watchpoint 2: a
(gdb) c
Hello world
Hardware watchpoint 2: a

Old value = 0
New value = 12
main (argc=1, argv=0x7fffffffdb28) at test.c:8
8         a = 10;                                                                                                                                                                      
(gdb) c
Hardware watchpoint 2: a

Old value = 12
New value = 10
main (argc=1, argv=0x7fffffffdb28) at test.c:9
9         return 0; 
(gdb) c

Watchpoint 2 deleted because the program has left the block in
which its expression is valid.
0x00007ffff7ab3033 in exit () from /lib/libc.so.6
(gdb) c

Program exited normally.
(gdb) q

推荐阅读
雯颜哥_135
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有