简体   繁体   English

从Shell脚本中运行gdb命令

[英]Run gdb command from within shell script

I am making a simple coredump analyzer. 我正在制作一个简单的coredump分析器。 I have a core file and symbols. 我有一个核心文件和符号。 Now I want to create a utility so these 2 files can be uploaded, and it shows the stacktrace (bt). 现在,我想创建一个实用程序,以便可以上传这2个文件,并显示stacktrace(bt)。 I execute a shell script which does: 我执行一个shell脚本,它执行以下操作:

gzip -d coredump.gz
tar xvf symbols.tar.gz
gdb program
#Now at this point I want to send gdb commands one at a time. Like:
core-file corefile
echo bt

I want to save the output of "bt" to a file. 我想将“ bt”的输出保存到文件中。 How can I do that? 我怎样才能做到这一点?

You want: 你要:

rm -f gdb.txt
gdb -ex 'set logging on' -ex 'where' program corefile
# GDB output is now in gdb.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM