Appendix D.
gdb Remote Serial Protocol
D.1. Overview
There may be occasions when you need to know something about the protocol--for example, if there
is only one serial port to your target machine, you might want your program to do something special
if it recognizes a packet meant for gdb.
In the examples below,
-
]
and
^
-
are used to indicate transmitted and received data respectfully.
All gdb commands and responses (other than acknowledgments) are sent as a
packet
. A
packet
is
introduced with the character
$
, the actual
packet-data
, and the terminating character
#
followed
by a two-digit
checksum
:
$packet-data#checksum
The two-digit
checksum
is computed as the modulo 256 sum of all characters between the leading
$
and the trailing
#
(an eight bit unsigned checksum).
Implementors should note that prior to gdb 5.0 the protocol specification also included an optional
two-digit
sequence-id
:
$sequence-id:packet-data#checksum
That
sequence-id
was appended to the acknowledgment. gdb has never output
sequence-id
s.
Stubs that handle packets added since gdb 5.0 must not accept
sequence-id
.
When either the host or the target machine receives a packet, the first response expected is an acknowl-
edgment: either
+
(to indicate the package was received correctly) or
-
(to request retransmission):
-
]
$packet-data#checksum
^
-
+
The host (gdb) sends
command
s, and the target (the debugging stub incorporated in your program)
sends a
response
. In the case of step and continue
command
s, the response is only sent when the
operation has completed (the target has again stopped).
packet-data
consists of a sequence of characters with the exception of
#
and
$
(see
X
packet for
additional exceptions).
Fields within the packet should be separated using
, ;
or
:
. Except where otherwise noted all numbers
are represented in hex with leading zeros suppressed.
Implementors should note that prior to gdb 5.0, the character
:
could not appear as the third character
in a packet (as it would potentially conflict with the
sequence-id
).
Response
data
can be run-length encoded to save space. A
*
means that the next character is an ascii
encoding giving a repeat count which stands for that many repetitions of the character preceding the
*
. The encoding is
n+29
, yielding a printable character where
n
]
=3
(which is where rle starts to
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: ......