博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
gdb调试core文件
阅读量:4627 次
发布时间:2019-06-09

本文共 1063 字,大约阅读时间需要 3 分钟。

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

转载于:https://www.cnblogs.com/zhangxuan/p/5977835.html

你可能感兴趣的文章
设计模式之—中介者模式<Mediator Pattern>
查看>>
C:指针遍历二维数组
查看>>
Mysql,SqlServer,Oracle主键自动增长的设置
查看>>
断言(ASSERT)的用法
查看>>
笔记 - Servlet
查看>>
OSI七层模型详解
查看>>
解惑好文:移动端H5页面高清多屏适配方案(2)
查看>>
理解MySQL——索引与优化
查看>>
Java-Runoob:Java 方法
查看>>
杂项:院校
查看>>
Luogu P4551 最长异或路径 01trie
查看>>
通过代码注册COM、DLL组件
查看>>
appium重新封装后,取一组元素之后显示不是列表类型的乌龙(copy有风险,paste需谨慎)...
查看>>
json_encode 中文处理
查看>>
jquery局部区域打印功能实现
查看>>
Centos7 中使用Supervisor守护进程
查看>>
第五周作业
查看>>
awk中关于BEGIN,END的使用问题
查看>>
[Vue warn]: Failed to mount component: template or render function not defined. 错误解决方法
查看>>
禁用root登录以及使用sudo分配权限
查看>>