Target-Description-Format.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Free Software" and "Free Software Needs
  8. Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
  9. and with the Back-Cover Texts as in (a) below.
  10. (a) The FSF's Back-Cover Text is: "You are free to copy and modify
  11. this GNU Manual. Buying copies from GNU Press supports the FSF in
  12. developing GNU and promoting software freedom." -->
  13. <!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <title>Debugging with GDB: Target Description Format</title>
  16. <meta name="description" content="Debugging with GDB: Target Description Format">
  17. <meta name="keywords" content="Debugging with GDB: Target Description Format">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  22. <link href="index.html#Top" rel="start" title="Top">
  23. <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
  24. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  25. <link href="Target-Descriptions.html#Target-Descriptions" rel="up" title="Target Descriptions">
  26. <link href="Predefined-Target-Types.html#Predefined-Target-Types" rel="next" title="Predefined Target Types">
  27. <link href="Retrieving-Descriptions.html#Retrieving-Descriptions" rel="previous" title="Retrieving Descriptions">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.smallquotation {font-size: smaller}
  32. div.display {margin-left: 3.2em}
  33. div.example {margin-left: 3.2em}
  34. div.indentedblock {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  38. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  39. div.smalllisp {margin-left: 3.2em}
  40. kbd {font-style:oblique}
  41. pre.display {font-family: inherit}
  42. pre.format {font-family: inherit}
  43. pre.menu-comment {font-family: serif}
  44. pre.menu-preformatted {font-family: serif}
  45. pre.smalldisplay {font-family: inherit; font-size: smaller}
  46. pre.smallexample {font-size: smaller}
  47. pre.smallformat {font-family: inherit; font-size: smaller}
  48. pre.smalllisp {font-size: smaller}
  49. span.nocodebreak {white-space:nowrap}
  50. span.nolinebreak {white-space:nowrap}
  51. span.roman {font-family:serif; font-weight:normal}
  52. span.sansserif {font-family:sans-serif; font-weight:normal}
  53. ul.no-bullet {list-style: none}
  54. -->
  55. </style>
  56. </head>
  57. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  58. <a name="Target-Description-Format"></a>
  59. <div class="header">
  60. <p>
  61. Next: <a href="Predefined-Target-Types.html#Predefined-Target-Types" accesskey="n" rel="next">Predefined Target Types</a>, Previous: <a href="Retrieving-Descriptions.html#Retrieving-Descriptions" accesskey="p" rel="previous">Retrieving Descriptions</a>, Up: <a href="Target-Descriptions.html#Target-Descriptions" accesskey="u" rel="up">Target Descriptions</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
  62. </div>
  63. <hr>
  64. <a name="Target-Description-Format-1"></a>
  65. <h3 class="section">G.2 Target Description Format</h3>
  66. <a name="index-target-descriptions_002c-XML-format"></a>
  67. <p>A target description annex is an <a href="http://www.w3.org/XML/">XML</a>
  68. document which complies with the Document Type Definition provided in
  69. the <small>GDB</small> sources in <samp>gdb/features/gdb-target.dtd</samp>. This
  70. means you can use generally available tools like <code>xmllint</code> to
  71. check that your feature descriptions are well-formed and valid.
  72. However, to help people unfamiliar with XML write descriptions for
  73. their targets, we also describe the grammar here.
  74. </p>
  75. <p>Target descriptions can identify the architecture of the remote target
  76. and (for some architectures) provide information about custom register
  77. sets. They can also identify the OS ABI of the remote target.
  78. <small>GDB</small> can use this information to autoconfigure for your
  79. target, or to warn you if you connect to an unsupported target.
  80. </p>
  81. <p>Here is a simple target description:
  82. </p>
  83. <div class="smallexample">
  84. <pre class="smallexample">&lt;target version=&quot;1.0&quot;&gt;
  85. &lt;architecture&gt;i386:x86-64&lt;/architecture&gt;
  86. &lt;/target&gt;
  87. </pre></div>
  88. <p>This minimal description only says that the target uses
  89. the x86-64 architecture.
  90. </p>
  91. <p>A target description has the following overall form, with [ ] marking
  92. optional elements and &hellip; marking repeatable elements. The elements
  93. are explained further below.
  94. </p>
  95. <div class="smallexample">
  96. <pre class="smallexample">&lt;?xml version=&quot;1.0&quot;?&gt;
  97. &lt;!DOCTYPE target SYSTEM &quot;gdb-target.dtd&quot;&gt;
  98. &lt;target version=&quot;1.0&quot;&gt;
  99. <span class="roman">[</span><var>architecture</var><span class="roman">]</span>
  100. <span class="roman">[</span><var>osabi</var><span class="roman">]</span>
  101. <span class="roman">[</span><var>compatible</var><span class="roman">]</span>
  102. <span class="roman">[</span><var>feature</var>&hellip;<span class="roman">]</span>
  103. &lt;/target&gt;
  104. </pre></div>
  105. <p>The description is generally insensitive to whitespace and line
  106. breaks, under the usual common-sense rules. The XML version
  107. declaration and document type declaration can generally be omitted
  108. (<small>GDB</small> does not require them), but specifying them may be
  109. useful for XML validation tools. The &lsquo;<samp>version</samp>&rsquo; attribute for
  110. &lsquo;<samp>&lt;target&gt;</samp>&rsquo; may also be omitted, but we recommend
  111. including it; if future versions of <small>GDB</small> use an incompatible
  112. revision of <samp>gdb-target.dtd</samp>, they will detect and report
  113. the version mismatch.
  114. </p>
  115. <a name="Inclusion"></a>
  116. <h4 class="subsection">G.2.1 Inclusion</h4>
  117. <a name="index-target-descriptions_002c-inclusion"></a>
  118. <a name="index-XInclude"></a>
  119. <a name="index-_003cxi_003ainclude_003e"></a>
  120. <p>It can sometimes be valuable to split a target description up into
  121. several different annexes, either for organizational purposes, or to
  122. share files between different possible target descriptions. You can
  123. divide a description into multiple files by replacing any element of
  124. the target description with an inclusion directive of the form:
  125. </p>
  126. <div class="smallexample">
  127. <pre class="smallexample">&lt;xi:include href=&quot;<var>document</var>&quot;/&gt;
  128. </pre></div>
  129. <p>When <small>GDB</small> encounters an element of this form, it will retrieve
  130. the named XML <var>document</var>, and replace the inclusion directive with
  131. the contents of that document. If the current description was read
  132. using &lsquo;<samp>qXfer</samp>&rsquo;, then so will be the included document;
  133. <var>document</var> will be interpreted as the name of an annex. If the
  134. current description was read from a file, <small>GDB</small> will look for
  135. <var>document</var> as a file in the same directory where it found the
  136. original description.
  137. </p>
  138. <a name="Architecture"></a>
  139. <h4 class="subsection">G.2.2 Architecture</h4>
  140. <a name="index-_003carchitecture_003e"></a>
  141. <p>An &lsquo;<samp>&lt;architecture&gt;</samp>&rsquo; element has this form:
  142. </p>
  143. <div class="smallexample">
  144. <pre class="smallexample"> &lt;architecture&gt;<var>arch</var>&lt;/architecture&gt;
  145. </pre></div>
  146. <p><var>arch</var> is one of the architectures from the set accepted by
  147. <code>set architecture</code> (see <a href="Targets.html#Targets">Specifying a Debugging Target</a>).
  148. </p>
  149. <a name="OS-ABI"></a>
  150. <h4 class="subsection">G.2.3 OS ABI</h4>
  151. <a name="index-_003cosabi_003e"></a>
  152. <p>This optional field was introduced in <small>GDB</small> version 7.0.
  153. Previous versions of <small>GDB</small> ignore it.
  154. </p>
  155. <p>An &lsquo;<samp>&lt;osabi&gt;</samp>&rsquo; element has this form:
  156. </p>
  157. <div class="smallexample">
  158. <pre class="smallexample"> &lt;osabi&gt;<var>abi-name</var>&lt;/osabi&gt;
  159. </pre></div>
  160. <p><var>abi-name</var> is an OS ABI name from the same selection accepted by
  161. <code>set&nbsp;osabi</code><!-- /@w --> (see <a href="ABI.html#ABI">Configuring the Current ABI</a>).
  162. </p>
  163. <a name="Compatible-Architecture"></a>
  164. <h4 class="subsection">G.2.4 Compatible Architecture</h4>
  165. <a name="index-_003ccompatible_003e"></a>
  166. <p>This optional field was introduced in <small>GDB</small> version 7.0.
  167. Previous versions of <small>GDB</small> ignore it.
  168. </p>
  169. <p>A &lsquo;<samp>&lt;compatible&gt;</samp>&rsquo; element has this form:
  170. </p>
  171. <div class="smallexample">
  172. <pre class="smallexample"> &lt;compatible&gt;<var>arch</var>&lt;/compatible&gt;
  173. </pre></div>
  174. <p><var>arch</var> is one of the architectures from the set accepted by
  175. <code>set architecture</code> (see <a href="Targets.html#Targets">Specifying a Debugging Target</a>).
  176. </p>
  177. <p>A &lsquo;<samp>&lt;compatible&gt;</samp>&rsquo; element is used to specify that the target
  178. is able to run binaries in some other than the main target architecture
  179. given by the &lsquo;<samp>&lt;architecture&gt;</samp>&rsquo; element. For example, on the
  180. Cell Broadband Engine, the main architecture is <code>powerpc:common</code>
  181. or <code>powerpc:common64</code>, but the system is able to run binaries
  182. in the <code>spu</code> architecture as well. The way to describe this
  183. capability with &lsquo;<samp>&lt;compatible&gt;</samp>&rsquo; is as follows:
  184. </p>
  185. <div class="smallexample">
  186. <pre class="smallexample"> &lt;architecture&gt;powerpc:common&lt;/architecture&gt;
  187. &lt;compatible&gt;spu&lt;/compatible&gt;
  188. </pre></div>
  189. <a name="Features"></a>
  190. <h4 class="subsection">G.2.5 Features</h4>
  191. <a name="index-_003cfeature_003e"></a>
  192. <p>Each &lsquo;<samp>&lt;feature&gt;</samp>&rsquo; describes some logical portion of the target
  193. system. Features are currently used to describe available CPU
  194. registers and the types of their contents. A &lsquo;<samp>&lt;feature&gt;</samp>&rsquo; element
  195. has this form:
  196. </p>
  197. <div class="smallexample">
  198. <pre class="smallexample">&lt;feature name=&quot;<var>name</var>&quot;&gt;
  199. <span class="roman">[</span><var>type</var>&hellip;<span class="roman">]</span>
  200. <var>reg</var>&hellip;
  201. &lt;/feature&gt;
  202. </pre></div>
  203. <p>Each feature&rsquo;s name should be unique within the description. The name
  204. of a feature does not matter unless <small>GDB</small> has some special
  205. knowledge of the contents of that feature; if it does, the feature
  206. should have its standard name. See <a href="Standard-Target-Features.html#Standard-Target-Features">Standard Target Features</a>.
  207. </p>
  208. <a name="Types"></a>
  209. <h4 class="subsection">G.2.6 Types</h4>
  210. <p>Any register&rsquo;s value is a collection of bits which <small>GDB</small> must
  211. interpret. The default interpretation is a two&rsquo;s complement integer,
  212. but other types can be requested by name in the register description.
  213. Some predefined types are provided by <small>GDB</small> (see <a href="Predefined-Target-Types.html#Predefined-Target-Types">Predefined Target Types</a>), and the description can define additional composite
  214. and enum types.
  215. </p>
  216. <p>Each type element must have an &lsquo;<samp>id</samp>&rsquo; attribute, which gives
  217. a unique (within the containing &lsquo;<samp>&lt;feature&gt;</samp>&rsquo;) name to the type.
  218. Types must be defined before they are used.
  219. </p>
  220. <a name="index-_003cvector_003e"></a>
  221. <p>Some targets offer vector registers, which can be treated as arrays
  222. of scalar elements. These types are written as &lsquo;<samp>&lt;vector&gt;</samp>&rsquo; elements,
  223. specifying the array element type, <var>type</var>, and the number of elements,
  224. <var>count</var>:
  225. </p>
  226. <div class="smallexample">
  227. <pre class="smallexample">&lt;vector id=&quot;<var>id</var>&quot; type=&quot;<var>type</var>&quot; count=&quot;<var>count</var>&quot;/&gt;
  228. </pre></div>
  229. <a name="index-_003cunion_003e"></a>
  230. <p>If a register&rsquo;s value is usefully viewed in multiple ways, define it
  231. with a union type containing the useful representations. The
  232. &lsquo;<samp>&lt;union&gt;</samp>&rsquo; element contains one or more &lsquo;<samp>&lt;field&gt;</samp>&rsquo; elements,
  233. each of which has a <var>name</var> and a <var>type</var>:
  234. </p>
  235. <div class="smallexample">
  236. <pre class="smallexample">&lt;union id=&quot;<var>id</var>&quot;&gt;
  237. &lt;field name=&quot;<var>name</var>&quot; type=&quot;<var>type</var>&quot;/&gt;
  238. &hellip;
  239. &lt;/union&gt;
  240. </pre></div>
  241. <a name="index-_003cstruct_003e"></a>
  242. <a name="index-_003cflags_003e"></a>
  243. <p>If a register&rsquo;s value is composed from several separate values, define
  244. it with either a structure type or a flags type.
  245. A flags type may only contain bitfields.
  246. A structure type may either contain only bitfields or contain no bitfields.
  247. If the value contains only bitfields, its total size in bytes must be
  248. specified.
  249. </p>
  250. <p>Non-bitfield values have a <var>name</var> and <var>type</var>.
  251. </p>
  252. <div class="smallexample">
  253. <pre class="smallexample">&lt;struct id=&quot;<var>id</var>&quot;&gt;
  254. &lt;field name=&quot;<var>name</var>&quot; type=&quot;<var>type</var>&quot;/&gt;
  255. &hellip;
  256. &lt;/struct&gt;
  257. </pre></div>
  258. <p>Both <var>name</var> and <var>type</var> values are required.
  259. No implicit padding is added.
  260. </p>
  261. <p>Bitfield values have a <var>name</var>, <var>start</var>, <var>end</var> and <var>type</var>.
  262. </p>
  263. <div class="smallexample">
  264. <pre class="smallexample">&lt;struct id=&quot;<var>id</var>&quot; size=&quot;<var>size</var>&quot;&gt;
  265. &lt;field name=&quot;<var>name</var>&quot; start=&quot;<var>start</var>&quot; end=&quot;<var>end</var>&quot; type=&quot;<var>type</var>&quot;/&gt;
  266. &hellip;
  267. &lt;/struct&gt;
  268. </pre></div>
  269. <div class="smallexample">
  270. <pre class="smallexample">&lt;flags id=&quot;<var>id</var>&quot; size=&quot;<var>size</var>&quot;&gt;
  271. &lt;field name=&quot;<var>name</var>&quot; start=&quot;<var>start</var>&quot; end=&quot;<var>end</var>&quot; type=&quot;<var>type</var>&quot;/&gt;
  272. &hellip;
  273. &lt;/flags&gt;
  274. </pre></div>
  275. <p>The <var>name</var> value is required.
  276. Bitfield values may be named with the empty string, &lsquo;<samp>&quot;&quot;</samp>&rsquo;,
  277. in which case the field is &ldquo;filler&rdquo; and its value is not printed.
  278. Not all bits need to be specified, so &ldquo;filler&rdquo; fields are optional.
  279. </p>
  280. <p>The <var>start</var> and <var>end</var> values are required, and <var>type</var>
  281. is optional.
  282. The field&rsquo;s <var>start</var> must be less than or equal to its <var>end</var>,
  283. and zero represents the least significant bit.
  284. </p>
  285. <p>The default value of <var>type</var> is <code>bool</code> for single bit fields,
  286. and an unsigned integer otherwise.
  287. </p>
  288. <p>Which to choose? Structures or flags?
  289. </p>
  290. <p>Registers defined with &lsquo;<samp>flags</samp>&rsquo; have these advantages over
  291. defining them with &lsquo;<samp>struct</samp>&rsquo;:
  292. </p>
  293. <ul>
  294. <li> Arithmetic may be performed on them as if they were integers.
  295. </li><li> They are printed in a more readable fashion.
  296. </li></ul>
  297. <p>Registers defined with &lsquo;<samp>struct</samp>&rsquo; have one advantage over
  298. defining them with &lsquo;<samp>flags</samp>&rsquo;:
  299. </p>
  300. <ul>
  301. <li> One can fetch individual fields like in &lsquo;<samp>C</samp>&rsquo;.
  302. <div class="smallexample">
  303. <pre class="smallexample">(gdb) print $my_struct_reg.field3
  304. $1 = 42
  305. </pre></div>
  306. </li></ul>
  307. <a name="Registers-2"></a>
  308. <h4 class="subsection">G.2.7 Registers</h4>
  309. <a name="index-_003creg_003e"></a>
  310. <p>Each register is represented as an element with this form:
  311. </p>
  312. <div class="smallexample">
  313. <pre class="smallexample">&lt;reg name=&quot;<var>name</var>&quot;
  314. bitsize=&quot;<var>size</var>&quot;
  315. <span class="roman">[</span>regnum=&quot;<var>num</var>&quot;<span class="roman">]</span>
  316. <span class="roman">[</span>save-restore=&quot;<var>save-restore</var>&quot;<span class="roman">]</span>
  317. <span class="roman">[</span>type=&quot;<var>type</var>&quot;<span class="roman">]</span>
  318. <span class="roman">[</span>group=&quot;<var>group</var>&quot;<span class="roman">]</span>/&gt;
  319. </pre></div>
  320. <p>The components are as follows:
  321. </p>
  322. <dl compact="compact">
  323. <dt><var>name</var></dt>
  324. <dd><p>The register&rsquo;s name; it must be unique within the target description.
  325. </p>
  326. </dd>
  327. <dt><var>bitsize</var></dt>
  328. <dd><p>The register&rsquo;s size, in bits.
  329. </p>
  330. </dd>
  331. <dt><var>regnum</var></dt>
  332. <dd><p>The register&rsquo;s number. If omitted, a register&rsquo;s number is one greater
  333. than that of the previous register (either in the current feature or in
  334. a preceding feature); the first register in the target description
  335. defaults to zero. This register number is used to read or write
  336. the register; e.g. it is used in the remote <code>p</code> and <code>P</code>
  337. packets, and registers appear in the <code>g</code> and <code>G</code> packets
  338. in order of increasing register number.
  339. </p>
  340. </dd>
  341. <dt><var>save-restore</var></dt>
  342. <dd><p>Whether the register should be preserved across inferior function
  343. calls; this must be either <code>yes</code> or <code>no</code>. The default is
  344. <code>yes</code>, which is appropriate for most registers except for
  345. some system control registers; this is not related to the target&rsquo;s
  346. ABI.
  347. </p>
  348. </dd>
  349. <dt><var>type</var></dt>
  350. <dd><p>The type of the register. It may be a predefined type, a type
  351. defined in the current feature, or one of the special types <code>int</code>
  352. and <code>float</code>. <code>int</code> is an integer type of the correct size
  353. for <var>bitsize</var>, and <code>float</code> is a floating point type (in the
  354. architecture&rsquo;s normal floating point format) of the correct size for
  355. <var>bitsize</var>. The default is <code>int</code>.
  356. </p>
  357. </dd>
  358. <dt><var>group</var></dt>
  359. <dd><p>The register group to which this register belongs. It can be one of the
  360. standard register groups <code>general</code>, <code>float</code>, <code>vector</code> or an
  361. arbitrary string. Group names should be limited to alphanumeric characters.
  362. If a group name is made up of multiple words the words may be separated by
  363. hyphens; e.g. <code>special-group</code> or <code>ultra-special-group</code>. If no
  364. <var>group</var> is specified, <small>GDB</small> will not display the register in
  365. <code>info registers</code>.
  366. </p>
  367. </dd>
  368. </dl>
  369. <hr>
  370. <div class="header">
  371. <p>
  372. Next: <a href="Predefined-Target-Types.html#Predefined-Target-Types" accesskey="n" rel="next">Predefined Target Types</a>, Previous: <a href="Retrieving-Descriptions.html#Retrieving-Descriptions" accesskey="p" rel="previous">Retrieving Descriptions</a>, Up: <a href="Target-Descriptions.html#Target-Descriptions" accesskey="u" rel="up">Target Descriptions</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
  373. </div>
  374. </body>
  375. </html>