gdb调试core文件
2016-10-19 16:56
253 查看
nw.c
void test_function (void)
{
unsigned char *ptr = 0x00;
*ptr = 0x00;
}
int main (void)
{
test_function();
return 0;
}
-----------------------
gcc -g -o main nw.c
执行main,生成core文件:core.8229
-------------------------
gbd调试生成的core文件
如果core.8229 跟 main不在同一个目录下,那么把core.8229放到main同路径下面。
调试方法:
一、gdb [exec file] [core file]
具体:gdb main core.8229
Core was generated by `./main'.
Program terminated with signal 11, Segmentation fault.
#0 0x080483c4 in test_function () at nw.c:4
4 *ptr = 0x00;
(gdb) list test_function //使用list指令,查看test_function函数
(gdb) q //推出gdb调试
二、
gdb -core=[core file]
file [exec file]
具体:
gdb -core=main.8229
(gdb) file main
(gdb) r
(gdb) list test_function //使用list指令,查看test_function函数
(gdb) q //推出gdb调试
三、
gdb -c main.8229
(gdb) file main
(gdb) r
(gdb) list test_function //使用list指令,查看test_function函数
(gdb) q //推出gdb调试
四、
gdb -c main.8229 main
(gdb) r
(gdb) list test_function //使用list指令,查看test_function函数
(gdb) q //推出gdb调试
参考:http://blog.csdn.net/hanchaoman/article/details/5583457
void test_function (void)
{
unsigned char *ptr = 0x00;
*ptr = 0x00;
}
int main (void)
{
test_function();
return 0;
}
-----------------------
gcc -g -o main nw.c
执行main,生成core文件:core.8229
-------------------------
gbd调试生成的core文件
如果core.8229 跟 main不在同一个目录下,那么把core.8229放到main同路径下面。
调试方法:
一、gdb [exec file] [core file]
具体:gdb main core.8229
Core was generated by `./main'.
Program terminated with signal 11, Segmentation fault.
#0 0x080483c4 in test_function () at nw.c:4
4 *ptr = 0x00;
(gdb) list test_function //使用list指令,查看test_function函数
(gdb) q //推出gdb调试
二、
gdb -core=[core file]
file [exec file]
具体:
gdb -core=main.8229
(gdb) file main
(gdb) r
(gdb) list test_function //使用list指令,查看test_function函数
(gdb) q //推出gdb调试
三、
gdb -c main.8229
(gdb) file main
(gdb) r
(gdb) list test_function //使用list指令,查看test_function函数
(gdb) q //推出gdb调试
四、
gdb -c main.8229 main
(gdb) r
(gdb) list test_function //使用list指令,查看test_function函数
(gdb) q //推出gdb调试
参考:http://blog.csdn.net/hanchaoman/article/details/5583457
相关文章推荐
- GDB调试core文件样例(如何定位Segment fault)
- gdb用法(二) 在Linux下产生并调试core文件
- GDB调试core文件样例(如何定位Segment fault)
- linux下用gdb调试core文件
- GDB调试core文件
- gdb调试core文件
- GDB调试core文件样例(如何定位Segment fault)
- gdb调试core异常文件之where命令
- arm-linux-gdb+gdbserver环境搭建以及远程调试 及调试core文件
- GDB调试之core文件(如何定位到Segment fault)
- gdb调试,分析core文件,找出段错误位置
- 用gdb调试core文件
- 编译ARM版本GDB调试CORE文件
- 转载_Linux core dump file详解及使用GDB调试Coredump文件
- GDB调试core文件样例(如何定位Segment fault)
- 建立与查看linux core(gdb调试)文件的实验
- GDB调试core文件样例
- linux gdb调试core文件
- core文件与gdb调试
- GDB调试core文件样例(如何定位Segment fault)