Question

I've got a 64-bit remote machine, anvil, and a 32 bit desktop.

I make a program called hello.c and on anvil I compile it with

  $ gcc -ggdb -o hello hello.c

It will run and debug fine on anvil.

But I'd like to debug it from my desktop (so I can use the debugger through emacs)

So :

$gdbserver anvil:24000 hello
Process hello created; pid = 10991
Listening on port 24000

But then on the desktop, I try to connect remotely, and all I get is strange errors There's some sign of connectivity: after I type target remote anvil:24000 the other end prints 'Remote debugging from host 10.17.20.149', which is my desktop address.

Here's a transcript:

jla@jaspden-desktop$ gdb hello

GNU gdb (GDB) Fedora (7.2-51.fc14)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/jla/myco/chip_test/hello...done.
(gdb) target remote anvil:24000
Remote debugging using anvil:24000
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
0x0000003ed0100a80 in ?? ()
(gdb) b main
Breakpoint 1 at 0x4004b7: file hello.c, line 6.
(gdb) run
The "remote" target does not support "run".  Try "help target" or "continue".
(gdb) continue
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
0x00000000004003f6 in _start ()
(gdb) 

Does anyone know what I'm doing wrong?

Était-ce utile?

La solution

Does anyone know what I'm doing wrong?

gcc -ggdb -o hello hello.c

This likely produces a 64-bit binary (though we can't tell for sure from what you've provided so far). As I said before, it doesn't matter that anvil is a 64-bit machine. What matters is what binary you are trying to debug.

What does file hello say?

GNU gdb (GDB) Fedora (7.2-51.fc14)
...
This GDB was configured as "i686-redhat-linux-gnu".

That's a problem: if hello is a 64-bit binary, then you can't debug it with this version of gdb. You will need to build a new version, configured with --host=i686-linux and --target=x86_64-linux.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top