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-2021 Free Software Foundation, Inc.
4
5Permission is granted to copy, distribute and/or modify this document
6under the terms of the GNU Free Documentation License, Version 1.3 or
7any later version published by the Free Software Foundation; with the
8Invariant Sections being "Free Software" and "Free Software Needs
9Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
10and with the Back-Cover Texts as in (a) below.
11
12(a) The FSF's Back-Cover Text is: "You are free to copy and modify
13this GNU Manual.  Buying copies from GNU Press supports the FSF in
14developing GNU and promoting software freedom." -->
15<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
16<head>
17<title>Debugging with GDB: DJGPP Native</title>
18
19<meta name="description" content="Debugging with GDB: DJGPP Native">
20<meta name="keywords" content="Debugging with GDB: DJGPP Native">
21<meta name="resource-type" content="document">
22<meta name="distribution" content="global">
23<meta name="Generator" content="makeinfo">
24<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
25<link href="index.html#Top" rel="start" title="Top">
26<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
27<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
28<link href="Native.html#Native" rel="up" title="Native">
29<link href="Cygwin-Native.html#Cygwin-Native" rel="next" title="Cygwin Native">
30<link href="Process-Information.html#Process-Information" rel="previous" title="Process Information">
31<style type="text/css">
32<!--
33a.summary-letter {text-decoration: none}
34blockquote.smallquotation {font-size: smaller}
35div.display {margin-left: 3.2em}
36div.example {margin-left: 3.2em}
37div.indentedblock {margin-left: 3.2em}
38div.lisp {margin-left: 3.2em}
39div.smalldisplay {margin-left: 3.2em}
40div.smallexample {margin-left: 3.2em}
41div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
42div.smalllisp {margin-left: 3.2em}
43kbd {font-style:oblique}
44pre.display {font-family: inherit}
45pre.format {font-family: inherit}
46pre.menu-comment {font-family: serif}
47pre.menu-preformatted {font-family: serif}
48pre.smalldisplay {font-family: inherit; font-size: smaller}
49pre.smallexample {font-size: smaller}
50pre.smallformat {font-family: inherit; font-size: smaller}
51pre.smalllisp {font-size: smaller}
52span.nocodebreak {white-space:nowrap}
53span.nolinebreak {white-space:nowrap}
54span.roman {font-family:serif; font-weight:normal}
55span.sansserif {font-family:sans-serif; font-weight:normal}
56ul.no-bullet {list-style: none}
57-->
58</style>
59
60
61</head>
62
63<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
64<a name="DJGPP-Native"></a>
65<div class="header">
66<p>
67Next: <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>
68</div>
69<hr>
70<a name="Features-for-Debugging-DJGPP-Programs"></a>
71<h4 class="subsection">21.1.3 Features for Debugging <small>DJGPP</small> Programs</h4>
72<a name="index-DJGPP-debugging"></a>
73<a name="index-native-DJGPP-debugging"></a>
74<a name="index-MS_002dDOS_002dspecific-commands"></a>
75
76<a name="index-DPMI"></a>
77<p><small>DJGPP</small> is a port of the <small>GNU</small> development tools to MS-DOS and
78MS-Windows.  <small>DJGPP</small> programs are 32-bit protected-mode programs
79that use the <em>DPMI</em> (DOS Protected-Mode Interface) API to run on
80top of real-mode DOS systems and their emulations.
81</p>
82<p><small>GDB</small> supports native debugging of <small>DJGPP</small> programs, and
83defines a few commands specific to the <small>DJGPP</small> port.  This
84subsection describes those commands.
85</p>
86<dl compact="compact">
87<dd><a name="index-info-dos"></a>
88</dd>
89<dt><code>info dos</code></dt>
90<dd><p>This is a prefix of <small>DJGPP</small>-specific commands which print
91information about the target system and important OS structures.
92</p>
93<a name="index-sysinfo"></a>
94<a name="index-MS_002dDOS-system-info"></a>
95<a name="index-free-memory-information-_0028MS_002dDOS_0029"></a>
96</dd>
97<dt><code>info dos sysinfo</code></dt>
98<dd><p>This command displays assorted information about the underlying
99platform: the CPU type and features, the OS version and flavor, the
100DPMI version, and the available conventional and DPMI memory.
101</p>
102<a name="index-GDT"></a>
103<a name="index-LDT"></a>
104<a name="index-IDT"></a>
105<a name="index-segment-descriptor-tables"></a>
106<a name="index-descriptor-tables-display"></a>
107</dd>
108<dt><code>info dos gdt</code></dt>
109<dt><code>info dos ldt</code></dt>
110<dt><code>info dos idt</code></dt>
111<dd><p>These 3 commands display entries from, respectively, Global, Local,
112and Interrupt Descriptor Tables (GDT, LDT, and IDT).  The descriptor
113tables are data structures which store a descriptor for each segment
114that is currently in use.  The segment&rsquo;s selector is an index into a
115descriptor table; the table entry for that index holds the
116descriptor&rsquo;s base address and limit, and its attributes and access
117rights.
118</p>
119<p>A typical <small>DJGPP</small> program uses 3 segments: a code segment, a data
120segment (used for both data and the stack), and a DOS segment (which
121allows access to DOS/BIOS data structures and absolute addresses in
122conventional memory).  However, the DPMI host will usually define
123additional segments in order to support the DPMI environment.
124</p>
125<a name="index-garbled-pointers"></a>
126<p>These commands allow to display entries from the descriptor tables.
127Without an argument, all entries from the specified table are
128displayed.  An argument, which should be an integer expression, means
129display a single entry whose index is given by the argument.  For
130example, here&rsquo;s a convenient way to display information about the
131debugged program&rsquo;s data segment:
132</p>
133<div class="smallexample">
134<pre class="smallexample"><code>(gdb) info dos ldt $ds</code>
135</pre><pre class="smallexample"><code>0x13f: base=0x11970000 limit=0x0009ffff 32-Bit Data (Read/Write, Exp-up)</code>
136</pre></div>
137
138<p>This comes in handy when you want to see whether a pointer is outside
139the data segment&rsquo;s limit (i.e. <em>garbled</em>).
140</p>
141<a name="index-page-tables-display-_0028MS_002dDOS_0029"></a>
142</dd>
143<dt><code>info dos pde</code></dt>
144<dt><code>info dos pte</code></dt>
145<dd><p>These two commands display entries from, respectively, the Page
146Directory and the Page Tables.  Page Directories and Page Tables are
147data structures which control how virtual memory addresses are mapped
148into physical addresses.  A Page Table includes an entry for every
149page of memory that is mapped into the program&rsquo;s address space; there
150may be several Page Tables, each one holding up to 4096 entries.  A
151Page Directory has up to 4096 entries, one each for every Page Table
152that is currently in use.
153</p>
154<p>Without an argument, <kbd>info dos pde</kbd> displays the entire Page
155Directory, and <kbd>info dos pte</kbd> displays all the entries in all of
156the Page Tables.  An argument, an integer expression, given to the
157<kbd>info dos pde</kbd> command means display only that entry from the Page
158Directory table.  An argument given to the <kbd>info dos pte</kbd> command
159means display entries from a single Page Table, the one pointed to by
160the specified entry in the Page Directory.
161</p>
162<a name="index-direct-memory-access-_0028DMA_0029-on-MS_002dDOS"></a>
163<p>These commands are useful when your program uses <em>DMA</em> (Direct
164Memory Access), which needs physical addresses to program the DMA
165controller.
166</p>
167<p>These commands are supported only with some DPMI servers.
168</p>
169<a name="index-physical-address-from-linear-address"></a>
170</dd>
171<dt><code>info dos address-pte <var>addr</var></code></dt>
172<dd><p>This command displays the Page Table entry for a specified linear
173address.  The argument <var>addr</var> is a linear address which should
174already have the appropriate segment&rsquo;s base address added to it,
175because this command accepts addresses which may belong to <em>any</em>
176segment.  For example, here&rsquo;s how to display the Page Table entry for
177the page where a variable <code>i</code> is stored:
178</p>
179<div class="smallexample">
180<pre class="smallexample"><code>(gdb) info dos address-pte __djgpp_base_address + (char *)&amp;i</code>
181</pre><pre class="smallexample"><code>Page Table entry for address 0x11a00d30:</code>
182</pre><pre class="smallexample"><code>Base=0x02698000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0xd30</code>
183</pre></div>
184
185<p>This says that <code>i</code> is stored at offset <code>0xd30</code> from the page
186whose physical base address is <code>0x02698000</code>, and shows all the
187attributes of that page.
188</p>
189<p>Note that you must cast the addresses of variables to a <code>char *</code>,
190since otherwise the value of <code>__djgpp_base_address</code>, the base
191address of all variables and functions in a <small>DJGPP</small> program, will
192be added using the rules of C pointer arithmetics: if <code>i</code> is
193declared an <code>int</code>, <small>GDB</small> will add 4 times the value of
194<code>__djgpp_base_address</code> to the address of <code>i</code>.
195</p>
196<p>Here&rsquo;s another example, it displays the Page Table entry for the
197transfer buffer:
198</p>
199<div class="smallexample">
200<pre class="smallexample"><code>(gdb) info dos address-pte *((unsigned *)&amp;_go32_info_block + 3)</code>
201</pre><pre class="smallexample"><code>Page Table entry for address 0x29110:</code>
202</pre><pre class="smallexample"><code>Base=0x00029000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0x110</code>
203</pre></div>
204
205<p>(The <code>+ 3</code> offset is because the transfer buffer&rsquo;s address is the
2063rd member of the <code>_go32_info_block</code> structure.)  The output
207clearly shows that this DPMI server maps the addresses in conventional
208memory 1:1, i.e. the physical (<code>0x00029000</code> + <code>0x110</code>) and
209linear (<code>0x29110</code>) addresses are identical.
210</p>
211<p>This command is supported only with some DPMI servers.
212</p></dd>
213</dl>
214
215<a name="index-DOS-serial-data-link_002c-remote-debugging"></a>
216<p>In addition to native debugging, the DJGPP port supports remote
217debugging via a serial data link.  The following commands are specific
218to remote serial debugging in the DJGPP port of <small>GDB</small>.
219</p>
220<dl compact="compact">
221<dd><a name="index-set-com1base"></a>
222<a name="index-set-com1irq"></a>
223<a name="index-set-com2base"></a>
224<a name="index-set-com2irq"></a>
225<a name="index-set-com3base"></a>
226<a name="index-set-com3irq"></a>
227<a name="index-set-com4base"></a>
228<a name="index-set-com4irq"></a>
229</dd>
230<dt><code>set com1base <var>addr</var></code></dt>
231<dd><p>This command sets the base I/O port address of the <samp>COM1</samp> serial
232port.
233</p>
234</dd>
235<dt><code>set com1irq <var>irq</var></code></dt>
236<dd><p>This command sets the <em>Interrupt Request</em> (<code>IRQ</code>) line to use
237for the <samp>COM1</samp> serial port.
238</p>
239<p>There are similar commands &lsquo;<samp>set com2base</samp>&rsquo;, &lsquo;<samp>set com3irq</samp>&rsquo;,
240etc. for setting the port address and the <code>IRQ</code> lines for the
241other 3 COM ports.
242</p>
243<a name="index-show-com1base"></a>
244<a name="index-show-com1irq"></a>
245<a name="index-show-com2base"></a>
246<a name="index-show-com2irq"></a>
247<a name="index-show-com3base"></a>
248<a name="index-show-com3irq"></a>
249<a name="index-show-com4base"></a>
250<a name="index-show-com4irq"></a>
251<p>The related commands &lsquo;<samp>show com1base</samp>&rsquo;, &lsquo;<samp>show com1irq</samp>&rsquo; etc.
252display the current settings of the base address and the <code>IRQ</code>
253lines used by the COM ports.
254</p>
255</dd>
256<dt><code>info serial</code></dt>
257<dd><a name="index-info-serial"></a>
258<a name="index-DOS-serial-port-status"></a>
259<p>This command prints the status of the 4 DOS serial ports.  For each
260port, it prints whether it&rsquo;s active or not, its I/O base address and
261IRQ number, whether it uses a 16550-style FIFO, its baudrate, and the
262counts of various errors encountered so far.
263</p></dd>
264</dl>
265
266
267<hr>
268<div class="header">
269<p>
270Next: <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>
271</div>
272
273
274
275</body>
276</html>
277