gdb错误-文件未采用可执行格式:无法识别文件格式

时间:2018-08-04 07:44:13

标签: linux ubuntu debugging gdb

我正在尝试使用gdb调试名为xdf的某些程序,但是当我运行gdb xdf时,出现以下错误:

"/home/nealtitusthomas/X-ray_astronomy/heasoft-6.24/x86_64-pc-linux-gnu-libc2.27/bin/xdf": not in executable format: File format not recognized

该程序是符号链接的,并且file /home/nealtitusthomas/X-ray_astronomy/heasoft-6.24/x86_64-pc-linux-gnu-libc2.27/bin/xdf的输出是:

/home/nealtitusthomas/X-ray_astronomy/heasoft-6.24/x86_64-pc-linux-gnu-libc2.27/bin/xdf: symbolic link to ../../ftools/x86_64-pc-linux-gnu-libc2.27/bin/xdf

此处gdb error not in executable format: File format not recognized给出的解决方案说,这是因为安装的gdb是32位版本,而程序是64位。但是,我的gdb安装是64位。这可以通过以下确认:

This GDB was configured as "x86_64-linux-gnu". 

2 个答案:

答案 0 :(得分:3)

您正在尝试在Shell脚本上使用GDB。就像它试图告诉您一样,GDB不知道该怎么办。

答案 1 :(得分:2)

  

file /home/nealti...

的输出

通常,您几乎总是应该使用file -L /home/...代替-该命令将取消引用任何符号链接,并在解析所有符号链接后告诉您 文件是什么。

  

POSIX shell script, ASCII text executable

您正在尝试调试Shell脚本。 GDB不知道该怎么做。

您需要在外壳脚本中查找 (使用您选择的编辑器),找出其最终调用的 actual 二进制文件,并对其进行调试。

包装外壳脚本通常看起来像这样:

 #!/bin/sh
... some code to figure out installation directory (e.g. INSTALL_DIR)
export LD_LIBRARY_PATH="$INSTALL_DIR/lib64:..."

# Now invoke the binary:
exec "$INSTALL_DIR/bin/xdf.exe" "$@"

您要做的是将最后一行替换为:

exec /usr/bin/gdb --args "$INSTALL_DIR/bin/xdf.exe" "$@"

并正常运行xdf shell脚本。现在它将自动神奇地调用gdb。

相关问题