我有一个c / c ++应用程序的核心转储。我是编程的新手,所以这个问题可能听起来很愚蠢。是否有一些我可以编写脚本来使用gdb来分析核心转储?
答案 0 :(得分:3)
是的,只需编写您想要的任何内容。例如:
gdb \
-ex "set pagination 0" \
-ex "thread apply all bt" \
-batch ${EXECUTABLE_FILE} ${CORE_FILE}
答案 1 :(得分:0)
按如下所示使用-x选项
$ cat gdb.cmds
set confirm off
set height 0
cd /homes/syrajendra
file dump
core dump.core
set solib-search-path "/lib"
bt
printf "\n"
quit
$ gdb -x gdb.cmds
. . .
[Thread debugging using libthread_db enabled]
Core was generated by `dump'.
Program terminated with signal SIGABRT, Aborted.
#0 0x000000080149f6ca in thr_kill () from /lib/libc.so.7
#0 0x000000080149f6ca in thr_kill () from /lib/libc.so.7
#1 0x0000000801574149 in abort () from /lib/libc.so.7
#2 0x0000000801556011 in __assert () from /lib/libc.so.7
#3 0x000000000040130a in fun2 (num=100) at ./dump.cpp:10
#4 0x0000000000401343 in fun1 (num=100) at ./dump.cpp:20
#5 0x000000000040137e in main () at ./dump.cpp:27