zoukankan      html  css  js  c++  java
  • gdb调试core文件

    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

  • 相关阅读:
    报数游戏
    Dynamics CRM 2013 初体验(2):UI
    Lucene.net常见功能实现知识汇总
    hdu 1853 最小费用流好题 环的问题
    MessagerService总结
    [置顶] Android EditText/TextView使用SpannableString显示复合文本
    MySQL Dll语句
    JavaScript表单验证
    intellij—idea14 注冊机
    OL记载Arcgis Server切片
  • 原文地址:https://www.cnblogs.com/zhangxuan/p/5977835.html
Copyright © 2011-2022 走看看