blob: 41c2d69c0ffb7f722700c50d37f422c847209862 [file] [log] [blame]
This is gdb.info, produced by makeinfo version 4.8 from ./gdb.texinfo.
INFO-DIR-SECTION Software development
START-INFO-DIR-ENTRY
* Gdb: (gdb). The GNU debugger.
END-INFO-DIR-ENTRY
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
2010 2011, 2012 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Free Software" and "Free Software Needs Free
Documentation", with the Front-Cover Texts being "A GNU Manual," and
with the Back-Cover Texts as in (a) below.
(a) The FSF's Back-Cover Text is: "You are free to copy and modify
this GNU Manual. Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom."
This file documents the GNU debugger GDB.
This is the Tenth Edition, of `Debugging with GDB: the GNU
Source-Level Debugger' for GDB (GDB) Version 7.5.
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
2010 2011, 2012 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Free Software" and "Free Software Needs Free
Documentation", with the Front-Cover Texts being "A GNU Manual," and
with the Back-Cover Texts as in (a) below.
(a) The FSF's Back-Cover Text is: "You are free to copy and modify
this GNU Manual. Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom."

File: gdb.info, Node: Running Configure, Next: Separate Objdir, Prev: Requirements, Up: Installing GDB
C.2 Invoking the GDB `configure' Script
=======================================
GDB comes with a `configure' script that automates the process of
preparing GDB for installation; you can then use `make' to build the
`gdb' program.
The GDB distribution includes all the source code you need for GDB
in a single directory, whose name is usually composed by appending the
version number to `gdb'.
For example, the GDB version 7.5 distribution is in the `gdb-7.5'
directory. That directory contains:
`gdb-7.5/configure (and supporting files)'
script for configuring GDB and all its supporting libraries
`gdb-7.5/gdb'
the source specific to GDB itself
`gdb-7.5/bfd'
source for the Binary File Descriptor library
`gdb-7.5/include'
GNU include files
`gdb-7.5/libiberty'
source for the `-liberty' free software library
`gdb-7.5/opcodes'
source for the library of opcode tables and disassemblers
`gdb-7.5/readline'
source for the GNU command-line interface
`gdb-7.5/glob'
source for the GNU filename pattern-matching subroutine
`gdb-7.5/mmalloc'
source for the GNU memory-mapped malloc package
The simplest way to configure and build GDB is to run `configure'
from the `gdb-VERSION-NUMBER' source directory, which in this example
is the `gdb-7.5' directory.
First switch to the `gdb-VERSION-NUMBER' source directory if you are
not already in it; then run `configure'. Pass the identifier for the
platform on which GDB will run as an argument.
For example:
cd gdb-7.5
./configure HOST
make
where HOST is an identifier such as `sun4' or `decstation', that
identifies the platform where GDB will run. (You can often leave off
HOST; `configure' tries to guess the correct value by examining your
system.)
Running `configure HOST' and then running `make' builds the `bfd',
`readline', `mmalloc', and `libiberty' libraries, then `gdb' itself.
The configured source files, and the binaries, are left in the
corresponding source directories.
`configure' is a Bourne-shell (`/bin/sh') script; if your system
does not recognize this automatically when you run a different shell,
you may need to run `sh' on it explicitly:
sh configure HOST
If you run `configure' from a directory that contains source
directories for multiple libraries or programs, such as the `gdb-7.5'
source directory for version 7.5, `configure' creates configuration
files for every directory level underneath (unless you tell it not to,
with the `--norecursion' option).
You should run the `configure' script from the top directory in the
source tree, the `gdb-VERSION-NUMBER' directory. If you run
`configure' from one of the subdirectories, you will configure only
that subdirectory. That is usually not what you want. In particular,
if you run the first `configure' from the `gdb' subdirectory of the
`gdb-VERSION-NUMBER' directory, you will omit the configuration of
`bfd', `readline', and other sibling directories of the `gdb'
subdirectory. This leads to build errors about missing include files
such as `bfd/bfd.h'.
You can install `gdb' anywhere; it has no hardwired paths. However,
you should make sure that the shell on your path (named by the `SHELL'
environment variable) is publicly readable. Remember that GDB uses the
shell to start your program--some systems refuse to let GDB debug child
processes whose programs are not readable.

File: gdb.info, Node: Separate Objdir, Next: Config Names, Prev: Running Configure, Up: Installing GDB
C.3 Compiling GDB in Another Directory
======================================
If you want to run GDB versions for several host or target machines,
you need a different `gdb' compiled for each combination of host and
target. `configure' is designed to make this easy by allowing you to
generate each configuration in a separate subdirectory, rather than in
the source directory. If your `make' program handles the `VPATH'
feature (GNU `make' does), running `make' in each of these directories
builds the `gdb' program specified there.
To build `gdb' in a separate directory, run `configure' with the
`--srcdir' option to specify where to find the source. (You also need
to specify a path to find `configure' itself from your working
directory. If the path to `configure' would be the same as the
argument to `--srcdir', you can leave out the `--srcdir' option; it is
assumed.)
For example, with version 7.5, you can build GDB in a separate
directory for a Sun 4 like this:
cd gdb-7.5
mkdir ../gdb-sun4
cd ../gdb-sun4
../gdb-7.5/configure sun4
make
When `configure' builds a configuration using a remote source
directory, it creates a tree for the binaries with the same structure
(and using the same names) as the tree under the source directory. In
the example, you'd find the Sun 4 library `libiberty.a' in the
directory `gdb-sun4/libiberty', and GDB itself in `gdb-sun4/gdb'.
Make sure that your path to the `configure' script has just one
instance of `gdb' in it. If your path to `configure' looks like
`../gdb-7.5/gdb/configure', you are configuring only one subdirectory
of GDB, not the whole package. This leads to build errors about
missing include files such as `bfd/bfd.h'.
One popular reason to build several GDB configurations in separate
directories is to configure GDB for cross-compiling (where GDB runs on
one machine--the "host"--while debugging programs that run on another
machine--the "target"). You specify a cross-debugging target by giving
the `--target=TARGET' option to `configure'.
When you run `make' to build a program or library, you must run it
in a configured directory--whatever directory you were in when you
called `configure' (or one of its subdirectories).
The `Makefile' that `configure' generates in each source directory
also runs recursively. If you type `make' in a source directory such
as `gdb-7.5' (or in a separate configured directory configured with
`--srcdir=DIRNAME/gdb-7.5'), you will build all the required libraries,
and then build GDB.
When you have multiple hosts or targets configured in separate
directories, you can run `make' on them in parallel (for example, if
they are NFS-mounted on each of the hosts); they will not interfere
with each other.

File: gdb.info, Node: Config Names, Next: Configure Options, Prev: Separate Objdir, Up: Installing GDB
C.4 Specifying Names for Hosts and Targets
==========================================
The specifications used for hosts and targets in the `configure' script
are based on a three-part naming scheme, but some short predefined
aliases are also supported. The full naming scheme encodes three pieces
of information in the following pattern:
ARCHITECTURE-VENDOR-OS
For example, you can use the alias `sun4' as a HOST argument, or as
the value for TARGET in a `--target=TARGET' option. The equivalent
full name is `sparc-sun-sunos4'.
The `configure' script accompanying GDB does not provide any query
facility to list all supported host and target names or aliases.
`configure' calls the Bourne shell script `config.sub' to map
abbreviations to full names; you can read the script, if you wish, or
you can use it to test your guesses on abbreviations--for example:
% sh config.sub i386-linux
i386-pc-linux-gnu
% sh config.sub alpha-linux
alpha-unknown-linux-gnu
% sh config.sub hp9k700
hppa1.1-hp-hpux
% sh config.sub sun4
sparc-sun-sunos4.1.1
% sh config.sub sun3
m68k-sun-sunos4.1.1
% sh config.sub i986v
Invalid configuration `i986v': machine `i986v' not recognized
`config.sub' is also distributed in the GDB source directory
(`gdb-7.5', for version 7.5).

File: gdb.info, Node: Configure Options, Next: System-wide configuration, Prev: Config Names, Up: Installing GDB
C.5 `configure' Options
=======================
Here is a summary of the `configure' options and arguments that are
most often useful for building GDB. `configure' also has several other
options not listed here. *note (configure.info)What Configure Does::,
for a full explanation of `configure'.
configure [--help]
[--prefix=DIR]
[--exec-prefix=DIR]
[--srcdir=DIRNAME]
[--norecursion] [--rm]
[--target=TARGET]
HOST
You may introduce options with a single `-' rather than `--' if you
prefer; but you may abbreviate option names if you use `--'.
`--help'
Display a quick summary of how to invoke `configure'.
`--prefix=DIR'
Configure the source to install programs and files under directory
`DIR'.
`--exec-prefix=DIR'
Configure the source to install programs under directory `DIR'.
`--srcdir=DIRNAME'
*Warning: using this option requires GNU `make', or another `make'
that implements the `VPATH' feature.*
Use this option to make configurations in directories separate
from the GDB source directories. Among other things, you can use
this to build (or maintain) several configurations simultaneously,
in separate directories. `configure' writes
configuration-specific files in the current directory, but
arranges for them to use the source in the directory DIRNAME.
`configure' creates directories under the working directory in
parallel to the source directories below DIRNAME.
`--norecursion'
Configure only the directory level where `configure' is executed;
do not propagate configuration to subdirectories.
`--target=TARGET'
Configure GDB for cross-debugging programs running on the specified
TARGET. Without this option, GDB is configured to debug programs
that run on the same machine (HOST) as GDB itself.
There is no convenient way to generate a list of all available
targets.
`HOST ...'
Configure GDB to run on the specified HOST.
There is no convenient way to generate a list of all available
hosts.
There are many other options available as well, but they are
generally needed for special purposes only.

File: gdb.info, Node: System-wide configuration, Prev: Configure Options, Up: Installing GDB
C.6 System-wide configuration and settings
==========================================
GDB can be configured to have a system-wide init file; this file will
be read and executed at startup (*note What GDB does during startup:
Startup.).
Here is the corresponding configure option:
`--with-system-gdbinit=FILE'
Specify that the default location of the system-wide init file is
FILE.
If GDB has been configured with the option `--prefix=$prefix', it
may be subject to relocation. Two possible cases:
* If the default location of this init file contains `$prefix', it
will be subject to relocation. Suppose that the configure options
are `--prefix=$prefix --with-system-gdbinit=$prefix/etc/gdbinit';
if GDB is moved from `$prefix' to `$install', the system init file
is looked for as `$install/etc/gdbinit' instead of
`$prefix/etc/gdbinit'.
* By contrast, if the default location does not contain the prefix,
it will not be relocated. E.g. if GDB has been configured with
`--prefix=/usr/local --with-system-gdbinit=/usr/share/gdb/gdbinit',
then GDB will always look for `/usr/share/gdb/gdbinit', wherever
GDB is installed.

File: gdb.info, Node: Maintenance Commands, Next: Remote Protocol, Prev: Installing GDB, Up: Top
Appendix D Maintenance Commands
*******************************
In addition to commands intended for GDB users, GDB includes a number
of commands intended for GDB developers, that are not documented
elsewhere in this manual. These commands are provided here for
reference. (For commands that turn on debugging messages, see *Note
Debugging Output::.)
`maint agent [-at LOCATION,] EXPRESSION'
`maint agent-eval [-at LOCATION,] EXPRESSION'
Translate the given EXPRESSION into remote agent bytecodes. This
command is useful for debugging the Agent Expression mechanism
(*note Agent Expressions::). The `agent' version produces an
expression useful for data collection, such as by tracepoints,
while `maint agent-eval' produces an expression that evaluates
directly to a result. For instance, a collection expression for
`globa + globb' will include bytecodes to record four bytes of
memory at each of the addresses of `globa' and `globb', while
discarding the result of the addition, while an evaluation
expression will do the addition and return the sum. If `-at' is
given, generate remote agent bytecode for LOCATION. If not,
generate remote agent bytecode for current frame PC address.
`maint agent-printf FORMAT,EXPR,...'
Translate the given format string and list of argument expressions
into remote agent bytecodes and display them as a disassembled
list. This command is useful for debugging the agent version of
dynamic printf (*note Dynamic Printf::.
`maint info breakpoints'
Using the same format as `info breakpoints', display both the
breakpoints you've set explicitly, and those GDB is using for
internal purposes. Internal breakpoints are shown with negative
breakpoint numbers. The type column identifies what kind of
breakpoint is shown:
`breakpoint'
Normal, explicitly set breakpoint.
`watchpoint'
Normal, explicitly set watchpoint.
`longjmp'
Internal breakpoint, used to handle correctly stepping through
`longjmp' calls.
`longjmp resume'
Internal breakpoint at the target of a `longjmp'.
`until'
Temporary internal breakpoint used by the GDB `until' command.
`finish'
Temporary internal breakpoint used by the GDB `finish'
command.
`shlib events'
Shared library events.
`set displaced-stepping'
`show displaced-stepping'
Control whether or not GDB will do "displaced stepping" if the
target supports it. Displaced stepping is a way to single-step
over breakpoints without removing them from the inferior, by
executing an out-of-line copy of the instruction that was
originally at the breakpoint location. It is also known as
out-of-line single-stepping.
`set displaced-stepping on'
If the target architecture supports it, GDB will use
displaced stepping to step over breakpoints.
`set displaced-stepping off'
GDB will not use displaced stepping to step over breakpoints,
even if such is supported by the target architecture.
`set displaced-stepping auto'
This is the default mode. GDB will use displaced stepping
only if non-stop mode is active (*note Non-Stop Mode::) and
the target architecture supports displaced stepping.
`maint check-symtabs'
Check the consistency of psymtabs and symtabs.
`maint cplus first_component NAME'
Print the first C++ class/namespace component of NAME.
`maint cplus namespace'
Print the list of possible C++ namespaces.
`maint demangle NAME'
Demangle a C++ or Objective-C mangled NAME.
`maint deprecate COMMAND [REPLACEMENT]'
`maint undeprecate COMMAND'
Deprecate or undeprecate the named COMMAND. Deprecated commands
cause GDB to issue a warning when you use them. The optional
argument REPLACEMENT says which newer command should be used in
favor of the deprecated one; if it is given, GDB will mention the
replacement as part of the warning.
`maint dump-me'
Cause a fatal signal in the debugger and force it to dump its core.
This is supported only on systems which support aborting a program
with the `SIGQUIT' signal.
`maint internal-error [MESSAGE-TEXT]'
`maint internal-warning [MESSAGE-TEXT]'
Cause GDB to call the internal function `internal_error' or
`internal_warning' and hence behave as though an internal error or
internal warning has been detected. In addition to reporting the
internal problem, these functions give the user the opportunity to
either quit GDB or create a core file of the current GDB session.
These commands take an optional parameter MESSAGE-TEXT that is
used as the text of the error or warning message.
Here's an example of using `internal-error':
(gdb) maint internal-error testing, 1, 2
.../maint.c:121: internal-error: testing, 1, 2
A problem internal to GDB has been detected. Further
debugging may prove unreliable.
Quit this debugging session? (y or n) n
Create a core file? (y or n) n
(gdb)
`maint set internal-error ACTION [ask|yes|no]'
`maint show internal-error ACTION'
`maint set internal-warning ACTION [ask|yes|no]'
`maint show internal-warning ACTION'
When GDB reports an internal problem (error or warning) it gives
the user the opportunity to both quit GDB and create a core file
of the current GDB session. These commands let you override the
default behaviour for each particular ACTION, described in the
table below.
`quit'
You can specify that GDB should always (yes) or never (no)
quit. The default is to ask the user what to do.
`corefile'
You can specify that GDB should always (yes) or never (no)
create a core file. The default is to ask the user what to
do.
`maint packet TEXT'
If GDB is talking to an inferior via the serial protocol, then
this command sends the string TEXT to the inferior, and displays
the response packet. GDB supplies the initial `$' character, the
terminating `#' character, and the checksum.
`maint print architecture [FILE]'
Print the entire architecture configuration. The optional argument
FILE names the file where the output goes.
`maint print c-tdesc'
Print the current target description (*note Target Descriptions::)
as a C source file. The created source file can be used in GDB
when an XML parser is not available to parse the description.
`maint print dummy-frames'
Prints the contents of GDB's internal dummy-frame stack.
(gdb) b add
...
(gdb) print add(2,3)
Breakpoint 2, add (a=2, b=3) at ...
58 return (a + b);
The program being debugged stopped while in a function called from GDB.
...
(gdb) maint print dummy-frames
0x1a57c80: pc=0x01014068 fp=0x0200bddc sp=0x0200bdd6
top=0x0200bdd4 id={stack=0x200bddc,code=0x101405c}
call_lo=0x01014000 call_hi=0x01014001
(gdb)
Takes an optional file parameter.
`maint print registers [FILE]'
`maint print raw-registers [FILE]'
`maint print cooked-registers [FILE]'
`maint print register-groups [FILE]'
`maint print remote-registers [FILE]'
Print GDB's internal register data structures.
The command `maint print raw-registers' includes the contents of
the raw register cache; the command `maint print cooked-registers'
includes the (cooked) value of all registers, including registers
which aren't available on the target nor visible to user; the
command `maint print register-groups' includes the groups that
each register is a member of; and the command `maint print
remote-registers' includes the remote target's register numbers
and offsets in the `G' packets. *Note Registers:
(gdbint)Registers.
These commands take an optional parameter, a file name to which to
write the information.
`maint print reggroups [FILE]'
Print GDB's internal register group data structures. The optional
argument FILE tells to what file to write the information.
The register groups info looks like this:
(gdb) maint print reggroups
Group Type
general user
float user
all user
vector user
system user
save internal
restore internal
`flushregs'
This command forces GDB to flush its internal register cache.
`maint print objfiles'
Print a dump of all known object files. For each object file, this
command prints its name, address in memory, and all of its psymtabs
and symtabs.
`maint print section-scripts [REGEXP]'
Print a dump of scripts specified in the `.debug_gdb_section'
section. If REGEXP is specified, only print scripts loaded by
object files matching REGEXP. For each script, this command
prints its name as specified in the objfile, and the full path if
known. *Note dotdebug_gdb_scripts section::.
`maint print statistics'
This command prints, for each object file in the program, various
data about that object file followed by the byte cache ("bcache")
statistics for the object file. The objfile data includes the
number of minimal, partial, full, and stabs symbols, the number of
types defined by the objfile, the number of as yet unexpanded psym
tables, the number of line tables and string tables, and the
amount of memory used by the various tables. The bcache
statistics include the counts, sizes, and counts of duplicates of
all and unique objects, max, average, and median entry size, total
memory used and its overhead and savings, and various measures of
the hash table size and chain lengths.
`maint print target-stack'
A "target" is an interface between the debugger and a particular
kind of file or process. Targets can be stacked in "strata", so
that more than one target can potentially respond to a request.
In particular, memory accesses will walk down the stack of targets
until they find a target that is interested in handling that
particular address.
This command prints a short description of each layer that was
pushed on the "target stack", starting from the top layer down to
the bottom one.
`maint print type EXPR'
Print the type chain for a type specified by EXPR. The argument
can be either a type name or a symbol. If it is a symbol, the
type of that symbol is described. The type chain produced by this
command is a recursive definition of the data type as stored in
GDB's data structures, including its flags and contained types.
`maint set dwarf2 always-disassemble'
`maint show dwarf2 always-disassemble'
Control the behavior of `info address' when using DWARF debugging
information.
The default is `off', which means that GDB should try to describe
a variable's location in an easily readable format. When `on',
GDB will instead display the DWARF location expression in an
assembly-like format. Note that some locations are too complex
for GDB to describe simply; in this case you will always see the
disassembly form.
Here is an example of the resulting disassembly:
(gdb) info addr argc
Symbol "argc" is a complex DWARF expression:
1: DW_OP_fbreg 0
For more information on these expressions, see the DWARF standard
(http://www.dwarfstd.org/).
`maint set dwarf2 max-cache-age'
`maint show dwarf2 max-cache-age'
Control the DWARF 2 compilation unit cache.
In object files with inter-compilation-unit references, such as
those produced by the GCC option `-feliminate-dwarf2-dups', the
DWARF 2 reader needs to frequently refer to previously read
compilation units. This setting controls how long a compilation
unit will remain in the cache if it is not referenced. A higher
limit means that cached compilation units will be stored in memory
longer, and more total memory will be used. Setting it to zero
disables caching, which will slow down GDB startup, but reduce
memory consumption.
`maint set profile'
`maint show profile'
Control profiling of GDB.
Profiling will be disabled until you use the `maint set profile'
command to enable it. When you enable profiling, the system will
begin collecting timing and execution count data; when you disable
profiling or exit GDB, the results will be written to a log file.
Remember that if you use profiling, GDB will overwrite the
profiling log file (often called `gmon.out'). If you have a
record of important profiling data in a `gmon.out' file, be sure
to move it to a safe location.
Configuring with `--enable-profiling' arranges for GDB to be
compiled with the `-pg' compiler option.
`maint set show-debug-regs'
`maint show show-debug-regs'
Control whether to show variables that mirror the hardware debug
registers. Use `ON' to enable, `OFF' to disable. If enabled, the
debug registers values are shown when GDB inserts or removes a
hardware breakpoint or watchpoint, and when the inferior triggers
a hardware-assisted breakpoint or watchpoint.
`maint set show-all-tib'
`maint show show-all-tib'
Control whether to show all non zero areas within a 1k block
starting at thread local base, when using the `info w32
thread-information-block' command.
`maint space'
Control whether to display memory usage for each command. If set
to a nonzero value, GDB will display how much memory each command
took, following the command's own output. This can also be
requested by invoking GDB with the `--statistics' command-line
switch (*note Mode Options::).
`maint time'
Control whether to display the execution time of GDB for each
command. If set to a nonzero value, GDB will display how much
time it took to execute each command, following the command's own
output. Both CPU time and wallclock time are printed. Printing
both is useful when trying to determine whether the cost is CPU
or, e.g., disk/network, latency. Note that the CPU time printed
is for GDB only, it does not include the execution time of the
inferior because there's no mechanism currently to compute how
much time was spent by GDB and how much time was spent by the
program been debugged. This can also be requested by invoking GDB
with the `--statistics' command-line switch (*note Mode Options::).
`maint translate-address [SECTION] ADDR'
Find the symbol stored at the location specified by the address
ADDR and an optional section name SECTION. If found, GDB prints
the name of the closest symbol and an offset from the symbol's
location to the specified address. This is similar to the `info
address' command (*note Symbols::), except that this command also
allows to find symbols in other sections.
If section was not specified, the section in which the symbol was
found is also printed. For dynamically linked executables, the
name of executable or shared library containing the symbol is
printed as well.
The following command is useful for non-interactive invocations of
GDB, such as in the test suite.
`set watchdog NSEC'
Set the maximum number of seconds GDB will wait for the target
operation to finish. If this time expires, GDB reports and error
and the command is aborted.
`show watchdog'
Show the current setting of the target wait timeout.

File: gdb.info, Node: Remote Protocol, Next: Agent Expressions, Prev: Maintenance Commands, Up: Top
Appendix E GDB Remote Serial Protocol
*************************************
* Menu:
* Overview::
* Packets::
* Stop Reply Packets::
* General Query Packets::
* Architecture-Specific Protocol Details::
* Tracepoint Packets::
* Host I/O Packets::
* Interrupts::
* Notification Packets::
* Remote Non-Stop::
* Packet Acknowledgment::
* Examples::
* File-I/O Remote Protocol Extension::
* Library List Format::
* Library List Format for SVR4 Targets::
* Memory Map Format::
* Thread List Format::
* Traceframe Info Format::

File: gdb.info, Node: Overview, Next: Packets, Up: Remote Protocol
E.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, respectively.
All GDB commands and responses (other than acknowledgments and
notifications, see *Note Notification Packets::) 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-IDs. 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 acknowledgment: either `+' (to indicate
the package was received correctly) or `-' (to request retransmission):
-> `$'PACKET-DATA`#'CHECKSUM
<- `+'
The `+'/`-' acknowledgments can be disabled once a connection is
established. *Note Packet Acknowledgment::, for details.
The host (GDB) 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, and the target has again stopped all threads in all attached
processes. This is the default all-stop mode behavior, but the remote
protocol also supports GDB's non-stop execution mode; see *Note Remote
Non-Stop::, for details.
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).
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. Run-length
encoding replaces runs of identical characters with one instance of the
repeated character, followed by a `*' and a repeat count. The repeat
count is itself sent encoded, to avoid binary characters in DATA: a
value of N is sent as `N+29'. For a repeat count greater or equal to
3, this produces a printable ASCII character, e.g. a space (ASCII code
32) for a repeat count of 3. (This is because run-length encoding
starts to win for counts 3 or more.) Thus, for example, `0* ' is a
run-length encoding of "0000": the space character after `*' means
repeat the leading `0' `32 - 29 = 3' more times.
The printable characters `#' and `$' or with a numeric value greater
than 126 must not be used. Runs of six repeats (`#') or seven repeats
(`$') can be expanded using a repeat count of only five (`"'). For
example, `00000000' can be encoded as `0*"00'.
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 GDB can tell if a packet is supported based on that
response.
At a minimum, a stub is required to support the `g' and `G' commands
for register access, and the `m' and `M' commands for memory access.
Stubs that only control single-threaded targets can implement run
control with the `c' (continue), and `s' (step) commands. Stubs that
support multi-threading targets should support the `vCont' command.
All other commands are optional.

File: gdb.info, Node: Packets, Next: Stop Reply Packets, Prev: Overview, Up: Remote Protocol
E.2 Packets
===========
The following table provides a complete list of all currently defined
COMMANDs and their corresponding response DATA. *Note File-I/O Remote
Protocol Extension::, for details about the File I/O extension of the
remote protocol.
Each packet's description has a template showing the packet's overall
syntax, followed by an explanation of the packet's meaning. We include
spaces in some of the templates for clarity; these are not part of the
packet's syntax. No GDB packet uses spaces to separate its components.
For example, a template like `foo BAR BAZ' describes a packet
beginning with the three ASCII bytes `foo', followed by a BAR, followed
directly by a BAZ. GDB does not transmit a space character between the
`foo' and the BAR, or between the BAR and the BAZ.
Several packets and replies include a THREAD-ID field to identify a
thread. Normally these are positive numbers with a target-specific
interpretation, formatted as big-endian hex strings. A THREAD-ID can
also be a literal `-1' to indicate all threads, or `0' to pick any
thread.
In addition, the remote protocol supports a multiprocess feature in
which the THREAD-ID syntax is extended to optionally include both
process and thread ID fields, as `pPID.TID'. The PID (process) and TID
(thread) components each have the format described above: a positive
number with target-specific interpretation formatted as a big-endian
hex string, literal `-1' to indicate all processes or threads
(respectively), or `0' to indicate an arbitrary process or thread.
Specifying just a process, as `pPID', is equivalent to `pPID.-1'. It
is an error to specify all processes but a specific thread, such as
`p-1.TID'. Note that the `p' prefix is _not_ used for those packets
and replies explicitly documented to include a process ID, rather than
a THREAD-ID.
The multiprocess THREAD-ID syntax extensions are only used if both
GDB and the stub report support for the `multiprocess' feature using
`qSupported'. *Note multiprocess extensions::, for more information.
Note that all packet forms beginning with an upper- or lower-case
letter, other than those described here, are reserved for future use.
Here are the packet descriptions.
`!'
Enable extended mode. In extended mode, the remote server is made
persistent. The `R' packet is used to restart the program being
debugged.
Reply:
`OK'
The remote target both supports and has enabled extended mode.
`?'
Indicate the reason the target halted. The reply is the same as
for step and continue. This packet has a special interpretation
when the target is in non-stop mode; see *Note Remote Non-Stop::.
Reply: *Note Stop Reply Packets::, for the reply specifications.
`A ARGLEN,ARGNUM,ARG,...'
Initialized `argv[]' array passed into program. ARGLEN specifies
the number of bytes in the hex encoded byte stream ARG. See
`gdbserver' for more details.
Reply:
`OK'
The arguments were set.
`E NN'
An error occurred.
`b BAUD'
(Don't use this packet; its behavior is not well-defined.) Change
the serial line speed to BAUD.
JTC: _When does the transport layer state change? When it's
received, or after the ACK is transmitted. In either case, there
are problems if the command or the acknowledgment packet is
dropped._
Stan: _If people really wanted to add something like this, and get
it working for the first time, they ought to modify ser-unix.c to
send some kind of out-of-band message to a specially-setup stub
and have the switch happen "in between" packets, so that from
remote protocol's point of view, nothing actually happened._
`B ADDR,MODE'
Set (MODE is `S') or clear (MODE is `C') a breakpoint at ADDR.
Don't use this packet. Use the `Z' and `z' packets instead (*note
insert breakpoint or watchpoint packet::).
`bc'
Backward continue. Execute the target system in reverse. No
parameter. *Note Reverse Execution::, for more information.
Reply: *Note Stop Reply Packets::, for the reply specifications.
`bs'
Backward single step. Execute one instruction in reverse. No
parameter. *Note Reverse Execution::, for more information.
Reply: *Note Stop Reply Packets::, for the reply specifications.
`c [ADDR]'
Continue. ADDR is address to resume. If ADDR is omitted, resume
at current address.
This packet is deprecated for multi-threading support. *Note
vCont packet::.
Reply: *Note Stop Reply Packets::, for the reply specifications.
`C SIG[;ADDR]'
Continue with signal SIG (hex signal number). If `;ADDR' is
omitted, resume at same address.
This packet is deprecated for multi-threading support. *Note
vCont packet::.
Reply: *Note Stop Reply Packets::, for the reply specifications.
`d'
Toggle debug flag.
Don't use this packet; instead, define a general set packet (*note
General Query Packets::).
`D'
`D;PID'
The first form of the packet is used to detach GDB from the remote
system. It is sent to the remote target before GDB disconnects
via the `detach' command.
The second form, including a process ID, is used when multiprocess
protocol extensions are enabled (*note multiprocess extensions::),
to detach only a specific process. The PID is specified as a
big-endian hex string.
Reply:
`OK'
for success
`E NN'
for an error
`F RC,EE,CF;XX'
A reply from GDB to an `F' packet sent by the target. This is
part of the File-I/O protocol extension. *Note File-I/O Remote
Protocol Extension::, for the specification.
`g'
Read general registers.
Reply:
`XX...'
Each byte of register data is described by two hex digits.
The bytes with the register are transmitted in target byte
order. The size of each register and their position within
the `g' packet are determined by the GDB internal gdbarch
functions `DEPRECATED_REGISTER_RAW_SIZE' and
`gdbarch_register_name'. The specification of several
standard `g' packets is specified below.
When reading registers from a trace frame (*note Using the
Collected Data: Analyze Collected Data.), the stub may also
return a string of literal `x''s in place of the register
data digits, to indicate that the corresponding register has
not been collected, thus its value is unavailable. For
example, for an architecture with 4 registers of 4 bytes
each, the following reply indicates to GDB that registers 0
and 2 have not been collected, while registers 1 and 3 have
been collected, and both have zero value:
-> `g'
<- `xxxxxxxx00000000xxxxxxxx00000000'
`E NN'
for an error.
`G XX...'
Write general registers. *Note read registers packet::, for a
description of the XX... data.
Reply:
`OK'
for success
`E NN'
for an error
`H OP THREAD-ID'
Set thread for subsequent operations (`m', `M', `g', `G', et.al.).
OP depends on the operation to be performed: it should be `c' for
step and continue operations (note that this is deprecated,
supporting the `vCont' command is a better option), `g' for other
operations. The thread designator THREAD-ID has the format and
interpretation described in *Note thread-id syntax::.
Reply:
`OK'
for success
`E NN'
for an error
`i [ADDR[,NNN]]'
Step the remote target by a single clock cycle. If `,NNN' is
present, cycle step NNN cycles. If ADDR is present, cycle step
starting at that address.
`I'
Signal, then cycle step. *Note step with signal packet::. *Note
cycle step packet::.
`k'
Kill request.
FIXME: _There is no description of how to operate when a specific
thread context has been selected (i.e. does 'k' kill only that
thread?)_.
`m ADDR,LENGTH'
Read LENGTH bytes of memory starting at address ADDR. Note that
ADDR may not be aligned to any particular boundary.
The stub need not use any particular size or alignment when
gathering data from memory for the response; even if ADDR is
word-aligned and LENGTH is a multiple of the word size, the stub
is free to use byte accesses, or not. For this reason, this
packet may not be suitable for accessing memory-mapped I/O devices.
Reply:
`XX...'
Memory contents; each byte is transmitted as a two-digit
hexadecimal number. The reply may contain fewer bytes than
requested if the server was able to read only part of the
region of memory.
`E NN'
NN is errno
`M ADDR,LENGTH:XX...'
Write LENGTH bytes of memory starting at address ADDR. XX... is
the data; each byte is transmitted as a two-digit hexadecimal
number.
Reply:
`OK'
for success
`E NN'
for an error (this includes the case where only part of the
data was written).
`p N'
Read the value of register N; N is in hex. *Note read registers
packet::, for a description of how the returned register value is
encoded.
Reply:
`XX...'
the register's value
`E NN'
for an error
`'
Indicating an unrecognized QUERY.
`P N...=R...'
Write register N... with value R.... The register number N is in
hexadecimal, and R... contains two hex digits for each byte in the
register (target byte order).
Reply:
`OK'
for success
`E NN'
for an error
`q NAME PARAMS...'
`Q NAME PARAMS...'
General query (`q') and set (`Q'). These packets are described
fully in *Note General Query Packets::.
`r'
Reset the entire system.
Don't use this packet; use the `R' packet instead.
`R XX'
Restart the program being debugged. XX, while needed, is ignored.
This packet is only available in extended mode (*note extended
mode::).
The `R' packet has no reply.
`s [ADDR]'
Single step. ADDR is the address at which to resume. If ADDR is
omitted, resume at same address.
This packet is deprecated for multi-threading support. *Note
vCont packet::.
Reply: *Note Stop Reply Packets::, for the reply specifications.
`S SIG[;ADDR]'
Step with signal. This is analogous to the `C' packet, but
requests a single-step, rather than a normal resumption of
execution.
This packet is deprecated for multi-threading support. *Note
vCont packet::.
Reply: *Note Stop Reply Packets::, for the reply specifications.
`t ADDR:PP,MM'
Search backwards starting at address ADDR for a match with pattern
PP and mask MM. PP and MM are 4 bytes. ADDR must be at least 3
digits.
`T THREAD-ID'
Find out if the thread THREAD-ID is alive. *Note thread-id
syntax::.
Reply:
`OK'
thread is still alive
`E NN'
thread is dead
`v'
Packets starting with `v' are identified by a multi-letter name,
up to the first `;' or `?' (or the end of the packet).
`vAttach;PID'
Attach to a new process with the specified process ID PID. The
process ID is a hexadecimal integer identifying the process. In
all-stop mode, all threads in the attached process are stopped; in
non-stop mode, it may be attached without being stopped if that is
supported by the target.
This packet is only available in extended mode (*note extended
mode::).
Reply:
`E NN'
for an error
`Any stop packet'
for success in all-stop mode (*note Stop Reply Packets::)
`OK'
for success in non-stop mode (*note Remote Non-Stop::)
`vCont[;ACTION[:THREAD-ID]]...'
Resume the inferior, specifying different actions for each thread.
If an action is specified with no THREAD-ID, then it is applied to
any threads that don't have a specific action specified; if no
default action is specified then other threads should remain
stopped in all-stop mode and in their current state in non-stop
mode. Specifying multiple default actions is an error; specifying
no actions is also an error. Thread IDs are specified using the
syntax described in *Note thread-id syntax::.
Currently supported actions are:
`c'
Continue.
`C SIG'
Continue with signal SIG. The signal SIG should be two hex
digits.
`s'
Step.
`S SIG'
Step with signal SIG. The signal SIG should be two hex
digits.
`t'
Stop.
The optional argument ADDR normally associated with the `c', `C',
`s', and `S' packets is not supported in `vCont'.
The `t' action is only relevant in non-stop mode (*note Remote
Non-Stop::) and may be ignored by the stub otherwise. A stop
reply should be generated for any affected thread not already
stopped. When a thread is stopped by means of a `t' action, the
corresponding stop reply should indicate that the thread has
stopped with signal `0', regardless of whether the target uses
some other signal as an implementation detail.
The stub must support `vCont' if it reports support for
multiprocess extensions (*note multiprocess extensions::). Note
that in this case `vCont' actions can be specified to apply to all
threads in a process by using the `pPID.-1' form of the THREAD-ID.
Reply: *Note Stop Reply Packets::, for the reply specifications.
`vCont?'
Request a list of actions supported by the `vCont' packet.
Reply:
`vCont[;ACTION...]'
The `vCont' packet is supported. Each ACTION is a supported
command in the `vCont' packet.
`'
The `vCont' packet is not supported.
`vFile:OPERATION:PARAMETER...'
Perform a file operation on the target system. For details, see
*Note Host I/O Packets::.
`vFlashErase:ADDR,LENGTH'
Direct the stub to erase LENGTH bytes of flash starting at ADDR.
The region may enclose any number of flash blocks, but its start
and end must fall on block boundaries, as indicated by the flash
block size appearing in the memory map (*note Memory Map
Format::). GDB groups flash memory programming operations
together, and sends a `vFlashDone' request after each group; the
stub is allowed to delay erase operation until the `vFlashDone'
packet is received.
Reply:
`OK'
for success
`E NN'
for an error
`vFlashWrite:ADDR:XX...'
Direct the stub to write data to flash address ADDR. The data is
passed in binary form using the same encoding as for the `X'
packet (*note Binary Data::). The memory ranges specified by
`vFlashWrite' packets preceding a `vFlashDone' packet must not
overlap, and must appear in order of increasing addresses
(although `vFlashErase' packets for higher addresses may already
have been received; the ordering is guaranteed only between
`vFlashWrite' packets). If a packet writes to an address that was
neither erased by a preceding `vFlashErase' packet nor by some
other target-specific method, the results are unpredictable.
Reply:
`OK'
for success
`E.memtype'
for vFlashWrite addressing non-flash memory
`E NN'
for an error
`vFlashDone'
Indicate to the stub that flash programming operation is finished.
The stub is permitted to delay or batch the effects of a group of
`vFlashErase' and `vFlashWrite' packets until a `vFlashDone'
packet is received. The contents of the affected regions of flash
memory are unpredictable until the `vFlashDone' request is
completed.
`vKill;PID'
Kill the process with the specified process ID. PID is a
hexadecimal integer identifying the process. This packet is used
in preference to `k' when multiprocess protocol extensions are
supported; see *Note multiprocess extensions::.
Reply:
`E NN'
for an error
`OK'
for success
`vRun;FILENAME[;ARGUMENT]...'
Run the program FILENAME, passing it each ARGUMENT on its command
line. The file and arguments are hex-encoded strings. If
FILENAME is an empty string, the stub may use a default program
(e.g. the last program run). The program is created in the stopped
state.
This packet is only available in extended mode (*note extended
mode::).
Reply:
`E NN'
for an error
`Any stop packet'
for success (*note Stop Reply Packets::)
`vStopped'
In non-stop mode (*note Remote Non-Stop::), acknowledge a previous
stop reply and prompt for the stub to report another one.
Reply:
`Any stop packet'
if there is another unreported stop event (*note Stop Reply
Packets::)
`OK'
if there are no unreported stop events
`X ADDR,LENGTH:XX...'
Write data to memory, where the data is transmitted in binary.
ADDR is address, LENGTH is number of bytes, `XX...' is binary data
(*note Binary Data::).
Reply:
`OK'
for success
`E NN'
for an error
`z TYPE,ADDR,KIND'
`Z TYPE,ADDR,KIND'
Insert (`Z') or remove (`z') a TYPE breakpoint or watchpoint
starting at address ADDRESS of kind KIND.
Each breakpoint and watchpoint packet TYPE is documented
separately.
_Implementation notes: A remote target shall return an empty string
for an unrecognized breakpoint or watchpoint packet TYPE. A
remote target shall support either both or neither of a given
`ZTYPE...' and `zTYPE...' packet pair. To avoid potential
problems with duplicate packets, the operations should be
implemented in an idempotent way._
`z0,ADDR,KIND'
`Z0,ADDR,KIND[;COND_LIST...][;cmds:PERSIST,CMD_LIST...]'
Insert (`Z0') or remove (`z0') a memory breakpoint at address ADDR
of type KIND.
A memory breakpoint is implemented by replacing the instruction at
ADDR with a software breakpoint or trap instruction. The KIND is
target-specific and typically indicates the size of the breakpoint
in bytes that should be inserted. E.g., the ARM and MIPS can
insert either a 2 or 4 byte breakpoint. Some architectures have
additional meanings for KIND; COND_LIST is an optional list of
conditional expressions in bytecode form that should be evaluated
on the target's side. These are the conditions that should be
taken into consideration when deciding if the breakpoint trigger
should be reported back to GDBN.
The COND_LIST parameter is comprised of a series of expressions,
concatenated without separators. Each expression has the following
form:
`X LEN,EXPR'
LEN is the length of the bytecode expression and EXPR is the
actual conditional expression in bytecode form.
The optional CMD_LIST parameter introduces commands that may be
run on the target, rather than being reported back to GDB. The
parameter starts with a numeric flag PERSIST; if the flag is
nonzero, then the breakpoint may remain active and the commands
continue to be run even when GDB disconnects from the target.
Following this flag is a series of expressions concatenated with no
separators. Each expression has the following form:
`X LEN,EXPR'
LEN is the length of the bytecode expression and EXPR is the
actual conditional expression in bytecode form.
see *Note Architecture-Specific Protocol Details::.
_Implementation note: It is possible for a target to copy or move
code that contains memory breakpoints (e.g., when implementing
overlays). The behavior of this packet, in the presence of such a
target, is not defined._
Reply:
`OK'
success
`'
not supported
`E NN'
for an error
`z1,ADDR,KIND'
`Z1,ADDR,KIND[;COND_LIST...]'
Insert (`Z1') or remove (`z1') a hardware breakpoint at address
ADDR.
A hardware breakpoint is implemented using a mechanism that is not
dependant on being able to modify the target's memory. KIND and
COND_LIST have the same meaning as in `Z0' packets.
_Implementation note: A hardware breakpoint is not affected by code
movement._
Reply:
`OK'
success
`'
not supported
`E NN'
for an error
`z2,ADDR,KIND'
`Z2,ADDR,KIND'
Insert (`Z2') or remove (`z2') a write watchpoint at ADDR. KIND
is interpreted as the number of bytes to watch.
Reply:
`OK'
success
`'
not supported
`E NN'
for an error
`z3,ADDR,KIND'
`Z3,ADDR,KIND'
Insert (`Z3') or remove (`z3') a read watchpoint at ADDR. KIND is
interpreted as the number of bytes to watch.
Reply:
`OK'
success
`'
not supported
`E NN'
for an error
`z4,ADDR,KIND'
`Z4,ADDR,KIND'
Insert (`Z4') or remove (`z4') an access watchpoint at ADDR. KIND
is interpreted as the number of bytes to watch.
Reply:
`OK'
success
`'
not supported
`E NN'
for an error

File: gdb.info, Node: Stop Reply Packets, Next: General Query Packets, Prev: Packets, Up: Remote Protocol
E.3 Stop Reply Packets
======================
The `C', `c', `S', `s', `vCont', `vAttach', `vRun', `vStopped', and `?'
packets can receive any of the below as a reply. Except for `?' and
`vStopped', that reply is only returned when the target halts. In the
below the exact meaning of "signal number" is defined by the header
`include/gdb/signals.h' in the GDB source code.
As in the description of request packets, we include spaces in the
reply templates for clarity; these are not part of the reply packet's
syntax. No GDB stop reply packet uses spaces to separate its
components.
`S AA'
The program received signal number AA (a two-digit hexadecimal
number). This is equivalent to a `T' response with no N:R pairs.
`T AA N1:R1;N2:R2;...'
The program received signal number AA (a two-digit hexadecimal
number). This is equivalent to an `S' response, except that the
`N:R' pairs can carry values of important registers and other
information directly in the stop reply packet, reducing round-trip
latency. Single-step and breakpoint traps are reported this way.
Each `N:R' pair is interpreted as follows:
* If N is a hexadecimal number, it is a register number, and the
corresponding R gives that register's value. R is a series
of bytes in target byte order, with each byte given by a
two-digit hex number.
* If N is `thread', then R is the THREAD-ID of the stopped
thread, as specified in *Note thread-id syntax::.
* If N is `core', then R is the hexadecimal number of the core
on which the stop event was detected.
* If N is a recognized "stop reason", it describes a more
specific event that stopped the target. The currently
defined stop reasons are listed below. AA should be `05',
the trap signal. At most one stop reason should be present.
* Otherwise, GDB should ignore this `N:R' pair and go on to the
next; this allows us to extend the protocol in the future.
The currently defined stop reasons are:
`watch'
`rwatch'
`awatch'
The packet indicates a watchpoint hit, and R is the data
address, in hex.
`library'
The packet indicates that the loaded libraries have changed.
GDB should use `qXfer:libraries:read' to fetch a new list of
loaded libraries. R is ignored.
`replaylog'
The packet indicates that the target cannot continue replaying
logged execution events, because it has reached the end (or
the beginning when executing backward) of the log. The value
of R will be either `begin' or `end'. *Note Reverse
Execution::, for more information.
`W AA'
`W AA ; process:PID'
The process exited, and AA is the exit status. This is only
applicable to certain targets.
The second form of the response, including the process ID of the
exited process, can be used only when GDB has reported support for
multiprocess protocol extensions; see *Note multiprocess
extensions::. The PID is formatted as a big-endian hex string.
`X AA'
`X AA ; process:PID'
The process terminated with signal AA.
The second form of the response, including the process ID of the
terminated process, can be used only when GDB has reported support
for multiprocess protocol extensions; see *Note multiprocess
extensions::. The PID is formatted as a big-endian hex string.
`O XX...'
`XX...' is hex encoding of ASCII data, to be written as the
program's console output. This can happen at any time while the
program is running and the debugger should continue to wait for
`W', `T', etc. This reply is not permitted in non-stop mode.
`F CALL-ID,PARAMETER...'
CALL-ID is the identifier which says which host system call should
be called. This is just the name of the function. Translation
into the correct system call is only applicable as it's defined in
GDB. *Note File-I/O Remote Protocol Extension::, for a list of
implemented system calls.
`PARAMETER...' is a list of parameters as defined for this very
system call.
The target replies with this packet when it expects GDB to call a
host system call on behalf of the target. GDB replies with an
appropriate `F' packet and keeps up waiting for the next reply
packet from the target. The latest `C', `c', `S' or `s' action is
expected to be continued. *Note File-I/O Remote Protocol
Extension::, for more details.

File: gdb.info, Node: General Query Packets, Next: Architecture-Specific Protocol Details, Prev: Stop Reply Packets, Up: Remote Protocol
E.4 General Query Packets
=========================
Packets starting with `q' are "general query packets"; packets starting
with `Q' are "general set packets". General query and set packets are
a semi-unified form for retrieving and sending information to and from
the stub.
The initial letter of a query or set packet is followed by a name
indicating what sort of thing the packet applies to. For example, GDB
may use a `qSymbol' packet to exchange symbol definitions with the
stub. These packet names follow some conventions:
* The name must not contain commas, colons or semicolons.
* Most GDB query and set packets have a leading upper case letter.
* The names of custom vendor packets should use a company prefix, in
lower case, followed by a period. For example, packets designed at
the Acme Corporation might begin with `qacme.foo' (for querying
foos) or `Qacme.bar' (for setting bars).
The name of a query or set packet should be separated from any
parameters by a `:'; the parameters themselves should be separated by
`,' or `;'. Stubs must be careful to match the full packet name, and
check for a separator or the end of the packet, in case two packet
names share a common prefix. New packets should not begin with `qC',
`qP', or `qL'(1).
Like the descriptions of the other packets, each description here
has a template showing the packet's overall syntax, followed by an
explanation of the packet's meaning. We include spaces in some of the
templates for clarity; these are not part of the packet's syntax. No
GDB packet uses spaces to separate its components.
Here are the currently defined query and set packets:
`QAgent:1'
`QAgent:0'
Turn on or off the agent as a helper to perform some debugging
operations delegated from GDB (*note Control Agent::).
`QAllow:OP:VAL...'
Specify which operations GDB expects to request of the target, as
a semicolon-separated list of operation name and value pairs.
Possible values for OP include `WriteReg', `WriteMem',
`InsertBreak', `InsertTrace', `InsertFastTrace', and `Stop'. VAL
is either 0, indicating that GDB will not request the operation,
or 1, indicating that it may. (The target can then use this to
set up its own internals optimally, for instance if the debugger
never expects to insert breakpoints, it may not need to install
its own trap handler.)
`qC'
Return the current thread ID.
Reply:
`QC THREAD-ID'
Where THREAD-ID is a thread ID as documented in *Note
thread-id syntax::.
`(anything else)'
Any other reply implies the old thread ID.
`qCRC:ADDR,LENGTH'
Compute the CRC checksum of a block of memory using CRC-32 defined
in IEEE 802.3. The CRC is computed byte at a time, taking the most
significant bit of each byte first. The initial pattern code
`0xffffffff' is used to ensure leading zeros affect the CRC.
_Note:_ This is the same CRC used in validating separate debug
files (*note Debugging Information in Separate Files: Separate
Debug Files.). However the algorithm is slightly different. When
validating separate debug files, the CRC is computed taking the
_least_ significant bit of each byte first, and the final result
is inverted to detect trailing zeros.
Reply:
`E NN'
An error (such as memory fault)
`C CRC32'
The specified memory region's checksum is CRC32.
`QDisableRandomization:VALUE'
Some target operating systems will randomize the virtual address
space of the inferior process as a security feature, but provide a
feature to disable such randomization, e.g. to allow for a more
deterministic debugging experience. On such systems, this packet
with a VALUE of 1 directs the target to disable address space
randomization for processes subsequently started via `vRun'
packets, while a packet with a VALUE of 0 tells the target to
enable address space randomization.
This packet is only available in extended mode (*note extended
mode::).
Reply:
`OK'
The request succeeded.
`E NN'
An error occurred. NN are hex digits.
`'
An empty reply indicates that `QDisableRandomization' is not
supported by the stub.
This packet is not probed by default; the remote stub must request
it, by supplying an appropriate `qSupported' response (*note
qSupported::). This should only be done on targets that actually
support disabling address space randomization.
`qfThreadInfo'
`qsThreadInfo'
Obtain a list of all active thread IDs from the target (OS).
Since there may be too many active threads to fit into one reply
packet, this query works iteratively: it may require more than one
query/reply sequence to obtain the entire list of threads. The
first query of the sequence will be the `qfThreadInfo' query;
subsequent queries in the sequence will be the `qsThreadInfo'
query.
NOTE: This packet replaces the `qL' query (see below).
Reply:
`m THREAD-ID'
A single thread ID
`m THREAD-ID,THREAD-ID...'
a comma-separated list of thread IDs
`l'
(lower case letter `L') denotes end of list.
In response to each query, the target will reply with a list of
one or more thread IDs, separated by commas. GDB will respond to
each reply with a request for more thread ids (using the `qs' form
of the query), until the target responds with `l' (lower-case ell,
for "last"). Refer to *Note thread-id syntax::, for the format of
the THREAD-ID fields.
`qGetTLSAddr:THREAD-ID,OFFSET,LM'
Fetch the address associated with thread local storage specified
by THREAD-ID, OFFSET, and LM.
THREAD-ID is the thread ID associated with the thread for which to
fetch the TLS address. *Note thread-id syntax::.
OFFSET is the (big endian, hex encoded) offset associated with the
thread local variable. (This offset is obtained from the debug
information associated with the variable.)
LM is the (big endian, hex encoded) OS/ABI-specific encoding of the
load module associated with the thread local storage. For example,
a GNU/Linux system will pass the link map address of the shared
object associated with the thread local storage under
consideration. Other operating environments may choose to
represent the load module differently, so the precise meaning of
this parameter will vary.
Reply:
`XX...'
Hex encoded (big endian) bytes representing the address of
the thread local storage requested.
`E NN'
An error occurred. NN are hex digits.
`'
An empty reply indicates that `qGetTLSAddr' is not supported
by the stub.
`qGetTIBAddr:THREAD-ID'
Fetch address of the Windows OS specific Thread Information Block.
THREAD-ID is the thread ID associated with the thread.
Reply:
`XX...'
Hex encoded (big endian) bytes representing the linear
address of the thread information block.
`E NN'
An error occured. This means that either the thread was not
found, or the address could not be retrieved.
`'
An empty reply indicates that `qGetTIBAddr' is not supported
by the stub.
`qL STARTFLAG THREADCOUNT NEXTTHREAD'
Obtain thread information from RTOS. Where: STARTFLAG (one hex
digit) is one to indicate the first query and zero to indicate a
subsequent query; THREADCOUNT (two hex digits) is the maximum
number of threads the response packet can contain; and NEXTTHREAD
(eight hex digits), for subsequent queries (STARTFLAG is zero), is
returned in the response as ARGTHREAD.
Don't use this packet; use the `qfThreadInfo' query instead (see
above).
Reply:
`qM COUNT DONE ARGTHREAD THREAD...'
Where: COUNT (two hex digits) is the number of threads being
returned; DONE (one hex digit) is zero to indicate more
threads and one indicates no further threads; ARGTHREADID
(eight hex digits) is NEXTTHREAD from the request packet;
THREAD... is a sequence of thread IDs from the target.
THREADID (eight hex digits). See
`remote.c:parse_threadlist_response()'.
`qOffsets'
Get section offsets that the target used when relocating the
downloaded image.
Reply:
`Text=XXX;Data=YYY[;Bss=ZZZ]'
Relocate the `Text' section by XXX from its original address.
Relocate the `Data' section by YYY from its original address.
If the object file format provides segment information (e.g.
ELF `PT_LOAD' program headers), GDB will relocate entire
segments by the supplied offsets.
_Note: while a `Bss' offset may be included in the response,
GDB ignores this and instead applies the `Data' offset to the
`Bss' section._
`TextSeg=XXX[;DataSeg=YYY]'
Relocate the first segment of the object file, which
conventionally contains program code, to a starting address
of XXX. If `DataSeg' is specified, relocate the second
segment, which conventionally contains modifiable data, to a
starting address of YYY. GDB will report an error if the
object file does not contain segment information, or does not
contain at least as many segments as mentioned in the reply.
Extra segments are kept at fixed offsets relative to the last
relocated segment.
`qP MODE THREAD-ID'
Returns information on THREAD-ID. Where: MODE is a hex encoded 32
bit mode; THREAD-ID is a thread ID (*note thread-id syntax::).
Don't use this packet; use the `qThreadExtraInfo' query instead
(see below).
Reply: see `remote.c:remote_unpack_thread_info_response()'.
`QNonStop:1'
`QNonStop:0'
Enter non-stop (`QNonStop:1') or all-stop (`QNonStop:0') mode.
*Note Remote Non-Stop::, for more information.
Reply:
`OK'
The request succeeded.
`E NN'
An error occurred. NN are hex digits.
`'
An empty reply indicates that `QNonStop' is not supported by
the stub.
This packet is not probed by default; the remote stub must request
it, by supplying an appropriate `qSupported' response (*note
qSupported::). Use of this packet is controlled by the `set
non-stop' command; *note Non-Stop Mode::.
`QPassSignals: SIGNAL [;SIGNAL]...'
Each listed SIGNAL should be passed directly to the inferior
process. Signals are numbered identically to continue packets and
stop replies (*note Stop Reply Packets::). Each SIGNAL list item
should be strictly greater than the previous item. These signals
do not need to stop the inferior, or be reported to GDB. All
other signals should be reported to GDB. Multiple `QPassSignals'
packets do not combine; any earlier `QPassSignals' list is
completely replaced by the new list. This packet improves
performance when using `handle SIGNAL nostop noprint pass'.
Reply:
`OK'
The request succeeded.
`E NN'
An error occurred. NN are hex digits.
`'
An empty reply indicates that `QPassSignals' is not supported
by the stub.
Use of this packet is controlled by the `set remote pass-signals'
command (*note set remote pass-signals: Remote Configuration.).
This packet is not probed by default; the remote stub must request
it, by supplying an appropriate `qSupported' response (*note
qSupported::).
`QProgramSignals: SIGNAL [;SIGNAL]...'
Each listed SIGNAL may be delivered to the inferior process.
Others should be silently discarded.
In some cases, the remote stub may need to decide whether to
deliver a signal to the program or not without GDB involvement.
One example of that is while detaching -- the program's threads
may have stopped for signals that haven't yet had a chance of
being reported to GDB, and so the remote stub can use the signal
list specified by this packet to know whether to deliver or ignore
those pending signals.
This does not influence whether to deliver a signal as requested
by a resumption packet (*note vCont packet::).
Signals are numbered identically to continue packets and stop
replies (*note Stop Reply Packets::). Each SIGNAL list item
should be strictly greater than the previous item. Multiple
`QProgramSignals' packets do not combine; any earlier
`QProgramSignals' list is completely replaced by the new list.
Reply:
`OK'
The request succeeded.
`E NN'
An error occurred. NN are hex digits.
`'
An empty reply indicates that `QProgramSignals' is not
supported by the stub.
Use of this packet is controlled by the `set remote
program-signals' command (*note set remote program-signals: Remote
Configuration.). This packet is not probed by default; the remote
stub must request it, by supplying an appropriate `qSupported'
response (*note qSupported::).
`qRcmd,COMMAND'
COMMAND (hex encoded) is passed to the local interpreter for
execution. Invalid commands should be reported using the output
string. Before the final result packet, the target may also
respond with a number of intermediate `OOUTPUT' console output
packets. _Implementors should note that providing access to a
stubs's interpreter may have security implications_.
Reply:
`OK'
A command response with no output.
`OUTPUT'
A command response with the hex encoded output string OUTPUT.
`E NN'
Indicate a badly formed request.
`'
An empty reply indicates that `qRcmd' is not recognized.
(Note that the `qRcmd' packet's name is separated from the command
by a `,', not a `:', contrary to the naming conventions above.
Please don't use this packet as a model for new packets.)
`qSearch:memory:ADDRESS;LENGTH;SEARCH-PATTERN'
Search LENGTH bytes at ADDRESS for SEARCH-PATTERN. ADDRESS and
LENGTH are encoded in hex. SEARCH-PATTERN is a sequence of bytes,
hex encoded.
Reply:
`0'
The pattern was not found.
`1,address'
The pattern was found at ADDRESS.
`E NN'
A badly formed request or an error was encountered while
searching memory.
`'
An empty reply indicates that `qSearch:memory' is not
recognized.
`QStartNoAckMode'
Request that the remote stub disable the normal `+'/`-' protocol
acknowledgments (*note Packet Acknowledgment::).
Reply:
`OK'
The stub has switched to no-acknowledgment mode. GDB
acknowledges this reponse, but neither the stub nor GDB shall
send or expect further `+'/`-' acknowledgments in the current
connection.
`'
An empty reply indicates that the stub does not support
no-acknowledgment mode.
`qSupported [:GDBFEATURE [;GDBFEATURE]... ]'
Tell the remote stub about features supported by GDB, and query
the stub for features it supports. This packet allows GDB and the
remote stub to take advantage of each others' features.
`qSupported' also consolidates multiple feature probes at startup,
to improve GDB performance--a single larger packet performs better
than multiple smaller probe packets on high-latency links. Some
features may enable behavior which must not be on by default, e.g.
because it would confuse older clients or stubs. Other features
may describe packets which could be automatically probed for, but
are not. These features must be reported before GDB will use
them. This "default unsupported" behavior is not appropriate for
all packets, but it helps to keep the initial connection time
under control with new versions of GDB which support increasing
numbers of packets.
Reply:
`STUBFEATURE [;STUBFEATURE]...'
The stub supports or does not support each returned
STUBFEATURE, depending on the form of each STUBFEATURE (see
below for the possible forms).
`'
An empty reply indicates that `qSupported' is not recognized,
or that no features needed to be reported to GDB.
The allowed forms for each feature (either a GDBFEATURE in the
`qSupported' packet, or a STUBFEATURE in the response) are:
`NAME=VALUE'
The remote protocol feature NAME is supported, and associated
with the specified VALUE. The format of VALUE depends on the
feature, but it must not include a semicolon.
`NAME+'
The remote protocol feature NAME is supported, and does not
need an associated value.
`NAME-'
The remote protocol feature NAME is not supported.
`NAME?'
The remote protocol feature NAME may be supported, and GDB
should auto-detect support in some other way when it is
needed. This form will not be used for GDBFEATURE
notifications, but may be used for STUBFEATURE responses.
Whenever the stub receives a `qSupported' request, the supplied
set of GDB features should override any previous request. This
allows GDB to put the stub in a known state, even if the stub had
previously been communicating with a different version of GDB.
The following values of GDBFEATURE (for the packet sent by GDB)
are defined:
`multiprocess'
This feature indicates whether GDB supports multiprocess
extensions to the remote protocol. GDB does not use such
extensions unless the stub also reports that it supports them
by including `multiprocess+' in its `qSupported' reply.
*Note multiprocess extensions::, for details.
`xmlRegisters'
This feature indicates that GDB supports the XML target
description. If the stub sees `xmlRegisters=' with target
specific strings separated by a comma, it will report register
description.
`qRelocInsn'
This feature indicates whether GDB supports the `qRelocInsn'
packet (*note Relocate instruction reply packet: Tracepoint
Packets.).
Stubs should ignore any unknown values for GDBFEATURE. Any GDB
which sends a `qSupported' packet supports receiving packets of
unlimited length (earlier versions of GDB may reject overly long
responses). Additional values for GDBFEATURE may be defined in
the future to let the stub take advantage of new features in GDB,
e.g. incompatible improvements in the remote protocol--the
`multiprocess' feature is an example of such a feature. The
stub's reply should be independent of the GDBFEATURE entries sent
by GDB; first GDB describes all the features it supports, and then
the stub replies with all the features it supports.
Similarly, GDB will silently ignore unrecognized stub feature
responses, as long as each response uses one of the standard forms.
Some features are flags. A stub which supports a flag feature
should respond with a `+' form response. Other features require
values, and the stub should respond with an `=' form response.
Each feature has a default value, which GDB will use if
`qSupported' is not available or if the feature is not mentioned
in the `qSupported' response. The default values are fixed; a
stub is free to omit any feature responses that match the defaults.
Not all features can be probed, but for those which can, the
probing mechanism is useful: in some cases, a stub's internal
architecture may not allow the protocol layer to know some
information about the underlying target in advance. This is
especially common in stubs which may be configured for multiple
targets.
These are the currently defined stub features and their properties:
Feature Name Value Default Probe Allowed
Required
`PacketSize' Yes `-' No
`qXfer:auxv:read' No `-' Yes
`qXfer:features:read' No `-' Yes
`qXfer:libraries:read' No `-' Yes
`qXfer:memory-map:read' No `-' Yes
`qXfer:sdata:read' No `-' Yes
`qXfer:spu:read' No `-' Yes
`qXfer:spu:write' No `-' Yes
`qXfer:siginfo:read' No `-' Yes
`qXfer:siginfo:write' No `-' Yes
`qXfer:threads:read' No `-' Yes
`qXfer:traceframe-info:read'No `-' Yes
`qXfer:uib:read' No `-' Yes
`qXfer:fdpic:read' No `-' Yes
`QNonStop' No `-' Yes
`QPassSignals' No `-' Yes
`QStartNoAckMode' No `-' Yes
`multiprocess' No `-' No
`ConditionalBreakpoints'No `-' No
`ConditionalTracepoints'No `-' No
`ReverseContinue' No `-' No
`ReverseStep' No `-' No
`TracepointSource' No `-' No
`QAgent' No `-' No
`QAllow' No `-' No
`QDisableRandomization' No `-' No
`EnableDisableTracepoints'No `-' No
`tracenz' No `-' No
`BreakpointCommands' No `-' No
These are the currently defined stub features, in more detail:
`PacketSize=BYTES'
The remote stub can accept packets up to at least BYTES in
length. GDB will send packets up to this size for bulk
transfers, and will never send larger packets. This is a
limit on the data characters in the packet, including the
frame and checksum. There is no trailing NUL byte in a
remote protocol packet; if the stub stores packets in a
NUL-terminated format, it should allow an extra byte in its
buffer for the NUL. If this stub feature is not supported,
GDB guesses based on the size of the `g' packet response.
`qXfer:auxv:read'
The remote stub understands the `qXfer:auxv:read' packet
(*note qXfer auxiliary vector read::).
`qXfer:features:read'
The remote stub understands the `qXfer:features:read' packet
(*note qXfer target description read::).
`qXfer:libraries:read'
The remote stub understands the `qXfer:libraries:read' packet
(*note qXfer library list read::).
`qXfer:libraries-svr4:read'
The remote stub understands the `qXfer:libraries-svr4:read'
packet (*note qXfer svr4 library list read::).
`qXfer:memory-map:read'
The remote stub understands the `qXfer:memory-map:read' packet
(*note qXfer memory map read::).
`qXfer:sdata:read'
The remote stub understands the `qXfer:sdata:read' packet
(*note qXfer sdata read::).
`qXfer:spu:read'
The remote stub understands the `qXfer:spu:read' packet
(*note qXfer spu read::).
`qXfer:spu:write'
The remote stub understands the `qXfer:spu:write' packet
(*note qXfer spu write::).
`qXfer:siginfo:read'
The remote stub understands the `qXfer:siginfo:read' packet
(*note qXfer siginfo read::).
`qXfer:siginfo:write'
The remote stub understands the `qXfer:siginfo:write' packet
(*note qXfer siginfo write::).
`qXfer:threads:read'
The remote stub understands the `qXfer:threads:read' packet
(*note qXfer threads read::).
`qXfer:traceframe-info:read'
The remote stub understands the `qXfer:traceframe-info:read'
packet (*note qXfer traceframe info read::).
`qXfer:uib:read'
The remote stub understands the `qXfer:uib:read' packet
(*note qXfer unwind info block::).
`qXfer:fdpic:read'
The remote stub understands the `qXfer:fdpic:read' packet
(*note qXfer fdpic loadmap read::).
`QNonStop'
The remote stub understands the `QNonStop' packet (*note
QNonStop::).
`QPassSignals'
The remote stub understands the `QPassSignals' packet (*note
QPassSignals::).
`QStartNoAckMode'
The remote stub understands the `QStartNoAckMode' packet and
prefers to operate in no-acknowledgment mode. *Note Packet
Acknowledgment::.
`multiprocess'
The remote stub understands the multiprocess extensions to
the remote protocol syntax. The multiprocess extensions
affect the syntax of thread IDs in both packets and replies
(*note thread-id syntax::), and add process IDs to the `D'
packet and `W' and `X' replies. Note that reporting this
feature indicates support for the syntactic extensions only,
not that the stub necessarily supports debugging of more than
one process at a time. The stub must not use multiprocess
extensions in packet replies unless GDB has also indicated it
supports them in its `qSupported' request.
`qXfer:osdata:read'
The remote stub understands the `qXfer:osdata:read' packet
((*note qXfer osdata read::).
`ConditionalBreakpoints'
The target accepts and implements evaluation of conditional
expressions defined for breakpoints. The target will only
report breakpoint triggers when such conditions are true
(*note Break Conditions: Conditions.).
`ConditionalTracepoints'
The remote stub accepts and implements conditional
expressions defined for tracepoints (*note Tracepoint
Conditions::).
`ReverseContinue'
The remote stub accepts and implements the reverse continue
packet (*note bc::).
`ReverseStep'
The remote stub accepts and implements the reverse step packet
(*note bs::).
`TracepointSource'
The remote stub understands the `QTDPsrc' packet that supplies
the source form of tracepoint definitions.
`QAgent'
The remote stub understands the `QAgent' packet.
`QAllow'
The remote stub understands the `QAllow' packet.
`QDisableRandomization'
The remote stub understands the `QDisableRandomization'
packet.
`StaticTracepoint'
The remote stub supports static tracepoints.
`InstallInTrace'
The remote stub supports installing tracepoint in tracing.
`EnableDisableTracepoints'
The remote stub supports the `QTEnable' (*note QTEnable::) and
`QTDisable' (*note QTDisable::) packets that allow tracepoints
to be enabled and disabled while a trace experiment is
running.
`tracenz'
The remote stub supports the `tracenz' bytecode for
collecting strings. See *Note Bytecode Descriptions:: for
details about the bytecode.
`BreakpointCommands'
The remote stub supports running a breakpoint's command list
itself, rather than reporting the hit to GDB.
`qSymbol::'
Notify the target that GDB is prepared to serve symbol lookup
requests. Accept requests from the target for the values of
symbols.
Reply:
`OK'
The target does not need to look up any (more) symbols.
`qSymbol:SYM_NAME'
The target requests the value of symbol SYM_NAME (hex
encoded). GDB may provide the value by using the
`qSymbol:SYM_VALUE:SYM_NAME' message, described below.
`qSymbol:SYM_VALUE:SYM_NAME'
Set the value of SYM_NAME to SYM_VALUE.
SYM_NAME (hex encoded) is the name of a symbol whose value the
target has previously requested.
SYM_VALUE (hex) is the value for symbol SYM_NAME. If GDB cannot
supply a value for SYM_NAME, then this field will be empty.
Reply:
`OK'
The target does not need to look up any (more) symbols.
`qSymbol:SYM_NAME'
The target requests the value of a new symbol SYM_NAME (hex
encoded). GDB will continue to supply the values of symbols
(if available), until the target ceases to request them.
`qTBuffer'
`QTBuffer'
`QTDisconnected'
`QTDP'
`QTDPsrc'
`QTDV'
`qTfP'
`qTfV'
`QTFrame'
`qTMinFTPILen'
*Note Tracepoint Packets::.
`qThreadExtraInfo,THREAD-ID'
Obtain a printable string description of a thread's attributes from
the target OS. THREAD-ID is a thread ID; see *Note thread-id
syntax::. This string may contain anything that the target OS
thinks is interesting for GDB to tell the user about the thread.
The string is displayed in GDB's `info threads' display. Some
examples of possible thread extra info strings are `Runnable', or
`Blocked on Mutex'.
Reply:
`XX...'
Where `XX...' is a hex encoding of ASCII data, comprising the
printable string containing the extra information about the
thread's attributes.
(Note that the `qThreadExtraInfo' packet's name is separated from
the command by a `,', not a `:', contrary to the naming
conventions above. Please don't use this packet as a model for new
packets.)
`QTNotes'
`qTP'
`QTSave'
`qTsP'
`qTsV'
`QTStart'
`QTStop'
`QTEnable'
`QTDisable'
`QTinit'
`QTro'
`qTStatus'
`qTV'
`qTfSTM'
`qTsSTM'
`qTSTMat'
*Note Tracepoint Packets::.
`qXfer:OBJECT:read:ANNEX:OFFSET,LENGTH'
Read uninterpreted bytes from the target's special data area
identified by the keyword OBJECT. Request LENGTH bytes starting
at OFFSET bytes into the data. The content and encoding of ANNEX
is specific to OBJECT; it can supply additional details about what
data to access.
Here are the specific requests of this form defined so far. All
`qXfer:OBJECT:read:...' requests use the same reply formats,
listed below.
`qXfer:auxv:read::OFFSET,LENGTH'
Access the target's "auxiliary vector". *Note auxiliary
vector: OS Information. Note ANNEX must be empty.
This packet is not probed by default; the remote stub must
request it, by supplying an appropriate `qSupported' response
(*note qSupported::).
`qXfer:features:read:ANNEX:OFFSET,LENGTH'
Access the "target description". *Note Target
Descriptions::. The annex specifies which XML document to
access. The main description is always loaded from the
`target.xml' annex.
This packet is not probed by default; the remote stub must
request it, by supplying an appropriate `qSupported' response
(*note qSupported::).
`qXfer:libraries:read:ANNEX:OFFSET,LENGTH'
Access the target's list of loaded libraries. *Note Library
List Format::. The annex part of the generic `qXfer' packet
must be empty (*note qXfer read::).
Targets which maintain a list of libraries in the program's
memory do not need to implement this packet; it is designed
for platforms where the operating system manages the list of
loaded libraries.
This packet is not probed by default; the remote stub must
request it, by supplying an appropriate `qSupported' response
(*note qSupported::).
`qXfer:libraries-svr4:read:ANNEX:OFFSET,LENGTH'
Access the target's list of loaded libraries when the target
is an SVR4 platform. *Note Library List Format for SVR4
Targets::. The annex part of the generic `qXfer' packet must
be empty (*note qXfer read::).
This packet is optional for better performance on SVR4
targets. GDB uses memory read packets to read the SVR4
library list otherwise.
This packet is not probed by default; the remote stub must
request it, by supplying an appropriate `qSupported' response
(*note qSupported::).
`qXfer:memory-map:read::OFFSET,LENGTH'
Access the target's "memory-map". *Note Memory Map Format::.
The annex part of the generic `qXfer' packet must be empty
(*note qXfer read::).
This packet is not probed by default; the remote stub must
request it, by supplying an appropriate `qSupported' response
(*note qSupported::).
`qXfer:sdata:read::OFFSET,LENGTH'
Read contents of the extra collected static tracepoint marker
information. The annex part of the generic `qXfer' packet
must be empty (*note qXfer read::). *Note Tracepoint Action
Lists: Tracepoint Actions.
This packet is not probed by default; the remote stub must
request it, by supplying an appropriate `qSupported' response
(*note qSupported::).
`qXfer:siginfo:read::OFFSET,LENGTH'
Read contents of the extra signal information on the target
system. The annex part of the generic `qXfer' packet must be
empty (*note qXfer read::).
This packet is not probed by default; the remote stub must
request it, by supplying an appropriate `qSupported' response
(*note qSupported::).
`qXfer:spu:read:ANNEX:OFFSET,LENGTH'
Read contents of an `spufs' file on the target system. The
annex specifies which file to read; it must be of the form
`ID/NAME', where ID specifies an SPU context ID in the target
process, and NAME identifes the `spufs' file in that context
to be accessed.
This packet is not probed by default; the remote stub must
request it, by supplying an appropriate `qSupported' response
(*note qSupported::).
`qXfer:threads:read::OFFSET,LENGTH'
Access the list of threads on target. *Note Thread List
Format::. The annex part of the generic `qXfer' packet must
be empty (*note qXfer read::).
This packet is not probed by default; the remote stub must
request it, by supplying an appropriate `qSupported' response
(*note qSupported::).
`qXfer:traceframe-info:read::OFFSET,LENGTH'
Return a description of the current traceframe's contents.
*Note Traceframe Info Format::. The annex part of the generic
`qXfer' packet must be empty (*note qXfer read::).
This packet is not probed by default; the remote stub must
request it, by supplying an appropriate `qSupported' response
(*note qSupported::).
`qXfer:uib:read:PC:OFFSET,LENGTH'
Return the unwind information block for PC. This packet is
used on OpenVMS/ia64 to ask the kernel unwind information.
This packet is not probed by default.
`qXfer:fdpic:read:ANNEX:OFFSET,LENGTH'
Read contents of `loadmap's on the target system. The annex,
either `exec' or `interp', specifies which `loadmap',
executable `loadmap' or interpreter `loadmap' to read.
This packet is not probed by default; the remote stub must
request it, by supplying an appropriate `qSupported' response
(*note qSupported::).
`qXfer:osdata:read::OFFSET,LENGTH'
Access the target's "operating system information". *Note
Operating System Information::.
Reply:
`m DATA'
Data DATA (*note Binary Data::) has been read from the
target. There may be more data at a higher address (although
it is permitted to return `m' even for the last valid block
of data, as long as at least one byte of data was read).
DATA may have fewer bytes than the LENGTH in the request.
`l DATA'
Data DATA (*note Binary Data::) has been read from the target.
There is no more data to be read. DATA may have fewer bytes
than the LENGTH in the request.
`l'
The OFFSET in the request is at the end of the data. There
is no more data to be read.
`E00'
The request was malformed, or ANNEX was invalid.
`E NN'
The offset was invalid, or there was an error encountered
reading the data. NN is a hex-encoded `errno' value.
`'
An empty reply indicates the OBJECT string was not recognized
by the stub, or that the object does not support reading.
`qXfer:OBJECT:write:ANNEX:OFFSET:DATA...'
Write uninterpreted bytes into the target's special data area
identified by the keyword OBJECT, starting at OFFSET bytes into
the data. DATA... is the binary-encoded data (*note Binary
Data::) to be written. The content and encoding of ANNEX is
specific to OBJECT; it can supply additional details about what
data to access.
Here are the specific requests of this form defined so far. All
`qXfer:OBJECT:write:...' requests use the same reply formats,
listed below.
`qXfer:siginfo:write::OFFSET:DATA...'
Write DATA to the extra signal information on the target
system. The annex part of the generic `qXfer' packet must be
empty (*note qXfer write::).
This packet is not probed by default; the remote stub must
request it, by supplying an appropriate `qSupported' response
(*note qSupported::).
`qXfer:spu:write:ANNEX:OFFSET:DATA...'
Write DATA to an `spufs' file on the target system. The
annex specifies which file to write; it must be of the form
`ID/NAME', where ID specifies an SPU context ID in the target
process, and NAME identifes the `spufs' file in that context
to be accessed.
This packet is not probed by default; the remote stub must
request it, by supplying an appropriate `qSupported' response
(*note qSupported::).
Reply:
`NN'
NN (hex encoded) is the number of bytes written. This may be
fewer bytes than supplied in the request.
`E00'
The request was malformed, or ANNEX was invalid.
`E NN'
The offset was invalid, or there was an error encountered
writing the data. NN is a hex-encoded `errno' value.
`'
An empty reply indicates the OBJECT string was not recognized
by the stub, or that the object does not support writing.
`qXfer:OBJECT:OPERATION:...'
Requests of this form may be added in the future. When a stub does
not recognize the OBJECT keyword, or its support for OBJECT does
not recognize the OPERATION keyword, the stub must respond with an
empty packet.
`qAttached:PID'
Return an indication of whether the remote server attached to an
existing process or created a new process. When the multiprocess
protocol extensions are supported (*note multiprocess
extensions::), PID is an integer in hexadecimal format identifying
the target process. Otherwise, GDB will omit the PID field and
the query packet will be simplified as `qAttached'.
This query is used, for example, to know whether the remote process
should be detached or killed when a GDB session is ended with the
`quit' command.
Reply:
`1'
The remote server attached to an existing process.
`0'
The remote server created a new process.
`E NN'
A badly formed request or an error was encountered.
---------- Footnotes ----------
(1) The `qP' and `qL' packets predate these conventions, and have
arguments without any terminator for the packet name; we suspect they
are in widespread use in places that are difficult to upgrade. The
`qC' packet has no arguments, but some existing stubs (e.g. RedBoot)
are known to not check for the end of the packet.

File: gdb.info, Node: Architecture-Specific Protocol Details, Next: Tracepoint Packets, Prev: General Query Packets, Up: Remote Protocol
E.5 Architecture-Specific Protocol Details
==========================================
This section describes how the remote protocol is applied to specific
target architectures. Also see *Note Standard Target Features::, for
details of XML target descriptions for each architecture.
* Menu:
* ARM-Specific Protocol Details::
* MIPS-Specific Protocol Details::

File: gdb.info, Node: ARM-Specific Protocol Details, Next: MIPS-Specific Protocol Details, Up: Architecture-Specific Protocol Details
E.5.1 ARM-specific Protocol Details
-----------------------------------
* Menu:
* ARM Breakpoint Kinds::

File: gdb.info, Node: ARM Breakpoint Kinds, Up: ARM-Specific Protocol Details
E.5.1.1 ARM Breakpoint Kinds
............................
These breakpoint kinds are defined for the `Z0' and `Z1' packets.
2
16-bit Thumb mode breakpoint.
3
32-bit Thumb mode (Thumb-2) breakpoint.
4
32-bit ARM mode breakpoint.

File: gdb.info, Node: MIPS-Specific Protocol Details, Prev: ARM-Specific Protocol Details, Up: Architecture-Specific Protocol Details
E.5.2 MIPS-specific Protocol Details
------------------------------------
* Menu:
* MIPS Register packet Format::
* MIPS Breakpoint Kinds::

File: gdb.info, Node: MIPS Register packet Format, Next: MIPS Breakpoint Kinds, Up: MIPS-Specific Protocol Details
E.5.2.1 MIPS Register Packet Format
...................................
The following `g'/`G' packets have previously been defined. In the
below, some thirty-two bit registers are transferred as sixty-four
bits. Those registers should be zero/sign extended (which?) to fill
the space allocated. Register bytes are transferred in target byte
order. The two nibbles within a register byte are transferred
most-significant - least-significant.
MIPS32
All registers are transferred as thirty-two bit quantities in the
order: 32 general-purpose; sr; lo; hi; bad; cause; pc; 32
floating-point registers; fsr; fir; fp.
MIPS64
All registers are transferred as sixty-four bit quantities
(including thirty-two bit registers such as `sr'). The ordering
is the same as `MIPS32'.

File: gdb.info, Node: MIPS Breakpoint Kinds, Prev: MIPS Register packet Format, Up: MIPS-Specific Protocol Details
E.5.2.2 MIPS Breakpoint Kinds
.............................
These breakpoint kinds are defined for the `Z0' and `Z1' packets.
2
16-bit MIPS16 mode breakpoint.
3
16-bit microMIPS mode breakpoint.
4
32-bit standard MIPS mode breakpoint.
5
32-bit microMIPS mode breakpoint.

File: gdb.info, Node: Tracepoint Packets, Next: Host I/O Packets, Prev: Architecture-Specific Protocol Details, Up: Remote Protocol
E.6 Tracepoint Packets
======================
Here we describe the packets GDB uses to implement tracepoints (*note
Tracepoints::).
`QTDP:N:ADDR:ENA:STEP:PASS[:FFLEN][:XLEN,BYTES][-]'
Create a new tracepoint, number N, at ADDR. If ENA is `E', then
the tracepoint is enabled; if it is `D', then the tracepoint is
disabled. STEP is the tracepoint's step count, and PASS is its
pass count. If an `F' is present, then the tracepoint is to be a
fast tracepoint, and the FLEN is the number of bytes that the
target should copy elsewhere to make room for the tracepoint. If
an `X' is present, it introduces a tracepoint condition, which
consists of a hexadecimal length, followed by a comma and
hex-encoded bytes, in a manner similar to action encodings as
described below. If the trailing `-' is present, further `QTDP'
packets will follow to specify this tracepoint's actions.
Replies:
`OK'
The packet was understood and carried out.
`qRelocInsn'
*Note Relocate instruction reply packet: Tracepoint Packets.
`'
The packet was not recognized.
`QTDP:-N:ADDR:[S]ACTION...[-]'
Define actions to be taken when a tracepoint is hit. N and ADDR
must be the same as in the initial `QTDP' packet for this
tracepoint. This packet may only be sent immediately after
another `QTDP' packet that ended with a `-'. If the trailing `-'
is present, further `QTDP' packets will follow, specifying more
actions for this tracepoint.
In the series of action packets for a given tracepoint, at most one
can have an `S' before its first ACTION. If such a packet is
sent, it and the following packets define "while-stepping"
actions. Any prior packets define ordinary actions -- that is,
those taken when the tracepoint is first hit. If no action packet
has an `S', then all the packets in the series specify ordinary
tracepoint actions.
The `ACTION...' portion of the packet is a series of actions,
concatenated without separators. Each action has one of the
following forms:
`R MASK'
Collect the registers whose bits are set in MASK. MASK is a
hexadecimal number whose I'th bit is set if register number I
should be collected. (The least significant bit is numbered
zero.) Note that MASK may be any number of digits long; it
may not fit in a 32-bit word.
`M BASEREG,OFFSET,LEN'
Collect LEN bytes of memory starting at the address in
register number BASEREG, plus OFFSET. If BASEREG is `-1',
then the range has a fixed address: OFFSET is the address of
the lowest byte to collect. The BASEREG, OFFSET, and LEN
parameters are all unsigned hexadecimal values (the `-1'
value for BASEREG is a special case).
`X LEN,EXPR'
Evaluate EXPR, whose length is LEN, and collect memory as it
directs. EXPR is an agent expression, as described in *Note
Agent Expressions::. Each byte of the expression is encoded
as a two-digit hex number in the packet; LEN is the number of
bytes in the expression (and thus one-half the number of hex
digits in the packet).
Any number of actions may be packed together in a single `QTDP'
packet, as long as the packet does not exceed the maximum packet
length (400 bytes, for many stubs). There may be only one `R'
action per tracepoint, and it must precede any `M' or `X' actions.
Any registers referred to by `M' and `X' actions must be
collected by a preceding `R' action. (The "while-stepping"
actions are treated as if they were attached to a separate
tracepoint, as far as these restrictions are concerned.)
Replies:
`OK'
The packet was understood and carried out.
`qRelocInsn'
*Note Relocate instruction reply packet: Tracepoint Packets.
`'
The packet was not recognized.
`QTDPsrc:N:ADDR:TYPE:START:SLEN:BYTES'
Specify a source string of tracepoint N at address ADDR. This is
useful to get accurate reproduction of the tracepoints originally
downloaded at the beginning of the trace run. TYPE is the name of
the tracepoint part, such as `cond' for the tracepoint's
conditional expression (see below for a list of types), while
BYTES is the string, encoded in hexadecimal.
START is the offset of the BYTES within the overall source string,
while SLEN is the total length of the source string. This is
intended for handling source strings that are longer than will fit
in a single packet.
The available string types are `at' for the location, `cond' for
the conditional, and `cmd' for an action command. GDB sends a
separate packet for each command in the action list, in the same
order in which the commands are stored in the list.
The target does not need to do anything with source strings except
report them back as part of the replies to the `qTfP'/`qTsP' query
packets.
Although this packet is optional, and GDB will only send it if the
target replies with `TracepointSource' *Note General Query
Packets::, it makes both disconnected tracing and trace files much
easier to use. Otherwise the user must be careful that the
tracepoints in effect while looking at trace frames are identical
to the ones in effect during the trace run; even a small
discrepancy could cause `tdump' not to work, or a particular trace
frame not be found.
`QTDV:N:VALUE'
Create a new trace state variable, number N, with an initial value
of VALUE, which is a 64-bit signed integer. Both N and VALUE are
encoded as hexadecimal values. GDB has the option of not using
this packet for initial values of zero; the target should simply
create the trace state variables as they are mentioned in
expressions.
`QTFrame:N'
Select the N'th tracepoint frame from the buffer, and use the
register and memory contents recorded there to answer subsequent
request packets from GDB.
A successful reply from the stub indicates that the stub has found
the requested frame. The response is a series of parts,
concatenated without separators, describing the frame we selected.
Each part has one of the following forms:
`F F'
The selected frame is number N in the trace frame buffer; F
is a hexadecimal number. If F is `-1', then there was no
frame matching the criteria in the request packet.
`T T'
The selected trace frame records a hit of tracepoint number T;
T is a hexadecimal number.
`QTFrame:pc:ADDR'
Like `QTFrame:N', but select the first tracepoint frame after the
currently selected frame whose PC is ADDR; ADDR is a hexadecimal
number.
`QTFrame:tdp:T'
Like `QTFrame:N', but select the first tracepoint frame after the
currently selected frame that is a hit of tracepoint T; T is a
hexadecimal number.
`QTFrame:range:START:END'
Like `QTFrame:N', but select the first tracepoint frame after the
currently selected frame whose PC is between START (inclusive) and
END (inclusive); START and END are hexadecimal numbers.
`QTFrame:outside:START:END'
Like `QTFrame:range:START:END', but select the first frame
_outside_ the given range of addresses (exclusive).
`qTMinFTPILen'
This packet requests the minimum length of instruction at which a
fast tracepoint (*note Set Tracepoints::) may be placed. For
instance, on the 32-bit x86 architecture, it is possible to use a
4-byte jump, but it depends on the target system being able to
create trampolines in the first 64K of memory, which might or
might not be possible for that system. So the reply to this
packet will be 4 if it is able to arrange for that.
Replies:
`0'
The minimum instruction length is currently unknown.
`LENGTH'
The minimum instruction length is LENGTH, where LENGTH is
greater or equal to 1. LENGTH is a hexadecimal number. A
reply of 1 means that a fast tracepoint may be placed on any
instruction regardless of size.
`E'
An error has occurred.
`'
An empty reply indicates that the request is not supported by
the stub.
`QTStart'
Begin the tracepoint experiment. Begin collecting data from
tracepoint hits in the trace frame buffer. This packet supports
the `qRelocInsn' reply (*note Relocate instruction reply packet:
Tracepoint Packets.).
`QTStop'
End the tracepoint experiment. Stop collecting trace frames.
`QTEnable:N:ADDR'
Enable tracepoint N at address ADDR in a started tracepoint
experiment. If the tracepoint was previously disabled, then
collection of data from it will resume.
`QTDisable:N:ADDR'
Disable tracepoint N at address ADDR in a started tracepoint
experiment. No more data will be collected from the tracepoint
unless `QTEnable:N:ADDR' is subsequently issued.
`QTinit'
Clear the table of tracepoints, and empty the trace frame buffer.
`QTro:START1,END1:START2,END2:...'
Establish the given ranges of memory as "transparent". The stub
will answer requests for these ranges from memory's current
contents, if they were not collected as part of the tracepoint hit.
GDB uses this to mark read-only regions of memory, like those
containing program code. Since these areas never change, they
should still have the same contents they did when the tracepoint
was hit, so there's no reason for the stub to refuse to provide
their contents.
`QTDisconnected:VALUE'
Set the choice to what to do with the tracing run when GDB
disconnects from the target. A VALUE of 1 directs the target to
continue the tracing run, while 0 tells the target to stop tracing
if GDB is no longer in the picture.
`qTStatus'
Ask the stub if there is a trace experiment running right now.
The reply has the form:
`TRUNNING[;FIELD]...'
RUNNING is a single digit `1' if the trace is presently
running, or `0' if not. It is followed by semicolon-separated
optional fields that an agent may use to report additional
status.
If the trace is not running, the agent may report any of several
explanations as one of the optional fields:
`tnotrun:0'
No trace has been run yet.
`tstop[:TEXT]:0'
The trace was stopped by a user-originated stop command. The
optional TEXT field is a user-supplied string supplied as
part of the stop command (for instance, an explanation of why
the trace was stopped manually). It is hex-encoded.
`tfull:0'
The trace stopped because the trace buffer filled up.
`tdisconnected:0'
The trace stopped because GDB disconnected from the target.
`tpasscount:TPNUM'
The trace stopped because tracepoint TPNUM exceeded its pass
count.
`terror:TEXT:TPNUM'
The trace stopped because tracepoint TPNUM had an error. The
string TEXT is available to describe the nature of the error
(for instance, a divide by zero in the condition expression).
TEXT is hex encoded.
`tunknown:0'
The trace stopped for some other reason.
Additional optional fields supply statistical and other
information. Although not required, they are extremely useful for
users monitoring the progress of a trace run. If a trace has
stopped, and these numbers are reported, they must reflect the
state of the just-stopped trace.
`tframes:N'
The number of trace frames in the buffer.
`tcreated:N'
The total number of trace frames created during the run. This
may be larger than the trace frame count, if the buffer is
circular.
`tsize:N'
The total size of the trace buffer, in bytes.
`tfree:N'
The number of bytes still unused in the buffer.
`circular:N'
The value of the circular trace buffer flag. `1' means that
the trace buffer is circular and old trace frames will be
discarded if necessary to make room, `0' means that the trace
buffer is linear and may fill up.
`disconn:N'
The value of the disconnected tracing flag. `1' means that
tracing will continue after GDB disconnects, `0' means that
the trace run will stop.
`qTP:TP:ADDR'
Ask the stub for the current state of tracepoint number TP at
address ADDR.
Replies:
`VHITS:USAGE'
The tracepoint has been hit HITS times so far during the trace
run, and accounts for USAGE in the trace buffer. Note that
`while-stepping' steps are not counted as separate hits, but
the steps' space consumption is added into the usage number.
`qTV:VAR'
Ask the stub for the value of the trace state variable number VAR.
Replies:
`VVALUE'
The value of the variable is VALUE. This will be the current
value of the variable if the user is examining a running
target, or a saved value if the variable was collected in the
trace frame that the user is looking at. Note that multiple
requests may result in different reply values, such as when
requesting values while the program is running.
`U'
The value of the variable is unknown. This would occur, for
example, if the user is examining a trace frame in which the
requested variable was not collected.
`qTfP'
`qTsP'
These packets request data about tracepoints that are being used by
the target. GDB sends `qTfP' to get the first piece of data, and
multiple `qTsP' to get additional pieces. Replies to these
packets generally take the form of the `QTDP' packets that define
tracepoints. (FIXME add detailed syntax)
`qTfV'
`qTsV'
These packets request data about trace state variables that are on
the target. GDB sends `qTfV' to get the first vari of data, and
multiple `qTsV' to get additional variables. Replies to these
packets follow the syntax of the `QTDV' packets that define trace
state variables.
`qTfSTM'
`qTsSTM'
These packets request data about static tracepoint markers that
exist in the target program. GDB sends `qTfSTM' to get the first
piece of data, and multiple `qTsSTM' to get additional pieces.
Replies to these packets take the following form:
Reply:
`m ADDRESS:ID:EXTRA'
A single marker
`m ADDRESS:ID:EXTRA,ADDRESS:ID:EXTRA...'
a comma-separated list of markers
`l'
(lower case letter `L') denotes end of list.
`E NN'
An error occurred. NN are hex digits.
`'
An empty reply indicates that the request is not supported by
the stub.
ADDRESS is encoded in hex. ID and EXTRA are strings encoded in
hex.
In response to each query, the target will reply with a list of
one or more markers, separated by commas. GDB will respond to each
reply with a request for more markers (using the `qs' form of the
query), until the target responds with `l' (lower-case ell, for
"last").
`qTSTMat:ADDRESS'
This packets requests data about static tracepoint markers in the
target program at ADDRESS. Replies to this packet follow the
syntax of the `qTfSTM' and `qTsSTM' packets that list static
tracepoint markers.
`QTSave:FILENAME'
This packet directs the target to save trace data to the file name
FILENAME in the target's filesystem. FILENAME is encoded as a hex
string; the interpretation of the file name (relative vs absolute,
wild cards, etc) is up to the target.
`qTBuffer:OFFSET,LEN'
Return up to LEN bytes of the current contents of trace buffer,
starting at OFFSET. The trace buffer is treated as if it were a
contiguous collection of traceframes, as per the trace file format.
The reply consists as many hex-encoded bytes as the target can
deliver in a packet; it is not an error to return fewer than were
asked for. A reply consisting of just `l' indicates that no bytes
are available.
`QTBuffer:circular:VALUE'
This packet directs the target to use a circular trace buffer if
VALUE is 1, or a linear buffer if the value is 0.
`QTNotes:[TYPE:TEXT][;TYPE:TEXT]...'
This packet adds optional textual notes to the trace run.
Allowable types include `user', `notes', and `tstop', the TEXT
fields are arbitrary strings, hex-encoded.
E.6.1 Relocate instruction reply packet
---------------------------------------
When installing fast tracepoints in memory, the target may need to
relocate the instruction currently at the tracepoint address to a
different address in memory. For most instructions, a simple copy is
enough, but, for example, call instructions that implicitly push the
return address on the stack, and relative branches or other PC-relative
instructions require offset adjustment, so that the effect of executing
the instruction at a different address is the same as if it had
executed in the original location.
In response to several of the tracepoint packets, the target may also
respond with a number of intermediate `qRelocInsn' request packets
before the final result packet, to have GDB handle this relocation
operation. If a packet supports this mechanism, its documentation will
explicitly say so. See for example the above descriptions for the
`QTStart' and `QTDP' packets. The format of the request is:
`qRelocInsn:FROM;TO'
This requests GDB to copy instruction at address FROM to address
TO, possibly adjusted so that executing the instruction at TO has
the same effect as executing it at FROM. GDB writes the adjusted
instruction to target memory starting at TO.
Replies:
`qRelocInsn:ADJUSTED_SIZE'
Informs the stub the relocation is complete. ADJUSTED_SIZE is the
length in bytes of resulting relocated instruction sequence.
`E NN'
A badly formed request was detected, or an error was encountered
while relocating the instruction.

File: gdb.info, Node: Host I/O Packets, Next: Interrupts, Prev: Tracepoint Packets, Up: Remote Protocol
E.7 Host I/O Packets
====================
The "Host I/O" packets allow GDB to perform I/O operations on the far
side of a remote link. For example, Host I/O is used to upload and
download files to a remote target with its own filesystem. Host I/O
uses the same constant values and data structure layout as the
target-initiated File-I/O protocol. However, the Host I/O packets are
structured differently. The target-initiated protocol relies on target
memory to store parameters and buffers. Host I/O requests are
initiated by GDB, and the target's memory is not involved. *Note
File-I/O Remote Protocol Extension::, for more details on the
target-initiated protocol.
The Host I/O request packets all encode a single operation along with
its arguments. They have this format:
`vFile:OPERATION: PARAMETER...'
OPERATION is the name of the particular request; the target should
compare the entire packet name up to the second colon when checking
for a supported operation. The format of PARAMETER depends on the
operation. Numbers are always passed in hexadecimal. Negative
numbers have an explicit minus sign (i.e. two's complement is not
used). Strings (e.g. filenames) are encoded as a series of
hexadecimal bytes. The last argument to a system call may be a
buffer of escaped binary data (*note Binary Data::).
The valid responses to Host I/O packets are:
`F RESULT [, ERRNO] [; ATTACHMENT]'
RESULT is the integer value returned by this operation, usually
non-negative for success and -1 for errors. If an error has
occured, ERRNO will be included in the result. ERRNO will have a
value defined by the File-I/O protocol (*note Errno Values::). For
operations which return data, ATTACHMENT supplies the data as a
binary buffer. Binary buffers in response packets are escaped in
the normal way (*note Binary Data::). See the individual packet
documentation for the interpretation of RESULT and ATTACHMENT.
`'
An empty response indicates that this operation is not recognized.
These are the supported Host I/O operations:
`vFile:open: PATHNAME, FLAGS, MODE'
Open a file at PATHNAME and return a file descriptor for it, or
return -1 if an error occurs. PATHNAME is a string, FLAGS is an
integer indicating a mask of open flags (*note Open Flags::), and
MODE is an integer indicating a mask of mode bits to use if the
file is created (*note mode_t Values::). *Note open::, for
details of the open flags and mode values.
`vFile:close: FD'
Close the open file corresponding to FD and return 0, or -1 if an
error occurs.
`vFile:pread: FD, COUNT, OFFSET'
Read data from the open file corresponding to FD. Up to COUNT
bytes will be read from the file, starting at OFFSET relative to
the start of the file. The target may read fewer bytes; common
reasons include packet size limits and an end-of-file condition.
The number of bytes read is returned. Zero should only be
returned for a successful read at the end of the file, or if COUNT
was zero.
The data read should be returned as a binary attachment on success.
If zero bytes were read, the response should include an empty
binary attachment (i.e. a trailing semicolon). The return value
is the number of target bytes read; the binary attachment may be
longer if some characters were escaped.
`vFile:pwrite: FD, OFFSET, DATA'
Write DATA (a binary buffer) to the open file corresponding to FD.
Start the write at OFFSET from the start of the file. Unlike
many `write' system calls, there is no separate COUNT argument;
the length of DATA in the packet is used. `vFile:write' returns
the number of bytes written, which may be shorter than the length
of DATA, or -1 if an error occurred.
`vFile:unlink: PATHNAME'
Delete the file at PATHNAME on the target. Return 0, or -1 if an
error occurs. PATHNAME is a string.
`vFile:readlink: FILENAME'
Read value of symbolic link FILENAME on the target. Return the
number of bytes read, or -1 if an error occurs.
The data read should be returned as a binary attachment on success.
If zero bytes were read, the response should include an empty
binary attachment (i.e. a trailing semicolon). The return value
is the number of target bytes read; the binary attachment may be
longer if some characters were escaped.

File: gdb.info, Node: Interrupts, Next: Notification Packets, Prev: Host I/O Packets, Up: Remote Protocol
E.8 Interrupts
==============
When a program on the remote target is running, GDB may attempt to
interrupt it by sending a `Ctrl-C', `BREAK' or a `BREAK' followed by
`g', control of which is specified via GDB's `interrupt-sequence'.
The precise meaning of `BREAK' is defined by the transport mechanism
and may, in fact, be undefined. GDB does not currently define a
`BREAK' mechanism for any of the network interfaces except for TCP, in
which case GDB sends the `telnet' BREAK sequence.
`Ctrl-C', on the other hand, is defined and implemented for all
transport mechanisms. It is represented by sending the single byte
`0x03' without any of the usual packet overhead described in the
Overview section (*note Overview::). When a `0x03' byte is transmitted
as part of a packet, it is considered to be packet data and does _not_
represent an interrupt. E.g., an `X' packet (*note X packet::), used
for binary downloads, may include an unescaped `0x03' as part of its
packet.
`BREAK' followed by `g' is also known as Magic SysRq g. When Linux
kernel receives this sequence from serial port, it stops execution and
connects to gdb.
Stubs are not required to recognize these interrupt mechanisms and
the precise meaning associated with receipt of the interrupt is
implementation defined. If the target supports debugging of multiple
threads and/or processes, it should attempt to interrupt all
currently-executing threads and processes. If the stub is successful
at interrupting the running program, it should send one of the stop
reply packets (*note Stop Reply Packets::) to GDB as a result of
successfully stopping the program in all-stop mode, and a stop reply
for each stopped thread in non-stop mode. Interrupts received while the
program is stopped are discarded.

File: gdb.info, Node: Notification Packets, Next: Remote Non-Stop, Prev: Interrupts, Up: Remote Protocol
E.9 Notification Packets
========================
The GDB remote serial protocol includes "notifications", packets that
require no acknowledgment. Both the GDB and the stub may send
notifications (although the only notifications defined at present are
sent by the stub). Notifications carry information without incurring
the round-trip latency of an acknowledgment, and so are useful for
low-impact communications where occasional packet loss is not a problem.
A notification packet has the form `% DATA # CHECKSUM', where DATA
is the content of the notification, and CHECKSUM is a checksum of DATA,
computed and formatted as for ordinary GDB packets. A notification's
DATA never contains `$', `%' or `#' characters. Upon receiving a
notification, the recipient sends no `+' or `-' to acknowledge the
notification's receipt or to report its corruption.
Every notification's DATA begins with a name, which contains no
colon characters, followed by a colon character.
Recipients should silently ignore corrupted notifications and
notifications they do not understand. Recipients should restart
timeout periods on receipt of a well-formed notification, whether or
not they understand it.
Senders should only send the notifications described here when this
protocol description specifies that they are permitted. In the future,
we may extend the protocol to permit existing notifications in new
contexts; this rule helps older senders avoid confusing newer
recipients.
(Older versions of GDB ignore bytes received until they see the `$'
byte that begins an ordinary packet, so new stubs may transmit
notifications without fear of confusing older clients. There are no
notifications defined for GDB to send at the moment, but we assume that
most older stubs would ignore them, as well.)
The following notification packets from the stub to GDB are defined:
`Stop: REPLY'
Report an asynchronous stop event in non-stop mode. The REPLY has
the form of a stop reply, as described in *Note Stop Reply
Packets::. Refer to *Note Remote Non-Stop::, for information on
how these notifications are acknowledged by GDB.

File: gdb.info, Node: Remote Non-Stop, Next: Packet Acknowledgment, Prev: Notification Packets, Up: Remote Protocol
E.10 Remote Protocol Support for Non-Stop Mode
==============================================
GDB's remote protocol supports non-stop debugging of multi-threaded
programs, as described in *Note Non-Stop Mode::. If the stub supports
non-stop mode, it should report that to GDB by including `QNonStop+' in
its `qSupported' response (*note qSupported::).
GDB typically sends a `QNonStop' packet only when establishing a new
connection with the stub. Entering non-stop mode does not alter the
state of any currently-running threads, but targets must stop all
threads in any already-attached processes when entering all-stop mode.
GDB uses the `?' packet as necessary to probe the target state after a
mode change.
In non-stop mode, when an attached process encounters an event that
would otherwise be reported with a stop reply, it uses the asynchronous
notification mechanism (*note Notification Packets::) to inform GDB.
In contrast to all-stop mode, where all threads in all processes are
stopped when a stop reply is sent, in non-stop mode only the thread
reporting the stop event is stopped. That is, when reporting a `S' or
`T' response to indicate completion of a step operation, hitting a
breakpoint, or a fault, only the affected thread is stopped; any other
still-running threads continue to run. When reporting a `W' or `X'
response, all running threads belonging to other attached processes
continue to run.
Only one stop reply notification at a time may be pending; if
additional stop events occur before GDB has acknowledged the previous
notification, they must be queued by the stub for later synchronous
transmission in response to `vStopped' packets from GDB. Because the
notification mechanism is unreliable, the stub is permitted to resend a
stop reply notification if it believes GDB may not have received it.
GDB ignores additional stop reply notifications received before it has
finished processing a previous notification and the stub has completed
sending any queued stop events.
Otherwise, GDB must be prepared to receive a stop reply notification
at any time. Specifically, they may appear when GDB is not otherwise
reading input from the stub, or when GDB is expecting to read a normal
synchronous response or a `+'/`-' acknowledgment to a packet it has
sent. Notification packets are distinct from any other communication
from the stub so there is no ambiguity.
After receiving a stop reply notification, GDB shall acknowledge it
by sending a `vStopped' packet (*note vStopped packet::) as a regular,
synchronous request to the stub. Such acknowledgment is not required
to happen immediately, as GDB is permitted to send other, unrelated
packets to the stub first, which the stub should process normally.
Upon receiving a `vStopped' packet, if the stub has other queued
stop events to report to GDB, it shall respond by sending a normal stop
reply response. GDB shall then send another `vStopped' packet to
solicit further responses; again, it is permitted to send other,
unrelated packets as well which the stub should process normally.
If the stub receives a `vStopped' packet and there are no additional
stop events to report, the stub shall return an `OK' response. At this
point, if further stop events occur, the stub shall send a new stop
reply notification, GDB shall accept the notification, and the process
shall be repeated.
In non-stop mode, the target shall respond to the `?' packet as
follows. First, any incomplete stop reply notification/`vStopped'
sequence in progress is abandoned. The target must begin a new
sequence reporting stop events for all stopped threads, whether or not
it has previously reported those events to GDB. The first stop reply
is sent as a synchronous reply to the `?' packet, and subsequent stop
replies are sent as responses to `vStopped' packets using the mechanism
described above. The target must not send asynchronous stop reply
notifications until the sequence is complete. If all threads are
running when the target receives the `?' packet, or if the target is
not attached to any process, it shall respond `OK'.

File: gdb.info, Node: Packet Acknowledgment, Next: Examples, Prev: Remote Non-Stop, Up: Remote Protocol
E.11 Packet Acknowledgment
==========================
By default, 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). This mechanism allows the GDB remote protocol to
operate over unreliable transport mechanisms, such as a serial line.
In cases where the transport mechanism is itself reliable (such as a
pipe or TCP connection), the `+'/`-' acknowledgments are redundant. It
may be desirable to disable them in that case to reduce communication
overhead, or for other reasons. This can be accomplished by means of
the `QStartNoAckMode' packet; *note QStartNoAckMode::.
When in no-acknowledgment mode, neither the stub nor GDB shall send
or expect `+'/`-' protocol acknowledgments. The packet and response
format still includes the normal checksum, as described in *Note
Overview::, but the checksum may be ignored by the receiver.
If the stub supports `QStartNoAckMode' and prefers to operate in
no-acknowledgment mode, it should report that to GDB by including
`QStartNoAckMode+' in its response to `qSupported'; *note qSupported::.
If GDB also supports `QStartNoAckMode' and it has not been disabled via
the `set remote noack-packet off' command (*note Remote
Configuration::), GDB may then send a `QStartNoAckMode' packet to the
stub. Only then may the stub actually turn off packet acknowledgments.
GDB sends a final `+' acknowledgment of the stub's `OK' response, which
can be safely ignored by the stub.
Note that `set remote noack-packet' command only affects negotiation
between GDB and the stub when subsequent connections are made; it does
not affect the protocol acknowledgment state for any current connection.
Since `+'/`-' acknowledgments are enabled by default when a new
connection is established, there is also no protocol request to
re-enable the acknowledgments for the current connection, once disabled.

File: gdb.info, Node: Examples, Next: File-I/O Remote Protocol Extension, Prev: Packet Acknowledgment, Up: Remote Protocol
E.12 Examples
=============
Example sequence of a target being re-started. Notice how the restart
does not get any direct output:
-> `R00'
<- `+'
_target restarts_
-> `?'
<- `+'
<- `T001:1234123412341234'
-> `+'
Example sequence of a target being stepped by a single instruction:
-> `G1445...'
<- `+'
-> `s'
<- `+'
_time passes_
<- `T001:1234123412341234'
-> `+'
-> `g'
<- `+'
<- `1455...'
-> `+'

File: gdb.info, Node: File-I/O Remote Protocol Extension, Next: Library List Format, Prev: Examples, Up: Remote Protocol
E.13 File-I/O Remote Protocol Extension
=======================================
* Menu:
* File-I/O Overview::
* Protocol Basics::
* The F Request Packet::
* The F Reply Packet::
* The Ctrl-C Message::
* Console I/O::
* List of Supported Calls::
* Protocol-specific Representation of Datatypes::
* Constants::
* File-I/O Examples::

File: gdb.info, Node: File-I/O Overview, Next: Protocol Basics, Up: File-I/O Remote Protocol Extension
E.13.1 File-I/O Overview
------------------------
The "File I/O remote protocol extension" (short: File-I/O) allows the
target to use the host's file system and console I/O to perform various
system calls. System calls on the target system are translated into a
remote protocol packet to the host system, which then performs the
needed actions and returns a response packet to the target system.
This simulates file system operations even on targets that lack file
systems.
The protocol is defined to be independent of both the host and
target systems. It uses its own internal representation of datatypes
and values. Both GDB and the target's GDB stub are responsible for
translating the system-dependent value representations into the internal
protocol representations when data is transmitted.
The communication is synchronous. A system call is possible only
when GDB is waiting for a response from the `C', `c', `S' or `s'
packets. While GDB handles the request for a system call, the target
is stopped to allow deterministic access to the target's memory.
Therefore File-I/O is not interruptible by target signals. On the
other hand, it is possible to interrupt File-I/O by a user interrupt
(`Ctrl-C') within GDB.
The target's request to perform a host system call does not finish
the latest `C', `c', `S' or `s' action. That means, after finishing
the system call, the target returns to continuing the previous activity
(continue, step). No additional continue or step request from GDB is
required.
(gdb) continue
<- target requests 'system call X'
target is stopped, GDB executes system call
-> GDB returns result
... target continues, GDB returns to wait for the target
<- target hits breakpoint and sends a Txx packet
The protocol only supports I/O on the console and to regular files on
the host file system. Character or block special devices, pipes, named
pipes, sockets or any other communication method on the host system are
not supported by this protocol.
File I/O is not supported in non-stop mode.

File: gdb.info, Node: Protocol Basics, Next: The F Request Packet, Prev: File-I/O Overview, Up: File-I/O Remote Protocol Extension
E.13.2 Protocol Basics
----------------------
The File-I/O protocol uses the `F' packet as the request as well as
reply packet. Since a File-I/O system call can only occur when GDB is
waiting for a response from the continuing or stepping target, the
File-I/O request is a reply that GDB has to expect as a result of a
previous `C', `c', `S' or `s' packet. This `F' packet contains all
information needed to allow GDB to call the appropriate host system
call:
* A unique identifier for the requested system call.
* All parameters to the system call. Pointers are given as addresses
in the target memory address space. Pointers to strings are given
as pointer/length pair. Numerical values are given as they are.
Numerical control flags are given in a protocol-specific
representation.
At this point, GDB has to perform the following actions.
* If the parameters include pointer values to data needed as input
to a system call, GDB requests this data from the target with a
standard `m' packet request. This additional communication has to
be expected by the target implementation and is handled as any
other `m' packet.
* GDB translates all value from protocol representation to host
representation as needed. Datatypes are coerced into the host
types.
* GDB calls the system call.
* It then coerces datatypes back to protocol representation.
* If the system call is expected to return data in buffer space
specified by point