Remote debug error with GDB

12,917

Solution 1

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?

Solution 2

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.

Share:
12,917
boffman
Author by

boffman

Updated on June 09, 2022

Comments

  • boffman
    boffman almost 2 years

    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

  • boffman
    boffman about 15 years
    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".