9

I try to use remotely the gdbserver for debug as follows

Start the gdbserver on target machine

$ gdbserver localhost:2000 hello -l 20 -b 10 --enable-targets=all

Host machine has the program binary with debugging enabled

"copied binary from ARM target to host" 

Run gdb on host machine

$ gdb -q --args hello --enable-target=all

Connect to the target

(gdb) target remote 192.168.15.132
192.168.15.132: No such file or directory.
(gdb) target remote 192.168.15.132:2000
Remote debugging using 192.168.15.132:2000
warning: while parsing target description (at line 11): Target description specified unknown architecture "aarch64"
warning: Could not load XML target description; ignoring
Remote register badly formatted: T051d:0000000000000000;1f:80fcffffffff0000;20:403cfdb7ffff0000;thread:pd60.d60;core:1;
here: 00000000;1f:80fcffffffff0000;20:403cfdb7ffff0000;thread:pd60.d60;core:1;
(gdb) q

I am looking for an advice to correctly debug with ARM remote target.

user3428154
  • 1,174
  • 5
  • 18
  • 38
  • Could you please provide the outputs for the five following commands: 1) on the target machine: "uname -a" , "gdbserver --version" , "file hello" 2) on the host machine: "uname -a" and "gdb --configuration" - please use the paths to the exact versions of gdbserver, gdb and hello you are using. – Frant Nov 29 '18 at 04:09
  • 1) uname -a Linux imx8qmmek 4.9.51-8qm_beta2_8qxp_beta+g423d942 #1 SMP PREEMPT Tue Sep 18 14:49:17 CEST 2018 aarch64 aarch64 aarch64 GNU/Linux, – user3428154 Nov 29 '18 at 10:02
  • 1) gdbserver --version GNU gdbserver (GDB) 7.11.1 Copyright (C) 2016 Free Software Foundation, Inc. gdbserver is free software, covered by the GNU General Public License. This gdbserver was configured as "aarch64-poky-linux" – user3428154 Nov 29 '18 at 10:03
  • 1) ~/test1# file hello hello: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.14.0, BuildID[sha1]=800749f3ba9f83a96e4b47d6973d5139312409e8, not stripped root@imx8qmmek:~/test1# – user3428154 Nov 29 '18 at 10:04
  • 2) uname -a Linux ubuntu-Latitude-7480 4.15.0-39-generic #42~16.04.1-Ubuntu SMP Wed Oct 24 17:09:54 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux – user3428154 Nov 29 '18 at 10:05
  • 2) ~/work/test1$ which gdb /usr/bin/gdb gdb --configuration configure --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-auto-load-dir=$debugdir:$datadir/auto-load --with-auto-load-safe-path=$debugdir:$datadir/auto-load --with-expat --with-gdb-datadir=/usr/share/gdb (relocatable) --with-jit-reader-dir=/usr/lib/gdb (relocatable) --without-libunwind-ia64 --with-lzma --with-python=/usr (relocatable) --without-guile --with-separate-debug-dir=/usr/lib/debug (relocatable) --with-system-gdbinit=/etc/gdb/gdbinit --with-babeltrace – user3428154 Nov 29 '18 at 10:09
  • ./home/root/test1/hello; /usr/bin/gdbserver ; /usr/bin/gdb – user3428154 Nov 29 '18 at 10:14
  • gdb on host side is not providing aarch64, (gdb) set architecture auto i386:x64-32 i386:x86-64:intel i386 i386:x64-32:intel i386:x86-64:nacl i386:intel i386:x64-32:nacl i8086 i386:nacl i386:x86-64 (gdb) set architecture – user3428154 Nov 29 '18 at 10:18

2 Answers2

21

To debug executables compiled for a different architecture, install gdb-multiarch and run gdb-multiarch instead of gdb. Different distributions compile gdb differently and some even lack the multiarch version in their repositories - RHEL doesn't include it, but it's present in Ubuntu and Debian.

Syfer Polski
  • 308
  • 3
  • 7
  • 1
    This is the right answer. gdbserver running on aarch64 and gdb-multiarch from ubuntu. sudo apt-get install -y gdb-multiarch – badri Jul 23 '20 at 19:04
1

Since you are reporting that your GDB supports the following architectures: i386:x64-32 i386:x86-64:intel i386 i386:x64-32:intel i386:x86-64:nacl i386:intel i386:x64-32:nacl i8086 i386:nacl i386:x86-64, you may be attempting to remotely debug an aarch64-linux-gnu executable using an x86_64-targeted version of gdb.I would suggest to download/install gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz:

wget https://releases.linaro.org/components/toolchain/binaries/latest-7/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
tar Jxvf  gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz -C /opt

and then use /opt/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gdb for remotely debugging your program.

Frant
  • 5,382
  • 1
  • 16
  • 22
  • wget URL didn't worked for me but this 7.5 version worked gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz – cyber_raj Apr 05 '23 at 08:17