No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

411 líneas
18KB

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