我在Android上使用gdbserver和gdbserver64以及在我的主机上使用伴侣aarch64 gdb时遇到了很多麻烦 . 例如,我遇到这样的问题,gdb正在输出看起来像废话的东西:

(gdb) target remote :5039
Remote debugging using :5039
warning: Could not load vsyscall page because no executable was specified
try using the "file" command first.
0x0000007fa7921d2c in ?? ()
(gdb) bt
Python Exception <type 'exceptions.ImportError'> No module named gdb.frames: 
#0  0x0000007fa7921d2c in ?? ()
#1  0x0000000040000600 in ?? ()
Backtrace stopped: Cannot access memory at address 0x22eee199476794f4
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x0000007f87c249b4 in ?? ()
(gdb) x/4i $pc
=> 0x7f87c249b4:    ldrb    w8, [x0,#432]
   0x7f87c249b8:    cbz w8, 0x7f87c249ec
   0x7f87c249bc:    ldr x8, [x19,#3632]
   0x7f87c249c0:    ldr x9, [x8,#24]
(gdb) bt
Python Exception <type 'exceptions.ImportError'> No module named gdb.frames: 
#0  0x0000007f87c249b4 in ?? ()
#1  0x0000007fa4b4fb25 in ?? ()
#2  0x0000000000000001 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) c
Continuing.
[New Thread 22374]
[New Thread 22375]

Program received signal SIGSEGV, Segmentation fault.
0x0000007f87c249b4 in ?? ()
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x0000007f87c249b4 in ?? ()

这几乎是不可能使用的,一切都完全无益 . 没有加载符号,也没有回溯甚至是合理的 . 应用程序也会在使用静态gdb进行过度跟踪或跟踪时不会发出信号的地方重复发出信号(只是用它来命名一个特定问题) .

但是,我能够使用预构建的armv7a静态链接gdb二进制文件来相对轻松地调试Android模拟器中的某些32位应用程序 . 我在设备shell中运行静态gdb没有问题 . 我没有加载符号的麻烦,没有奇怪的信号问题 .

我无法在任何地方找到静态链接的aarch64 gdb二进制文件,所以我尝试在我的aarch64 chroot中构建一个 . 我确实设法为aarch64构建gdb,我使用了these configure flags

LDFLAGS="-static" ../configure --prefix=/noprefix --enable-static --disable-shared --disable-interprocess-agent --disable-libcc1

但它是动态链接的,这不是我想要的 .

root@gram:/opt/gdb-aarch64/noprefix/bin# file gdb
gdb: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=f1a630e569467794c45b4389f510720c4342704b, not stripped

如何构建静态链接的linux aarch64 gdb?