➜ [/data/home/noahyzhang/learn/core] gdb core.25068 GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-119.tl2 Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 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-redhat-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... [New LWP 25068] Missing separate debuginfo for the main executable file Try: yum --enablerepo='*debug*' install /usr/lib/debug/.build-id/9e/58829cf2411a83aa62369519de72c6dbe9b0e8 Core was generated by `./a.out'. Program terminated with signal 11, Segmentation fault. #0 0x000000000040055b in ?? () "/data/home/noahyzhang/learn/core/core.25068" is a core file. Please specify an executable to debug. (gdb) bt #0 0x000000000040055b in ?? () #1 0x00007fff0228e180 in ?? () #2 0x0000000000000000 in ?? () (gdb) file ./a.out Reading symbols from /data/home/noahyzhang/learn/core/a.out...done. (gdb) (gdb) (gdb) bt #0 0x000000000040055b in main () at core.c:6 (gdb)
gdb 的其他选项
1 2 3 4 5 6 7
bt: 查看堆栈信息 i locals:查看当前程序栈的局部变量 i args:查看当前程序栈的参数 i catch:查看当前程序中栈帧的异常处理器 p a:打印变量的值 i register:查看当前寄存器的值 r:从运行程序至第一个断点