gdb core dump

https://cand-w18.unexploitable.systems/l/lab02/note-on-gdb.txt
https://github.com/hellogcc/100-gdb-tips/blob/master/src/index.md

check the build ID of exe:

readelf -n /path/to/binary

check the ID in core file:

# 先安装 sudo apt-get install elfutils
eu-unstrip -n --core /path/to/core

例如:
gdb core dump_第1张图片

ubuntu 查看 core dump 文件生成位置:

cat /proc/sys/kernel/core_pattern
bt
bt full

info line * 0x123456  # 查看地址对应的代码行, 也可用 addr2line
info symbol 0x123456 # 同上 
 
info frame
info registers

x/i $pc
x/10x $esp

info threads

# Generally, the backtrace is used to get the stack of the current thread, 
# but if there is a necessity to get the stack trace of all the threads, use the following command:
thread apply all bt

info target
info sharedlib

gdb 启动时,指定源文件搜索位置:

gdb -q a.out -d /search/code/some

你可能感兴趣的:(c/c++,gcc,linux常用命令)