views:

1433

answers:

4

Hi, I tried to remote debug an 32-bit application on x86_64 suse linux, but get this "remote register badly formatted" error.

I start up the gdbserver as listening on port 12345 (gdbserver localhost:12345 my_prog)

And this is the error:

$ gdb
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-suse-linux".
(gdb) target remote <ip>:12345
Remote debugging using <ip>:12345
Remote register badly formatted: T0506:0000000000000000;07:80b8bcff00000000;10:4028f0f700000000;
here: 0000000;07:80b8bcff00000000;10:4028f0f700000000;
(gdb)

This is the debug server machine (uname -a):

Linux server 2.6.16.60-0.31-smp #1 SMP Tue Oct 7 16:16:29 UTC 2008 x86_64 x86_64 x86_64 GNU/Linux

And this is the debug client machine (uname -a):

Linux client 2.6.16.54-0.2.5-default #1 Mon Jan 21 13:29:51 UTC 2008 x86_64 x86_64 x86_64 GNU/Linux

Both machines are running in virtual machines though (VMWare). The gdbserver binary is copied from the client machine to the server machine.

(I remote debug because the runtime environment on the debug server is production-like, and doesn't contain any development tools, access to the source code etc.)

Any suggestions are welcome.

UPDATE: this worked for me by issuing the following command in gdb:

set architecture i386:x86-64

A: 

Perhaps you need to execute something like set architecture i386 at the (gdb) prompt? What does show architecture say after you connect to the remote target?

sigjuice
It says i386 (auto). Actually, when I set arch to "i386:x86-64:intel", it starts up without the error message, but when I try to step in the code, it gives me: "Cannot access memory at address 0x1f7fb5000".
boffman
Can you run the whole thing (gdbserver, gdb, 32-bit app) on the client machine? Do you run into the same issues?
sigjuice
A: 

Maybe you've already checked this, but here goes: - On the 64-bit machine, do you have 32-bit libraries of it (libc, etc)? - Have you tried running gdb with the "-nx" (no initialization files) switch?

jbatista
Yes, 32-bit libs are in /lib, and 64-bit are in /lib64. I tried gdb -nx but I could not notice any difference?
boffman
+1  A: 

A 64-bit GDB can directly debug both 32 and 64-bit inferior processes (I believe this is called multi-arch support).

Not so with gdbserver: it doesn't support multi-arch debugging.

You need a gdbserver that matches target architecture, and gdb that matches gdbserver. Build them from source, configure with --target=i686.

Employed Russian
A: 

1) You need a proper gdbserver for your target machine and your host machine (the one which fits the target machine in your case.

Let's say I want to debug a ppc target from an x86 host:

I will need on my target a ppc executable gdbserver.

I will need on my host an x86 executable gdb for powerpc.

After you are set with those things you have to do the following from your host gdb before connecting to the target in case you use shared libs:

set solib-absolute-prefix $ELDK_PREFIX/eldk-4.2-ppc_4xx/$CROSS_COMPILE

dir $ELDK_PREFIX/eldk-4.2-ppc_4xx/$CROSS_COMPILE

otherwise the host gdb will get crazy trying to load shared libs for x86.

robert.berger