GDB Remote Protocol Messages


SET THREAD
Syntax Hc<n> Set step/continue thread (-1 == all threads).
Hg<n> Set general operation thread (0 == any thread).
Reply OK, E<n> n == two-digit error code.
READ REGISTERS
Syntax g Get all cpu registers.
Reply hex-data Data consists of a single block of hex data representing the concatenation of the values of all registers. GDB must know their order and size to pick the values apart. Data is in target byte order.
E<n> n == two-digit error code.
WRITE REGISTERS
Syntax G<hex-data> Set all cpu registers. Data consists of a single block of hex data representing the concatenation of the values of all registers. Stub must know their order and size to pick the values apart. Data is in target byte order.
Reply OK, E<n> n == two-digit error code.
WRITE SINGLE REGISTER
Syntax: P<n>=<value> Set value of selected register. n == register number, value == new value in hex (target byte order).
Reply OK, E<n> n == two-digit error code.
"" WRITE SINGLE REGISTER not supported by this stub.
READ MEMORY
Syntax m<addr>,<len> Read len bytes starting at memory address addr.
Reply hex-data The values of the requested memory in target byte order. May be shorter than requested, if some of the memory could not be read.
E<n> n == two-digit error code.
NOTE: partial success should be reported as an error.
WRITE MEMORY
Syntax M<addr>,<len>:<hex-data> Write len bytes starting at memory address addr, with the values of the following data block (which is in target byte order).
Reply OK, E<n> n == two-digit error code.
NOTE: partial success should be reported as an error.
CONTINUE
Syntax c, or c<addr> Continue the target program (starting from addr if present, else from last known program counter).
Reply No reply is sent until the target stops; then the reply is the same as for GET REASON FOR STOPPING.
CONTINUE WITH SIGNAL
Syntax C<signal>, or C<signal>;<addr> Continue the target program (starting from addr if present, else from last known program counter), but cause it to behave as if receiving signal "signal".
Reply No reply is sent until the target stops; then the reply is the same as for GET REASON FOR STOPPING.
SINGLE-STEP
Syntax s, or s<addr> Single-step the target program (starting from addr if present, else from last known program counter).
Reply No reply is sent until the target stops; then the reply is the same as for GET REASON FOR STOPPING.
SINGLE-STEP WITH SIGNAL
Syntax S<signal>, or S<signal>;<addr> Single-step the target program (starting from addr if present, else from last known program counter), but cause it to behave as if receiving signal "signal".
Reply No reply is sent until the target stops; then the reply is the same as for GET REASON FOR STOPPING.
GET REASON FOR STOPPING
Syntax ? Get the (unix-like) signal number representing the reason for the most recent target stop (usually an exception or trap).
Reply S<signal> Target stopped with (unix-like) signal "signal".
T<signal>[<regnum>:<value>]+ Target stopped with (unix-like) signal "signal", and with the following list of register values in arbitrary order. As always, register values (if present) are in target byte order. Note that the "T" reply is an enhancement not implemented by all stubs.
W<exitcode> Target process exited with exitcode. Not supported by all stubs.
X<signal> Target process terminated with signal "signal". Not supported by all stubs.
IS THREAD ALIVE
Syntax T<threadnum> Find out if thread threadnum is alive.
Reply OK, E<n> n is ignored; simply means thread is not alive.
REMOTE RESTART
Syntax R<value> Restart the remote server.
Reply No reply will be sent. This message is normally followed by GET REASON FOR STOPPING.
REMOTE KILL
Syntax k Kill the remote process.
Reply "" Some stubs may reply with an empty packet; however GDB does not wait for a reply.
REMOTE DETACH
Syntax D Detach the remote process from the server/stub. For most stubs, this is a no-op.
Reply "" GDB does not wait for a reply.
SET BAUDRATE
Syntax b<n> n is the desired baudrate, in hex.
Reply OK Baud rate was set to n.
B01 Not supported.
TOGGLE DEBUG
Syntax d Toggle the stub debug mode (on to off, or off to on).
Reply "" This message is never used by GDB.
REMOTE RESET
Syntax r Reset the remote target board.
Reply Target will not reply, but will immediately reset.
USE EXTENDED SYNTAX
Syntax ! Use "extended remote protocol" extensions. This message is "sticky"; it only needs to be sent once.
Reply "" Reply is ignored by GDB.
GENERAL QUERY
Syntax q<anything> A general purpose command for extending the protocol, or defining target-specific queries.
Reply <anything> Replies will be defined for the specific query messages.
GENERAL SET
Syntax Q<anything> A general purpose command for extending the protocol, or defining target-specific "set" requests.
Reply <anything> Replies will be defined for the specific set messages.
UNKNOWN MESSAGE
Syntax Anything not covered above. All stubs should ignore any message that is correctly formatted (with checksum), yet otherwise unknown to them.
Reply "" The correct reply for an unrecognized message is an empty packet.
VERBOSE REPLY
Syntax O<hex-data> In certain circumstances (notably when the target process is running, ie. between receipt of CONTINUE/STEP and the reply of GET REASON FOR STOPPING), the stub may send a verbose message to GDB. This reply contains an arbitrary ascii string, encoded as two hex bytes per ascii character. GDB is expected to display this string to the console.

Extensions to the GDB Remote Protocol for Tracing

QUERY TRACE STATUS
Syntax qTStatus Get the status of the target trace subsystem.
Reply T0 Trace not running.
T1 Trace is running.
"" Empty packet: target does not support tracing.
INITIALIZE TRACE SUBSYSTEM
Syntax QTinit Set trace subsystem to "initialized" state (whatever that entails).
Reply OK Target trace initialized.
"" Empty packet: target does not support tracing.
START TRACE
Syntax QTStart Set trace subsystem to "running" state (insert trace traps etc., begin collecting data).
Reply OK Target trace started, trace traps inserted.
"" Empty packet: target does not support tracing.
STOP TRACE
Syntax QTStop Set trace subsystem to "not running" state (remove trace traps etc., cease collecting data).
Reply OK Target trace stopped, trace traps removed.
"" Empty packet: target does not support tracing.
SET TRACEPOINT
Syntax QTDP:[-]<id>:<addr>:<attributes>[-] Set (define) a tracepoint with id, address and other attributes as follows. If the message ends in a dash (-), then it is to be continued in the next message. If the id is preceeded by a dash (-), then this message is a continuation of the preceeding one.
Syntax of attributes: <enabled>: Values are 'E' (enabled) or 'D' (disabled). Required and position-dependent, can only cocur in the first message of a split SET TRACEPOINT request, following <addr>:
<stepcount>: How many times to single-step after tracepoint trap. Required and position dependent, can only occur in the first message of a split SET TRACEPOINT request, following <enabled>:
<passcount>: Number of times to allow this tracepoint to be triggered before automatically invoking STOP TRACE. Required and position dependent, can only occur in the first message of a split SET TRACEPOINT request, following <stepcount>:
R<register-mask> Each 'on' bit in the register mask represents a register to be collected at the trace event. With the rightmost bit representing register zero, the registers are numbered in the same order that GDB and the stub already agree upon for all other register operations.
M<regnum>,<offset>,<len> Memory range to be collected at the trace event. Each tracepoint definition may have an arbitrary number of memrange attributes. Regnum, offset and len are hex numbers. A positive integer regnum represents a memory range with a register-relative starting offset; otherwise the starting offset is absolute.
X<len>,<bytecode> Bytecode string to be executed at the trace event. Len represents the length of the bytecode string. Each tracepoint definition may have an arbitrary number of bytecode attributes. The format of the bytecode string is described in The GDB Agent Expression Mechanism.
S Fencepost token, separating the preceeding R, M and X attributes (to be collected at the trace trap event) from the following R, M and X attributes (to be collectted while single-stepping). Optional, and there can be only one per tracepoint definition. If this token is not present, then all R, M and X attributes apply to the trace trap event (not to stepping events).
Reply OK Tracepoint definition accepted.
E<n> Tracepoint definition rejected (error codes TBD).
"" Target does not support tracepoints. [NOTE: this may not mean that the target does not support tracing. Some targets may support some extremely simple form of tracing which might, for instance, simply be "on" or "off".]
REQUEST TRACE FRAME BY NUMBER
Syntax QTFrame:<n> Find the collected data associated with trace event number n. Trace events are numbered sequentially from zero.
Reply F<x> Frame x found. X may not be equal to n, if the frame buffer is circular and if the oldest frame in the buffer is older than n (in which case x will be the oldest frame).
F<x>T<y> As above, but y is the tracepoint id associated with trace frame x (if the target can provide this information).
F-1 No corresponding trace frame found.
"" Empty packet: target does not support tracing.
REQUEST TRACE FRAME BY PC
Syntax QTFrame:pc:<addr> Find the next collected data associated with a trace event at program counter "addr".
Reply See replies for REQUEST FRAME BY NUMBER .
REQUEST TRACE FRAME BY TRACEPOINT
Syntax QTFrame:tdp:<n> Find the next collected data associated with a trace event associated with tracepoint number n.
Reply See replies for REQUEST FRAME BY NUMBER .
REQUEST TRACE FRAME BY PC IN RANGE
Syntax QTFrame:range:<start>:<stop> Find the next collected data associated with a trace event associated with a program counter between "start" and "stop".
Reply See replies for REQUEST FRAME BY NUMBER .
REQUEST TRACE FRAME BY PC OUTSIDE RANGE
Syntax QTFrame:outside:<start>:<stop> Find the next collected data associated with a trace event associated with a program counter that isn't between "start" and "stop".
Reply See replies for REQUEST FRAME BY NUMBER .