Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

195 lines
9.1KB

  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>i386 (Debugging with GDB)</title>
  17. <meta name="description" content="i386 (Debugging with GDB)">
  18. <meta name="keywords" content="i386 (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="Architectures.html#Architectures" rel="up" title="Architectures">
  26. <link href="Alpha.html#Alpha" rel="next" title="Alpha">
  27. <link href="AArch64.html#AArch64" rel="prev" title="AArch64">
  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="i386"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Alpha.html#Alpha" accesskey="n" rel="next">Alpha</a>, Previous: <a href="AArch64.html#AArch64" accesskey="p" rel="prev">AArch64</a>, Up: <a href="Architectures.html#Architectures" accesskey="u" rel="up">Architectures</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="x86-Architecture_002dspecific-Issues"></a>
  64. <h4 class="subsection">21.4.2 x86 Architecture-specific Issues</h4>
  65. <dl compact="compact">
  66. <dt><code>set struct-convention <var>mode</var></code></dt>
  67. <dd><a name="index-set-struct_002dconvention"></a>
  68. <a name="index-struct-return-convention"></a>
  69. <a name="index-struct_002funion-returned-in-registers"></a>
  70. <p>Set the convention used by the inferior to return <code>struct</code>s and
  71. <code>union</code>s from functions to <var>mode</var>. Possible values of
  72. <var>mode</var> are <code>&quot;pcc&quot;</code>, <code>&quot;reg&quot;</code>, and <code>&quot;default&quot;</code> (the
  73. default). <code>&quot;default&quot;</code> or <code>&quot;pcc&quot;</code> means that <code>struct</code>s
  74. are returned on the stack, while <code>&quot;reg&quot;</code> means that a
  75. <code>struct</code> or a <code>union</code> whose size is 1, 2, 4, or 8 bytes will
  76. be returned in a register.
  77. </p>
  78. </dd>
  79. <dt><code>show struct-convention</code></dt>
  80. <dd><a name="index-show-struct_002dconvention"></a>
  81. <p>Show the current setting of the convention to return <code>struct</code>s
  82. from functions.
  83. </p></dd>
  84. </dl>
  85. <a name="Intel-Memory-Protection-Extensions-_0028MPX_0029_002e"></a>
  86. <h4 class="subsubsection">21.4.2.1 Intel <em>Memory Protection Extensions</em> (MPX).</h4>
  87. <a name="index-Intel-Memory-Protection-Extensions-_0028MPX_0029_002e"></a>
  88. <p>Memory Protection Extension (MPX) adds the bound registers &lsquo;<samp>BND0</samp>&rsquo;
  89. <a name="DOCF17" href="#FOOT17"><sup>17</sup></a> through &lsquo;<samp>BND3</samp>&rsquo;. Bound registers store a pair of 64-bit values
  90. which are the lower bound and upper bound. Bounds are effective addresses or
  91. memory locations. The upper bounds are architecturally represented in 1&rsquo;s
  92. complement form. A bound having lower bound = 0, and upper bound = 0
  93. (1&rsquo;s complement of all bits set) will allow access to the entire address space.
  94. </p>
  95. <p>&lsquo;<samp>BND0</samp>&rsquo; through &lsquo;<samp>BND3</samp>&rsquo; are represented in <small>GDB</small> as &lsquo;<samp>bnd0raw</samp>&rsquo;
  96. through &lsquo;<samp>bnd3raw</samp>&rsquo;. Pseudo registers &lsquo;<samp>bnd0</samp>&rsquo; through &lsquo;<samp>bnd3</samp>&rsquo;
  97. display the upper bound performing the complement of one operation on the
  98. upper bound value, i.e.&nbsp;when upper bound in &lsquo;<samp>bnd0raw</samp>&rsquo; is 0 in the
  99. <small>GDB</small> &lsquo;<samp>bnd0</samp>&rsquo; it will be <code>0xfff&hellip;</code>. In this sense it
  100. can also be noted that the upper bounds are inclusive.
  101. </p>
  102. <p>As an example, assume that the register BND0 holds bounds for a pointer having
  103. access allowed for the range between 0x32 and 0x71. The values present on
  104. bnd0raw and bnd registers are presented as follows:
  105. </p>
  106. <div class="smallexample">
  107. <pre class="smallexample"> bnd0raw = {0x32, 0xffffffff8e}
  108. bnd0 = {lbound = 0x32, ubound = 0x71} : size 64
  109. </pre></div>
  110. <p>This way the raw value can be accessed via bnd0raw&hellip;bnd3raw. Any
  111. change on bnd0&hellip;bnd3 or bnd0raw&hellip;bnd3raw is reflect on its
  112. counterpart. When the bnd0&hellip;bnd3 registers are displayed via
  113. Python, the display includes the memory size, in bits, accessible to
  114. the pointer.
  115. </p>
  116. <p>Bounds can also be stored in bounds tables, which are stored in
  117. application memory. These tables store bounds for pointers by specifying
  118. the bounds pointer&rsquo;s value along with its bounds. Evaluating and changing
  119. bounds located in bound tables is therefore interesting while investigating
  120. bugs on MPX context. <small>GDB</small> provides commands for this purpose:
  121. </p>
  122. <dl compact="compact">
  123. <dt><code>show mpx bound <var>pointer</var></code></dt>
  124. <dd><a name="index-show-mpx-bound"></a>
  125. <p>Display bounds of the given <var>pointer</var>.
  126. </p>
  127. </dd>
  128. <dt><code>set mpx bound <var>pointer</var>, <var>lbound</var>, <var>ubound</var></code></dt>
  129. <dd><a name="index-set-mpx-bound"></a>
  130. <p>Set the bounds of a pointer in the bound table.
  131. This command takes three parameters: <var>pointer</var> is the pointers
  132. whose bounds are to be changed, <var>lbound</var> and <var>ubound</var> are new values
  133. for lower and upper bounds respectively.
  134. </p></dd>
  135. </dl>
  136. <p>When you call an inferior function on an Intel MPX enabled program,
  137. GDB sets the inferior&rsquo;s bound registers to the init (disabled) state
  138. before calling the function. As a consequence, bounds checks for the
  139. pointer arguments passed to the function will always pass.
  140. </p>
  141. <p>This is necessary because when you call an inferior function, the
  142. program is usually in the middle of the execution of other function.
  143. Since at that point bound registers are in an arbitrary state, not
  144. clearing them would lead to random bound violations in the called
  145. function.
  146. </p>
  147. <p>You can still examine the influence of the bound registers on the
  148. execution of the called function by stopping the execution of the
  149. called function at its prologue, setting bound registers, and
  150. continuing the execution. For example:
  151. </p>
  152. <div class="smallexample">
  153. <pre class="smallexample"> $ break *upper
  154. Breakpoint 2 at 0x4009de: file i386-mpx-call.c, line 47.
  155. $ print upper (a, b, c, d, 1)
  156. Breakpoint 2, upper (a=0x0, b=0x6e0000005b, c=0x0, d=0x0, len=48)....
  157. $ print $bnd0
  158. {lbound = 0x0, ubound = ffffffff} : size -1
  159. </pre></div>
  160. <p>At this last step the value of bnd0 can be changed for investigation of bound
  161. violations caused along the execution of the call. In order to know how to
  162. set the bound registers or bound table for the call consult the ABI.
  163. </p>
  164. <div class="footnote">
  165. <hr>
  166. <h4 class="footnotes-heading">Footnotes</h4>
  167. <h3><a name="FOOT17" href="#DOCF17">(17)</a></h3>
  168. <p>The register named with capital letters represent the architecture
  169. registers.</p>
  170. </div>
  171. <hr>
  172. <div class="header">
  173. <p>
  174. Next: <a href="Alpha.html#Alpha" accesskey="n" rel="next">Alpha</a>, Previous: <a href="AArch64.html#AArch64" accesskey="p" rel="prev">AArch64</a>, Up: <a href="Architectures.html#Architectures" accesskey="u" rel="up">Architectures</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>
  175. </div>
  176. </body>
  177. </html>