選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

276 行
13KB

  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>DJGPP Native (Debugging with GDB)</title>
  17. <meta name="description" content="DJGPP Native (Debugging with GDB)">
  18. <meta name="keywords" content="DJGPP Native (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="Native.html#Native" rel="up" title="Native">
  26. <link href="Cygwin-Native.html#Cygwin-Native" rel="next" title="Cygwin Native">
  27. <link href="Process-Information.html#Process-Information" rel="prev" title="Process Information">
  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="DJGPP-Native"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Cygwin-Native.html#Cygwin-Native" accesskey="n" rel="next">Cygwin Native</a>, Previous: <a href="Process-Information.html#Process-Information" accesskey="p" rel="prev">Process Information</a>, Up: <a href="Native.html#Native" accesskey="u" rel="up">Native</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="Features-for-Debugging-DJGPP-Programs"></a>
  64. <h4 class="subsection">21.1.3 Features for Debugging <small>DJGPP</small> Programs</h4>
  65. <a name="index-DJGPP-debugging"></a>
  66. <a name="index-native-DJGPP-debugging"></a>
  67. <a name="index-MS_002dDOS_002dspecific-commands"></a>
  68. <a name="index-DPMI"></a>
  69. <p><small>DJGPP</small> is a port of the <small>GNU</small> development tools to MS-DOS and
  70. MS-Windows. <small>DJGPP</small> programs are 32-bit protected-mode programs
  71. that use the <em>DPMI</em> (DOS Protected-Mode Interface) API to run on
  72. top of real-mode DOS systems and their emulations.
  73. </p>
  74. <p><small>GDB</small> supports native debugging of <small>DJGPP</small> programs, and
  75. defines a few commands specific to the <small>DJGPP</small> port. This
  76. subsection describes those commands.
  77. </p>
  78. <dl compact="compact">
  79. <dd><a name="index-info-dos"></a>
  80. </dd>
  81. <dt><code>info dos</code></dt>
  82. <dd><p>This is a prefix of <small>DJGPP</small>-specific commands which print
  83. information about the target system and important OS structures.
  84. </p>
  85. <a name="index-sysinfo"></a>
  86. <a name="index-MS_002dDOS-system-info"></a>
  87. <a name="index-free-memory-information-_0028MS_002dDOS_0029"></a>
  88. </dd>
  89. <dt><code>info dos sysinfo</code></dt>
  90. <dd><p>This command displays assorted information about the underlying
  91. platform: the CPU type and features, the OS version and flavor, the
  92. DPMI version, and the available conventional and DPMI memory.
  93. </p>
  94. <a name="index-GDT"></a>
  95. <a name="index-LDT"></a>
  96. <a name="index-IDT"></a>
  97. <a name="index-segment-descriptor-tables"></a>
  98. <a name="index-descriptor-tables-display"></a>
  99. </dd>
  100. <dt><code>info dos gdt</code></dt>
  101. <dt><code>info dos ldt</code></dt>
  102. <dt><code>info dos idt</code></dt>
  103. <dd><p>These 3 commands display entries from, respectively, Global, Local,
  104. and Interrupt Descriptor Tables (GDT, LDT, and IDT). The descriptor
  105. tables are data structures which store a descriptor for each segment
  106. that is currently in use. The segment&rsquo;s selector is an index into a
  107. descriptor table; the table entry for that index holds the
  108. descriptor&rsquo;s base address and limit, and its attributes and access
  109. rights.
  110. </p>
  111. <p>A typical <small>DJGPP</small> program uses 3 segments: a code segment, a data
  112. segment (used for both data and the stack), and a DOS segment (which
  113. allows access to DOS/BIOS data structures and absolute addresses in
  114. conventional memory). However, the DPMI host will usually define
  115. additional segments in order to support the DPMI environment.
  116. </p>
  117. <a name="index-garbled-pointers"></a>
  118. <p>These commands allow to display entries from the descriptor tables.
  119. Without an argument, all entries from the specified table are
  120. displayed. An argument, which should be an integer expression, means
  121. display a single entry whose index is given by the argument. For
  122. example, here&rsquo;s a convenient way to display information about the
  123. debugged program&rsquo;s data segment:
  124. </p>
  125. <div class="smallexample">
  126. <pre class="smallexample"><code>(gdb) info dos ldt $ds</code>
  127. </pre><pre class="smallexample"><code>0x13f: base=0x11970000 limit=0x0009ffff 32-Bit Data (Read/Write, Exp-up)</code>
  128. </pre></div>
  129. <p>This comes in handy when you want to see whether a pointer is outside
  130. the data segment&rsquo;s limit (i.e. <em>garbled</em>).
  131. </p>
  132. <a name="index-page-tables-display-_0028MS_002dDOS_0029"></a>
  133. </dd>
  134. <dt><code>info dos pde</code></dt>
  135. <dt><code>info dos pte</code></dt>
  136. <dd><p>These two commands display entries from, respectively, the Page
  137. Directory and the Page Tables. Page Directories and Page Tables are
  138. data structures which control how virtual memory addresses are mapped
  139. into physical addresses. A Page Table includes an entry for every
  140. page of memory that is mapped into the program&rsquo;s address space; there
  141. may be several Page Tables, each one holding up to 4096 entries. A
  142. Page Directory has up to 4096 entries, one each for every Page Table
  143. that is currently in use.
  144. </p>
  145. <p>Without an argument, <kbd>info dos pde</kbd> displays the entire Page
  146. Directory, and <kbd>info dos pte</kbd> displays all the entries in all of
  147. the Page Tables. An argument, an integer expression, given to the
  148. <kbd>info dos pde</kbd> command means display only that entry from the Page
  149. Directory table. An argument given to the <kbd>info dos pte</kbd> command
  150. means display entries from a single Page Table, the one pointed to by
  151. the specified entry in the Page Directory.
  152. </p>
  153. <a name="index-direct-memory-access-_0028DMA_0029-on-MS_002dDOS"></a>
  154. <p>These commands are useful when your program uses <em>DMA</em> (Direct
  155. Memory Access), which needs physical addresses to program the DMA
  156. controller.
  157. </p>
  158. <p>These commands are supported only with some DPMI servers.
  159. </p>
  160. <a name="index-physical-address-from-linear-address"></a>
  161. </dd>
  162. <dt><code>info dos address-pte <var>addr</var></code></dt>
  163. <dd><p>This command displays the Page Table entry for a specified linear
  164. address. The argument <var>addr</var> is a linear address which should
  165. already have the appropriate segment&rsquo;s base address added to it,
  166. because this command accepts addresses which may belong to <em>any</em>
  167. segment. For example, here&rsquo;s how to display the Page Table entry for
  168. the page where a variable <code>i</code> is stored:
  169. </p>
  170. <div class="smallexample">
  171. <pre class="smallexample"><code>(gdb) info dos address-pte __djgpp_base_address + (char *)&amp;i</code>
  172. </pre><pre class="smallexample"><code>Page Table entry for address 0x11a00d30:</code>
  173. </pre><pre class="smallexample"><code>Base=0x02698000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0xd30</code>
  174. </pre></div>
  175. <p>This says that <code>i</code> is stored at offset <code>0xd30</code> from the page
  176. whose physical base address is <code>0x02698000</code>, and shows all the
  177. attributes of that page.
  178. </p>
  179. <p>Note that you must cast the addresses of variables to a <code>char *</code>,
  180. since otherwise the value of <code>__djgpp_base_address</code>, the base
  181. address of all variables and functions in a <small>DJGPP</small> program, will
  182. be added using the rules of C pointer arithmetics: if <code>i</code> is
  183. declared an <code>int</code>, <small>GDB</small> will add 4 times the value of
  184. <code>__djgpp_base_address</code> to the address of <code>i</code>.
  185. </p>
  186. <p>Here&rsquo;s another example, it displays the Page Table entry for the
  187. transfer buffer:
  188. </p>
  189. <div class="smallexample">
  190. <pre class="smallexample"><code>(gdb) info dos address-pte *((unsigned *)&amp;_go32_info_block + 3)</code>
  191. </pre><pre class="smallexample"><code>Page Table entry for address 0x29110:</code>
  192. </pre><pre class="smallexample"><code>Base=0x00029000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0x110</code>
  193. </pre></div>
  194. <p>(The <code>+ 3</code> offset is because the transfer buffer&rsquo;s address is the
  195. 3rd member of the <code>_go32_info_block</code> structure.) The output
  196. clearly shows that this DPMI server maps the addresses in conventional
  197. memory 1:1, i.e. the physical (<code>0x00029000</code> + <code>0x110</code>) and
  198. linear (<code>0x29110</code>) addresses are identical.
  199. </p>
  200. <p>This command is supported only with some DPMI servers.
  201. </p></dd>
  202. </dl>
  203. <a name="index-DOS-serial-data-link_002c-remote-debugging"></a>
  204. <p>In addition to native debugging, the DJGPP port supports remote
  205. debugging via a serial data link. The following commands are specific
  206. to remote serial debugging in the DJGPP port of <small>GDB</small>.
  207. </p>
  208. <dl compact="compact">
  209. <dd><a name="index-set-com1base"></a>
  210. <a name="index-set-com1irq"></a>
  211. <a name="index-set-com2base"></a>
  212. <a name="index-set-com2irq"></a>
  213. <a name="index-set-com3base"></a>
  214. <a name="index-set-com3irq"></a>
  215. <a name="index-set-com4base"></a>
  216. <a name="index-set-com4irq"></a>
  217. </dd>
  218. <dt><code>set com1base <var>addr</var></code></dt>
  219. <dd><p>This command sets the base I/O port address of the <samp>COM1</samp> serial
  220. port.
  221. </p>
  222. </dd>
  223. <dt><code>set com1irq <var>irq</var></code></dt>
  224. <dd><p>This command sets the <em>Interrupt Request</em> (<code>IRQ</code>) line to use
  225. for the <samp>COM1</samp> serial port.
  226. </p>
  227. <p>There are similar commands &lsquo;<samp>set com2base</samp>&rsquo;, &lsquo;<samp>set com3irq</samp>&rsquo;,
  228. etc. for setting the port address and the <code>IRQ</code> lines for the
  229. other 3 COM ports.
  230. </p>
  231. <a name="index-show-com1base"></a>
  232. <a name="index-show-com1irq"></a>
  233. <a name="index-show-com2base"></a>
  234. <a name="index-show-com2irq"></a>
  235. <a name="index-show-com3base"></a>
  236. <a name="index-show-com3irq"></a>
  237. <a name="index-show-com4base"></a>
  238. <a name="index-show-com4irq"></a>
  239. <p>The related commands &lsquo;<samp>show com1base</samp>&rsquo;, &lsquo;<samp>show com1irq</samp>&rsquo; etc.
  240. display the current settings of the base address and the <code>IRQ</code>
  241. lines used by the COM ports.
  242. </p>
  243. </dd>
  244. <dt><code>info serial</code></dt>
  245. <dd><a name="index-info-serial"></a>
  246. <a name="index-DOS-serial-port-status"></a>
  247. <p>This command prints the status of the 4 DOS serial ports. For each
  248. port, it prints whether it&rsquo;s active or not, its I/O base address and
  249. IRQ number, whether it uses a 16550-style FIFO, its baudrate, and the
  250. counts of various errors encountered so far.
  251. </p></dd>
  252. </dl>
  253. <hr>
  254. <div class="header">
  255. <p>
  256. Next: <a href="Cygwin-Native.html#Cygwin-Native" accesskey="n" rel="next">Cygwin Native</a>, Previous: <a href="Process-Information.html#Process-Information" accesskey="p" rel="prev">Process Information</a>, Up: <a href="Native.html#Native" accesskey="u" rel="up">Native</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>
  257. </div>
  258. </body>
  259. </html>