【问题标题】:Debugging a simple ARM 64-bit executable causes internal error in GDB调试简单的 ARM 64 位可执行文件会导致 GDB 出现内部错误
【发布时间】:2019-01-30 11:46:26
【问题描述】:

我写了一个简单的 C 程序来打印 hello world。然后我运行它

aarch64-linux-gnu-gcc -ohello hello.c -static -g3
gdb-multiarch hello

在此之后,我run 和 gdb 遇到内部错误:

Reading symbols from hello...done.
(gdb) r
Starting program: /home/gt/hello
/build/gdb-GT4MLW/gdb-8.1/gdb/i387-tdep.c:592: internal-error: void i387_supply_fxsave(regcache*, int, const void*): Assertion `tdep->st0_regnum >= I386_ST0_REGNUM' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

这是file hello的输出:

hello: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), statically linked, for GNU/Linux 3.7.0, BuildID[sha1]=a...b, with debug_info, not stripped

这是我的hello.c

#include<stdio.h>

int main(){
        printf("hello world");
        return 0;
}

我做错了什么?我还需要做什么?我在 x86_64 机器上运行 Ubuntu 18.04。

当我使用gdb hello时,我无法使用断点,我得到这个错误:

Reading symbols from hello...done.
(gdb) break 4
Breakpoint 1 at 0x400404: file hello.c, line 4.
(gdb) r
Starting program: /home/gt/hello
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x400404
(gdb)

我正在遵循第一部分下this page 提供的指南。

【问题讨论】:

    标签: gcc arm gdb


    【解决方案1】:

    为了运行和调试您的 AArch64 可执行文件,您(通常)需要在 AArch64 机器或 AArch64 模拟器中运行它。

    您可能有一些设置,其中 qemu 或多或少地为您透明地模拟 aarch64 二进制文件 - 但这对于调试器来说并不那么透明。一般来说,您可以在一台机器上运行调试器,通过网络连接到另一台机器上的调试服务器,允许您使用调试服务器调试在机器上运行的进程。

    您链接的指南显示了如何设置 qemu 以允许它在执行二进制文件时透明地模拟它们。该指南仅显示执行,而不是调试,但它有一个指向https://ubuntuforums.org/showthread.php?t=2010979&s=096fb05dbd59acbfc8542b71f4b590db&p=12061325#post12061325 的链接“使用 GDB 进行调试”,其中解释了如何调试在 qemu 仿真中执行的进程。这基本上相当于我上面提到的使用调试服务器进行远程调试。

    这篇文章的要点是:

    # In a terminal
    $ qemu-arm-static -g 10101 ./hello
    
    # In a new terminal
    $ gdb-multiarch 
    (gdb) target remote :10101
    Remote debugging using :10101
    [New Remote target]
    [Switching to Remote target]
    

    【讨论】:

      猜你喜欢
      • 2014-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-12
      • 1970-01-01
      • 2022-11-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多