manpagez: man pages & more
info gdb
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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 No value for GDBN.

In the examples below, ‘->’ and ‘<-’ are used to indicate transmitted and received data, respectively.

All No value for GDBN 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 No value for GDBN 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. No value for GDBN has never output sequence-ids. Stubs that handle packets added since No value for GDBN 5.0 must not accept sequence-id.

When either the host or the target machine receives a packet, the first response expected is an acknowledgment: either ‘+’ (to indicate the package was received correctly) or ‘-’ (to request retransmission):

 
-> $packet-data#checksum
<- +

The host (No value for GDBN) sends commands, and the target (the debugging stub incorporated in your program) sends a response. In the case of step and continue commands, 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 No value for GDBN 5.0, the character ‘:’ could not appear as the third character in a packet (as it would potentially conflict with the sequence-id).

Binary data in most packets is encoded either as two hexadecimal digits per byte of binary data. This allowed the traditional remote protocol to work over connections which were only seven-bit clean. Some packets designed more recently assume an eight-bit clean connection, and use a more efficient encoding to send and receive binary data.

The binary data representation uses 7d (ASCII}’) as an escape character. Any escaped byte is transmitted as the escape character followed by the original character XORed with 0x20. For example, the byte 0x7d would be transmitted as the two bytes 0x7d 0x5d. The bytes 0x23 (ASCII#’), 0x24 (ASCII$’), and 0x7d (ASCII}’) must always be escaped. Responses sent by the stub must also escape 0x2a (ASCII*’), so that it is not interpreted as the start of a run-length encoded sequence (described next).

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 win). The printable characters ‘$’, ‘#’, ‘+’ and ‘-’ or with a numeric value greater than 126 should not be used.

So:

 
"0* "

means the same as "0000".

The error response returned for some packets includes a two character error number. That number is not well defined.

For any command not supported by the stub, an empty response (‘$#00’) should be returned. That way it is possible to extend the protocol. A newer No value for GDBN can tell if a packet is supported based on that response.

A stub is required to support the ‘g’, ‘G’, ‘m’, ‘M’, ‘c’, and ‘scommands. All other commands are optional.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2017
Individual documents may contain additional copyright information.