GDB工具如何使用断点信息
来源:互联网 发布:java软件工程师一个月挣多少钱 编辑:程序博客网 时间:2024/05/21 16:55
在Linux平台下,使用最多的就是调试工具GDB.通过命令gcc -g test.c 。默认会生成a.out文件,这个文件由于参数-g的原因加入了调试信息。所以可以使用gdb来加载并调试,但是在使用断点的时候,你会很郁闷。真的。比如下面先来看这个过程。
/******
test.c 代码
********/
1 #include <stdio.h>
2
3 void docout()
4 {
5
6 }
7 int main(void)
8 {
9
10 int b;
11 printf("%p\n",&b);
12 docout();
13 return 0;
14 }
执行命令 gcc -g test.c 输出:
[root@yongxin ~]# gcc -g test.c
[root@yongxin ~]# ls
anaconda-ks.cfg Download nautilus-debug-log.txt test.c
a.out Firefox_wallpaper.png Pictures Videos
crossplatform install.log Projects
Desktop install.log.syslog Public
Documents Music Templates
再执行gdb a.out 设置断点信息 breakpoint
2
3 void docout()
4 {
5
6 }
7 int main(void)
8 {
9
10 int b;
11 printf("%p\n",&b);
(gdb) break 10
Breakpoint 1 at 0x80483da: file test.c, line 10.
(gdb) break 12
Breakpoint 2 at 0x80483ed: file test.c, line 12.
(gdb) infobreak
Undefined command: "infobreak". Try "help".
(gdb) info break
Num Type Disp Enb Address What
1 breakpoint keep y 0x080483da in main at test.c:10
2 breakpoint keep y 0x080483ed in main at test.c:12
可以运行,没问题。但是这些断点信息是没有办法保持的。下次进来的时候,必须重新设置断点。当你要频繁退出的时候,就会非常烦。特别是断点特别多的情况。气死你。
所以解决办法就是将打断点的命令(breakpoint 行号)写到一个文件里面去 ,在初始化的时候自动加载。
比如文件break.list
breakpoint 10
breakpoint 12
然后通过命令 gdb a.out -x break.list -tui 加载这个程序
然后 info break 你就可以看到所有加载的断点了。
完毕。
/******
test.c 代码
********/
1 #include <stdio.h>
2
3 void docout()
4 {
5
6 }
7 int main(void)
8 {
9
10 int b;
11 printf("%p\n",&b);
12 docout();
13 return 0;
14 }
执行命令 gcc -g test.c 输出:
[root@yongxin ~]# gcc -g test.c
[root@yongxin ~]# ls
anaconda-ks.cfg Download nautilus-debug-log.txt test.c
a.out Firefox_wallpaper.png Pictures Videos
crossplatform install.log Projects
Desktop install.log.syslog Public
Documents Music Templates
再执行gdb a.out 设置断点信息 breakpoint
2
3 void docout()
4 {
5
6 }
7 int main(void)
8 {
9
10 int b;
11 printf("%p\n",&b);
(gdb) break 10
Breakpoint 1 at 0x80483da: file test.c, line 10.
(gdb) break 12
Breakpoint 2 at 0x80483ed: file test.c, line 12.
(gdb) infobreak
Undefined command: "infobreak". Try "help".
(gdb) info break
Num Type Disp Enb Address What
1 breakpoint keep y 0x080483da in main at test.c:10
2 breakpoint keep y 0x080483ed in main at test.c:12
可以运行,没问题。但是这些断点信息是没有办法保持的。下次进来的时候,必须重新设置断点。当你要频繁退出的时候,就会非常烦。特别是断点特别多的情况。气死你。
所以解决办法就是将打断点的命令(breakpoint 行号)写到一个文件里面去 ,在初始化的时候自动加载。
比如文件break.list
breakpoint 10
breakpoint 12
然后通过命令 gdb a.out -x break.list -tui 加载这个程序
然后 info break 你就可以看到所有加载的断点了。
完毕。
- GDB工具如何使用断点信息
- gdb保存断点信息问题
- gdb如何保存和读取断点
- 如何使用gdb给某个模块(文件)的所有函数下断点
- Linux 如何使用gdb 查看core堆栈信息
- Linux 如何使用gdb 查看core堆栈信息
- Linux 如何使用gdb 查看core堆栈信息
- gdb断点
- linux gdb 断点设置以及使用
- gdb 内存断点watch 的使用
- gdb工具使用
- gdb工具的使用
- GDB调试工具使用
- gdb调试工具使用
- gdb工具的使用
- 使用 GDB 恢复堆栈信息
- Zend Studio中如何配置和使用xdebug断点调试工具?
- Zend Studio中如何配置和使用xdebug断点调试工具?
- 视图类CView及其派生类
- Linux内核学习之list_entry --- 用C语言实现泛型编程
- string.format
- http协议简介
- eclipse 配置 android开发环境
- GDB工具如何使用断点信息
- Hibernate的关系映射-------多对一与一对多
- hadoop 0.23 HDFS 的搭建与配置
- アジャイル開発~
- nginx+tomcat整合后获取真实IP
- scons用户指南第一章:编译和安装SCons
- 高性能的通讯程序,服务器端的代码大致如下:
- 2012年 要写的文章
- 生活是一张seo的网络