Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't remote debug with GDB

Tags:

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

like image 550
ransh Avatar asked May 29 '14 13:05

ransh


Video Answer


3 Answers

i had a similar problem, debugging code on a ARM CortexA5 from openSUSE 13.1 i64. problem occured, when i called the gdbserver on the target and gdb on the laptop, but called gdb on laptop not pointing to the cross compiled binary, but to the one compiled for the laptop (hence i64).

after calling gdb on the laptop pointing to the same, cross compiled binary that is started with gdbserver on the target, all is OK and the error message dissapears.

like image 167
Martin Wilde Avatar answered Sep 24 '22 10:09

Martin Wilde


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)

like image 37
Felipe Avatar answered Sep 24 '22 10:09

Felipe


This means that gdb you called on local machine and gdbserver you called on remote machine is of different architecture, this also means that the application you compiled would be cross-compiled with a compiler supported by your remote machine. So in the local machine you should call the gdb supported by the remote machine. Most probably it would be available in the same path where your cross compiler exists.

like image 43
Nikhil Augustine Avatar answered Sep 23 '22 10:09

Nikhil Augustine