The X provides for data to be written to the
target in binary format. This is the mechanism of choice for program
loading (the GDB load command). GDB will
first probe the target with an empty X packet
(which is 7-bit clean). If an "OK"
response is
received, subsequent transfers will use the X
packet. Otherwise M packets will be used. Thus
even 7-bit clean implementations should still support replying to an
empty X packet.
The example implementation is found in
rsp_write_mem_bin ()
. Even though the data
is binary, it must still be escaped so that '#', '$' and '}'
characters are not mistaken for new packets or escaped characters.
Each byte is read, and if escaped, restored to its original
value. The data is written using
set_program8 ()
, having first verified the
memory location with verify_memoryarea ()
.
If all bytes are successfully written, a reply packet of
"OK"
is sent. Otherwise and error packet ("E01")
is sent. The error number does not matter—it is ignored by the
target.