GDB 交叉编译 arm

GDB 交叉编译 arm

我在 ubuntu 16.04 上交叉编译 gdb 来调试在 arm 上运行的应用程序。我关注的主要教程是 https://sourceware.org/gdb/wiki/BuildingCrossGDBandGDBserver

我的 ubuntu 上安装的交叉工具链是 aarch64-himix100-linux,我已通过以下方式检查了目标名称:

aarch64-himix100-linux-gcc -v

结果表明 Target: aarch64-linux-gnu

我下载了 gdb-7.10.1 源代码并将其解压到名为“gdb-7.10.1”的文件夹中。然后我在“gdb-7.10.1”旁边创建了两个文件夹“build_gdb”和“build_gdbserver”,并开始构建:

cd build_gdb
../gdb-7.10.1/configure --target=aarch64-linux-gnu
make
cd ..
cd build_gdbserver
../gdb-7.10.1/gdb/gdbserver/configure --host=aarch64-linux-gnu
make

gdbserver 的最后一步make显示以下信息:

../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c: In function ‘aarch64_fill_gregset’:
../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c:233:62: error: dereferencing pointer to incomplete type ‘struct user_pt_regs’
     collect_register (regcache, AARCH64_X0_REGNO + i, &regset->regs[i]);
                                                              ^
../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c: In function ‘aarch64_store_gregset’:
../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c:246:61: error: dereferencing pointer to incomplete type ‘const struct user_pt_regs’
     supply_register (regcache, AARCH64_X0_REGNO + i, &regset->regs[i]);
                                                             ^
../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c: In function ‘aarch64_fill_fpregset’:
../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c:259:62: error: dereferencing pointer to incomplete type ‘struct user_fpsimd_state’
     collect_register (regcache, AARCH64_V0_REGNO + i, &regset->vregs[i]);
                                                              ^
../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c: In function ‘aarch64_store_fpregset’:
../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c:271:61: error: dereferencing pointer to incomplete type ‘const struct user_fpsimd_state’
     supply_register (regcache, AARCH64_V0_REGNO + i, &regset->vregs[i]);
                                                             ^
../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c: In function ‘aarch64_linux_set_debug_regs’:
../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c:581:29: error: storage size of ‘regs’ isn’t known
   struct user_hwdebug_state regs;
                             ^
In file included from /usr/include/signal.h:316:0,
                 from ../gdb-7.10.1/gdb/gdbserver/linux-low.h:21,
                 from ../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c:23:
../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c:592:35: error: invalid use of undefined type ‘struct user_hwdebug_state’
   iov.iov_len = (offsetof (struct user_hwdebug_state, dbg_regs[count - 1])
                                   ^
../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c:581:29: warning: unused variable ‘regs’ [-Wunused-variable]
   struct user_hwdebug_state regs;
                             ^
../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c: In function ‘aarch64_arch_setup’:
../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c:1220:29: error: storage size of ‘dreg_state’ isn’t known
   struct user_hwdebug_state dreg_state;
                             ^
../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c:1220:29: warning: unused variable ‘dreg_state’ [-Wunused-variable]
../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c: At top level:
../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c:1272:13: error: invalid application of ‘sizeof’ to incomplete type ‘struct user_pt_regs’
     sizeof (struct user_pt_regs), GENERAL_REGS,
             ^
../gdb-7.10.1/gdb/gdbserver/linux-aarch64-low.c:1275:13: error: invalid application of ‘sizeof’ to incomplete type ‘struct user_fpsimd_state’
     sizeof (struct user_fpsimd_state), FP_REGS,
             ^
Makefile:257: recipe for target 'linux-aarch64-low.o' failed
make: *** [linux-aarch64-low.o] Error 1

这个错误是 gdb 源代码的问题吗?如何修复?谢谢!

答案1

问题解决了。如果您遇到此问题,请按照以下方法操作: gdb 维基我在我的问题中提到过。我对 gdb wiki 的补充说明是:

gdb 的“--target”以及 gdbserver 的“--host”不应该是结果中的“Target”行

aarch64-himix100-linux-gcc -v

即 aarch64-linux-gnu,而是你的交叉工具链的名称,在我的情况下是“aarch64-himix100-linux”。

相关内容