[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Warning: target descriptions are still under active development, and the contents and format may change between GDB releases. The format is expected to stabilize in the future.
One of the challenges of using GDB to debug embedded systems is that there are so many minor variants of each processor architecture in use. It is common practice for vendors to start with a standard processor core -- ARM, PowerPC, or MIPS, for example --- and then make changes to adapt it to a particular market niche. Some architectures have hundreds of variants, available from dozens of vendors. This leads to a number of problems:
set architecture
command can be error-prone.
To address these problems, the GDB remote protocol allows a target system to not only identify itself to GDB, but to actually describe its own features. This lets GDB support processor variants it has never seen before -- to the extent that the descriptions are accurate, and that GDB understands them.
GDB must be linked with the Expat library to support XML target descriptions. See Expat.
F.1 Retrieving Descriptions How descriptions are fetched from a target. F.2 Target Description Format The contents of a target description. F.3 Predefined Target Types Standard types available for target descriptions. F.4 Standard Target Features Features GDB knows about.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Target descriptions can be read from the target automatically, or specified by the user manually. The default behavior is to read the description from the target. GDB retrieves it via the remote protocol using `qXfer' requests (see section qXfer). The annex in the `qXfer' packet will be `target.xml'. The contents of the `target.xml' annex are an XML document, of the form described in F.2 Target Description Format.
Alternatively, you can specify a file to read for the target description. If a file is set, the target will not be queried. The commands to specify a file are:
set tdesc filename path
unset tdesc filename
show tdesc filename
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A target description annex is an XML
document which complies with the Document Type Definition provided in
the GDB sources in `gdb/features/gdb-target.dtd'. This
means you can use generally available tools like xmllint
to
check that your feature descriptions are well-formed and valid.
However, to help people unfamiliar with XML write descriptions for
their targets, we also describe the grammar here.
Target descriptions can identify the architecture of the remote target and (for some architectures) provide information about custom register sets. GDB can use this information to autoconfigure for your target, or to warn you if you connect to an unsupported target.
Here is a simple target description:
<target version="1.0"> <architecture>i386:x86-64</architecture> </target> |
This minimal description only says that the target uses the x86-64 architecture.
A target description has the following overall form, with [ ] marking optional elements and ... marking repeatable elements. The elements are explained further below.
<?xml version="1.0"?> <!DOCTYPE target SYSTEM "gdb-target.dtd"> <target version="1.0"> [architecture] [feature...] </target> |
The description is generally insensitive to whitespace and line breaks, under the usual common-sense rules. The XML version declaration and document type declaration can generally be omitted (GDB does not require them), but specifying them may be useful for XML validation tools. The `version' attribute for `<target>' may also be omitted, but we recommend including it; if future versions of GDB use an incompatible revision of `gdb-target.dtd', they will detect and report the version mismatch.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
It can sometimes be valuable to split a target description up into several different annexes, either for organizational purposes, or to share files between different possible target descriptions. You can divide a description into multiple files by replacing any element of the target description with an inclusion directive of the form:
<xi:include href="document"/> |
When GDB encounters an element of this form, it will retrieve the named XML document, and replace the inclusion directive with the contents of that document. If the current description was read using `qXfer', then so will be the included document; document will be interpreted as the name of an annex. If the current description was read from a file, GDB will look for document as a file in the same directory where it found the original description.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
An `<architecture>' element has this form:
<architecture>arch</architecture> |
arch is an architecture name from the same selection
accepted by set architecture
(see section Specifying a Debugging Target).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Each `<feature>' describes some logical portion of the target system. Features are currently used to describe available CPU registers and the types of their contents. A `<feature>' element has this form:
<feature name="name"> [type...] reg... </feature> |
Each feature's name should be unique within the description. The name of a feature does not matter unless GDB has some special knowledge of the contents of that feature; if it does, the feature should have its standard name. See section F.4 Standard Target Features.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Any register's value is a collection of bits which GDB must interpret. The default interpretation is a two's complement integer, but other types can be requested by name in the register description. Some predefined types are provided by GDB (see section F.3 Predefined Target Types), and the description can define additional composite types.
Each type element must have an `id' attribute, which gives a unique (within the containing `<feature>') name to the type. Types must be defined before they are used.
Some targets offer vector registers, which can be treated as arrays of scalar elements. These types are written as `<vector>' elements, specifying the array element type, type, and the number of elements, count:
<vector id="id" type="type" count="count"/> |
If a register's value is usefully viewed in multiple ways, define it with a union type containing the useful representations. The `<union>' element contains one or more `<field>' elements, each of which has a name and a type:
<union id="id"> <field name="name" type="type"/> ... </union> |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Each register is represented as an element with this form:
<reg name="name" bitsize="size" [regnum="num"] [save-restore="save-restore"] [type="type"] [group="group"]/> |
The components are as follows:
p
and P
packets, and registers appear in the g
and G
packets
in order of increasing register number.
yes
or no
. The default is
yes
, which is appropriate for most registers except for
some system control registers; this is not related to the target's
ABI.
int
and float
. int
is an integer type of the correct size
for bitsize, and float
is a floating point type (in the
architecture's normal floating point format) of the correct size for
bitsize. The default is int
.
general
, float
, or vector
. If no
group is specified, GDB will not display the register
in info registers
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Type definitions in the self-description can build up composite types from basic building blocks, but can not define fundamental types. Instead, standard identifiers are provided by GDB for the fundamental types. The currently supported types are:
int8
int16
int32
int64
int128
uint8
uint16
uint32
uint64
uint128
code_ptr
data_ptr
ieee_single
ieee_double
arm_fpa_ext
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A target description must contain either no registers or all the target's registers. If the description contains no registers, then GDB will assume a default register layout, selected based on the architecture. If the description contains any registers, the default layout will not be used; the standard registers must be described in the target description, in such a way that GDB can recognize them.
This is accomplished by giving specific names to feature elements which contain standard registers. GDB will look for features with those names and verify that they contain the expected registers; if any known feature is missing required registers, or if any required feature is missing, GDB will reject the target description. You can add additional registers to any of the standard features -- GDB will display them just as if they were added to an unrecognized feature.
This section lists the known features and their expected contents. Sample XML documents for these features are included in the GDB source tree, in the directory `gdb/features'.
Names recognized by GDB should include the name of the company or organization which selected the name, and the overall architecture to which the feature applies; so e.g. the feature containing ARM core registers is named `org.gnu.gdb.arm.core'.
The names of registers are not case sensitive for the purpose of recognizing standard features, but GDB will only display registers using the capitalization used in the description.
F.4.1 ARM Features F.4.2 MIPS Features F.4.3 M68K Features F.4.4 PowerPC Features
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The `org.gnu.gdb.arm.core' feature is required for ARM targets. It should contain registers `r0' through `r13', `sp', `lr', `pc', and `cpsr'.
The `org.gnu.gdb.arm.fpa' feature is optional. If present, it should contain registers `f0' through `f7' and `fps'.
The `org.gnu.gdb.xscale.iwmmxt' feature is optional. If present, it should contain at least registers `wR0' through `wR15' and `wCGR0' through `wCGR3'. The `wCID', `wCon', `wCSSF', and `wCASF' registers are optional.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The `org.gnu.gdb.mips.cpu' feature is required for MIPS targets. It should contain registers `r0' through `r31', `lo', `hi', and `pc'. They may be 32-bit or 64-bit depending on the target.
The `org.gnu.gdb.mips.cp0' feature is also required. It should contain at least the `status', `badvaddr', and `cause' registers. They may be 32-bit or 64-bit depending on the target.
The `org.gnu.gdb.mips.fpu' feature is currently required, though it may be optional in a future version of GDB. It should contain registers `f0' through `f31', `fcsr', and `fir'. They may be 32-bit or 64-bit depending on the target.
The `org.gnu.gdb.mips.linux' feature is optional. It should contain a single register, `restart', which is used by the Linux kernel to control restartable syscalls.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
`org.gnu.gdb.m68k.core'
`org.gnu.gdb.coldfire.core'
`org.gnu.gdb.fido.core'
`org.gnu.gdb.coldfire.fp'
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The `org.gnu.gdb.power.core' feature is required for PowerPC targets. It should contain registers `r0' through `r31', `pc', `msr', `cr', `lr', `ctr', and `xer'. They may be 32-bit or 64-bit depending on the target.
The `org.gnu.gdb.power.fpu' feature is optional. It should contain registers `f0' through `f31' and `fpscr'.
The `org.gnu.gdb.power.altivec' feature is optional. It should contain registers `vr0' through `vr31', `vscr', and `vrsave'.
The `org.gnu.gdb.power.spe' feature is optional. It should contain registers `ev0h' through `ev31h', `acc', and `spefscr'. SPE targets should provide 32-bit registers in `org.gnu.gdb.power.core' and provide the upper halves in `ev0h' through `ev31h'. GDB will combine these to present registers `ev0' through `ev31' to the user.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Please send FSF & GNU inquiries & questions to gnu@gnu.org. There are also other ways to contact the FSF.
These pages are maintained by the GDB developers.
Copyright Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.
This document was generated by GDB Administrator on March, 27 2008 using texi2html