ransh
ransh

Reputation: 1702

can't remote debug with 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

Upvotes: 10

Views: 23566

Answers (4)

Kadir Erdem Demir
Kadir Erdem Demir

Reputation: 3595

I just configured my windows and now I can remote debug from my windows machine to a linux binary. Be sure your GDB compiled with correct options in your host machine(windows machine in my case). An example:

./gdb-7.4/configure --with-expat --target=x86_64-unknown-linux-gnu --host=i686-pc-mingw32

If you don't have expat download and install it.

You should download the gdb source code. And in same folder you should run configure.

--target option value should be same as the target's gdb banner. Go to target machine(linux in my case) and type gdb you will see something like x86_64-unknown-linux-gnu, you should input this value.

--host option should be i686-pc-mingw32 if you are on windows and using mingw.

Upvotes: 0

Nikhil Augustine
Nikhil Augustine

Reputation: 197

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.

Upvotes: 2

Felipe
Felipe

Reputation: 109

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)

Upvotes: 8

Martin Wilde
Martin Wilde

Reputation: 91

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.

Upvotes: 3

Related Questions