my-server
← Wiki

Gdbserver

gdbserver is a computer program that makes it possible to remotely debug other programs. Running on the same system as the program to be debugged, it allows the GNU Debugger to connect from another system; that is, only the executable to be debugged needs to be resident on the target system ("target"), while the source code and a copy of the binary file to be debugged reside on the developer's local computer ("host"). The connection can be either TCP or a serial line.

How it works

  1. <code>gdbserver</code> is launched on the target system, with the arguments:
  2. * Either a device name (to use a serial line) or a TCP hostname and port number, and
  3. * The path and filename of the executable to be debugged
  4. :It then waits passively for the host gdb to communicate with it.
  5. <code>gdb</code> is run on the host, with the arguments:
  6. * The path and filename of the executable (and any sources) on the host, and
  7. * A device name (for a serial line) or the IP address and port number needed for connection to the target system.

Example for debugging a program called <code>hello_world</code> on a remote target using TCP ("2159" is the registered TCP port number for remote GDB):

Alternatives

Another technique for debugging programs remotely is to use a remote stub. In this case, the program to be debugged 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: <cite>Why Programs Fail: A Guide to Systematic Debugging</cite>, Morgan Kaufmann, 2005.

External links