The RSP packet cannot be represented as a simple string, since binary packets may contain null (string terminator) characters. Instead the packet is represented as a character buffer and separate length field. However by convention the character buffer is also null-terminated, allowing non-binary packets to be printed out for debugging purposes. The public interface to this class is as follows:
RspPacket
. The constructor takes a single
integer argument, the size of the data buffer to allocate. It
allocates that buffer and stores the record of its size.
~RspPacket
. The destructor deletes the
allocated data buffer.
data
. A pointer to the data buffer.
packStr
. Takes a string constant as
argument and packs it into the data buffer, setting the length
field to the length of the string.
getBufSize
, getLen
and
setLen
. Accessor functions to get the size
of the data buffer and to get and set the length of the data
currently stored there.
Note | |
---|---|
Although by convention all data is stored null-terminated in the buffer, this null-termination is a convenience for debugging the GDB server and does not form part of the data. The length does not include this null-termination character. |