DJGPP-Native.html 13 KB

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