Jump to content

Gdbserver

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by SmackBot (talk | contribs) at 21:23, 19 February 2010 (Date maintenance tags and general fixes: build 400:). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

gdbserver is a computer program that allows to remotely debug other programs[1]. It runs in the system with the program to be debugged and allows the GNU Debugger to connect from a different system.

It only needs the presence of the executable on the target, while the source code and a copy of the binary file stay in the computer used by the developer.

How It Works

  1. gdbserver is launched on the target with the path and name of the executable to debug, and a port number (TCP or UDP). It listens for connections on the port.
  2. gdb is run on the host with the path and name of the executable (and the sources) on the host, and the IP address and port number to connect to the target.

Example for debugging a program in a remote host called hello_world ("2345" is the TCP port number):

remote$ gdbserver :2345 hello_world
Process hello_world created; pid = 2509
Listening on port 2345
local$ gdb -q hello_world
Reading symbols from /home/user/hello_world...done.
(gdb) target remote 192.168.0.11:2345
Remote debugging using 192.168.0.11:2345
0x002f3850 in ?? () from /lib/ld-linux.so.2
(gdb) continue
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x08048414 in main () at hello_world.c:10
10	        printf("x[%d] = %g\n", i, x[i]);
(gdb) 

Alternatives

A different technique to remotely debug programs is to use a remote stub[2].[clarification needed]

The program to debug is linked with a few special-purpose subroutines that implement the GDB remote serial protocol. The file containing these subroutines is called a debugging stub.

See also

Notes

References

  • Andreas Zeller: Why Programs Fail: A Guide to Systematic Debugging, Morgan Kaufmann, 2005. ISBN 1-55860-866-4