【问题标题】:Gdb scripting using bash使用 bash 编写 Gdb 脚本
【发布时间】:2014-01-05 21:49:33
【问题描述】:

我正在尝试编写一个脚本来分析核心转储。到目前为止,我已经想出了这个脚本。

#!/bin/bash

#
# A script to extract core-file informations
#

#Binary image
binimg=$1

# Today and yesterdays cores
core=$2

gdblogfile="$core-gdb.log"
rm -f $gdblogfile

gdb -batch \
    -ex "set logging file $gdblogfile" \
    -ex "set logging on" \
    -ex "set pagination off" \
    -ex "file $binimg" \
    -ex "core-file $core" \
    -ex "bt" \
    -ex "quit"

当我尝试执行它时,我得到了这个错误: 文件“退出”不存在或不是常规文件。

你能告诉我我做错了什么吗?

【问题讨论】:

    标签: bash gdb core


    【解决方案1】:

    您的 gdb 版本可能有问题(您使用的是哪个版本)?我可以用 gdb 6.3 重现你的错误,但不能用 7.6。无论如何,gdb 似乎,即使你已经以批处理模式启动它,仍然认为最后一个参数"quit" 是图像的文件名(并且它试图加载它,并抱怨找不到它)。因此,要按照 gdb 的预期进行操作,只需像往常一样传入图像和核心文件(同时删除 "ex file""ex core-file" 参数)。看看这样的东西是否适合你:

    gdb -batch \
        -ex "set logging file $gdblogfile" \
        -ex "set logging on" \
        -ex "set pagination off" \
        -ex bt \
        -ex quit \
        "$binimg" \
        "$core"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-07
      • 1970-01-01
      相关资源
      最近更新 更多