Can’t remote debug with GDB

gdb

I'm trying to debug target with gdb, but get rejection.

(gdb) target remote 10.0.0.2:2345
Remote debugging using 10.0.0.2:2345
warning: Architecture rejected target-supplied description
Remote 'g' packet reply is too long: 00000000ba4eefbe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c04defbe0000000090770940100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

The PC is 64-bit architecture, ubuntu 64-bit

$ uname -a
Linux ubuntu-VirtualBox 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Trying to set different architecture doesn't help.
(gdb) set architecture i386:x86-64:intel
The target architecture is assumed to be i386:x86-64:intel
(gdb) target remote 10.0.0.2:2345
Remote debugging using 10.0.0.2:2345
warning: Architecture rejected target-supplied description
Reply contains invalid hex digit 59

Thanks for any idea,
Ran

Best Answer

I solved this problem using the gdb-multiarch instead of only gdb in my remote machine.

When I was using the gdb I got the following error:

(gdb) target remote 192.168.1.254:9092
Remote debugging using 192.168.1.254:9092
warning: Architecture rejected target-supplied description
Remote 'g' packet reply is too long: 000000002efeffbe34feffbe0000000000000000000000000000000000000000000000000000000000000000000000000000000020fdffbe000000006c1effb6100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
(gdb)

My remote machine is as 32bit Intel Ubuntu V 16.04 and the target machine is an ARM 32bit Linux.

I followed these steps:

1: Keep the same binary executable in remote and target machine (compiled to the target machine and with Debug option, which in GCC is just a "-g" option);

2: Install gdbserver on target machine:

$ sudo apt install gdbserver

3: Install gdb-multiarch in the remote machine:

$ sudo apt install gdb-multiarch

4: Start gdbserver on target Machine:

$ gdbserver localhost:9092 app

where 9092 is the port I chose and app is the name of the binary executable;

5: Start gdb-multiarch on remote machine:

$ gdb-multiarch app

6: Type gbd-multiarch command:

(gdb) target remote 192.168.1.254:9092

where that IP address is the one of my target machine;

After step 6 I got the following screen (instead of the error), and the debug worked well:

(gdb) target remote 192.168.1.254:9092
Remote debugging using 192.168.1.254:9092
Reading /lib/ld-uClibc.so.0 from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /lib/ld-uClibc.so.0 from remote target...
Reading symbols from target:/lib/ld-uClibc.so.0...(no debugging symbols found)...done.
0xb6ff1e6c in _start () from target:/lib/ld-uClibc.so.0
(gdb)