154
Chapter 19. Debugging remote programs
the serial drivers the remote system uses. If you type the interrupt character once again, gdb displays
this prompt:
Interrupted while waiting for the program.
Give up (and stop debugging it)?
(y or n)
If you type
y
, gdb abandons the remote debugging session. (If you decide you want to try again later,
you can use
target remote
again to connect once more.) If you type
n
, gdb goes back to waiting.
detach
When you have finished debugging the remote program, you can use the
detach
command to
release it from gdb control. Detaching from the target normally resumes its execution, but the
results will depend on your particular remote stub. After the
detach
command, gdb is free to
connect to another target.
disconnect
The
disconnect
command behaves like
detach
, except that the target is generally not re-
sumed. It will wait for gdb (this instance or another one) to connect and continue debugging.
After the
disconnect
command, gdb is again free to connect to another target.
19.2. Using the
gdbserver
program
gdbserver
is a control program for Unix-like systems, which allows you to connect your program
with a remote gdb via
target remote
--but without linking in the usual debugging stub.
gdbserver
is not a complete replacement for the debugging stubs, because it requires essentially
the same operating-system facilities that gdb itself does. In fact, a system that can run
gdbserver
to connect to a remote gdb could also run gdb locally!
gdbserver
is sometimes useful nevertheless,
because it is a much smaller program than gdb itself. It is also easier to port than all of gdb, so you
may be able to get started more quickly on a new system by using
gdbserver
. Finally, if you develop
code for real-time systems, you may find that the tradeoffs involved in real-time operation make it
more convenient to do as much development work as possible on another system, for example by
cross-compiling. You can use
gdbserver
to make a similar choice for debugging.
gdb and
gdbserver
communicate via either a serial line or a TCP connection, using the standard gdb
remote serial protocol.
On the target machine,
you need to have a copy of the program you want to debug.
gdbserver
does not need your
program’s symbol table, so you can strip the program if necessary to save space. gdb on the host
system does all the symbol handling.
To use the server, you must tell it how to communicate with gdb; the name of your program; and
the arguments for your program. The usual syntax is:
target
C
gdbserver
comm program
[
args
... ]
comm
is either a device name (to use a serial line) or a TCP hostname and portnumber. For
example, to debug Emacs with the argument
foo.txt
and communicate with gdb over the serial
port
/dev/com1
:
target
C
gdbserver /dev/com1 emacs foo.txt
gdbserver
waits passively for the host gdb to communicate with it.
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: ......