Chapter 19.
Debugging remote programs
19.1. Connecting to a remote target
On the gdb host machine, you will need an unstripped copy of your program, since gdb needs symobl
and debugging information. Start up gdb as usual, using the name of the local copy of your program
as the first argument.
If you’re using a serial line, you may want to give gdb the
-baud
option, or use the
set remotebaud
command before the
target
command.
After that, use
target remote
to establish communications with the target machine. Its argument
specifies how to communicate--either via a devicename attached to a direct serial line, or a TCP or
UDP port (possibly to a terminal server which in turn has a serial line to the target). For example, to
use a serial line connected to the device named
/dev/ttyb
:
target remote /dev/ttyb
To use a TCP connection, use an argument of the form
host
:
port
or
tcp:
host
:
port
. For example,
to connect to port 2828 on a terminal server named
manyfarms
:
target remote manyfarms:2828
If your remote target is actually running on the same machine as your debugger session (e.g. a simu-
lator of your target running on the same host), you can omit the hostname. For example, to connect to
port 1234 on your local machine:
target remote :1234
Note that the colon is still required here.
To use a UDP connection, use an argument of the form
udp:
host
:
port
. For example, to connect to
UDP port 2828 on a terminal server named
manyfarms
:
target remote udp:manyfarms:2828
When using a UDP connection for remote debugging, you should keep in mind that the ‘U’ stands for
"Unreliable". UDP can silently drop packets on busy or unreliable networks, which will cause havoc
with your debugging session.
Now you can use all the usual commands to examine and change data and to step and continue the
remote program.
Whenever gdb is waiting for the remote program, if you type the interrupt character (often [C-C]), gdb
attempts to stop the program. This may or may not succeed, depending in part on the hardware and
Summary of Contents for ENTERPRISE LINUX 3 - SECURITY GUIDE
Page 1: ...Red Hat Enterprise Linux 3 Debugging with gdb ...
Page 12: ...2 Chapter 1 Debugging with gdb ...
Page 28: ...18 Chapter 4 Getting In and Out of gdb ...
Page 34: ...24 Chapter 5 gdb Commands ...
Page 44: ...34 Chapter 6 Running Programs Under gdb ...
Page 68: ...58 Chapter 8 Examining the Stack ...
Page 98: ...88 Chapter 10 Examining Data ...
Page 112: ...102 Chapter 12 Tracepoints ...
Page 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Page 138: ...128 Chapter 14 Using gdb with Different Languages ...
Page 144: ...134 Chapter 15 Examining the Symbol Table ...
Page 170: ...160 Chapter 19 Debugging remote programs ...
Page 198: ...188 Chapter 21 Controlling gdb ...
Page 204: ...194 Chapter 22 Canned Sequences of Commands ...
Page 206: ...196 Chapter 23 Command Interpreters ...
Page 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Page 296: ...286 Chapter 27 gdb Annotations ...
Page 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Page 322: ...312 Chapter 30 Using History Interactively ...
Page 362: ...352 Appendix D gdb Remote Serial Protocol ...
Page 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Page 386: ...376 Appendix G GNU Free Documentation License ...
Page 410: ......