Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / mingw / info / gdb / DJGPP-Native.html
blob9d962ab1336e8ef1ba6c45879e2daef79fad9b44
1 <html lang="en">
2 <head>
3 <title>Debugging with GDB</title>
4 <meta http-equiv="Content-Type" content="text/html">
5 <meta name="description" content="Debugging with GDB">
6 <meta name="generator" content="makeinfo 4.3">
7 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home">
8 </head>
9 <body>
10 <div class="node">
11 <p>
12 Node:<a name="DJGPP%20Native">DJGPP Native</a>,
13 Next:<a rel="next" accesskey="n" href="Cygwin-Native.html#Cygwin%20Native">Cygwin Native</a>,
14 Previous:<a rel="previous" accesskey="p" href="SVR4-Process-Information.html#SVR4%20Process%20Information">SVR4 Process Information</a>,
15 Up:<a rel="up" accesskey="u" href="Native.html#Native">Native</a>
16 <hr><br>
17 </div>
19 <h4 class="subsection">Features for Debugging <small>DJGPP</small> Programs</h4>
21 <p><small>DJGPP</small> is the port of <small>GNU</small> development tools to MS-DOS and
22 MS-Windows. <small>DJGPP</small> programs are 32-bit protected-mode programs
23 that use the <dfn>DPMI</dfn> (DOS Protected-Mode Interface) API to run on
24 top of real-mode DOS systems and their emulations.
26 GDB supports native debugging of <small>DJGPP</small> programs, and
27 defines a few commands specific to the <small>DJGPP</small> port. This
28 subsection describes those commands.
30 <dl>
31 <dt><code>info dos</code>
32 <dd>This is a prefix of <small>DJGPP</small>-specific commands which print
33 information about the target system and important OS structures.
35 <br><dt><code>info dos sysinfo</code>
36 <dd>This command displays assorted information about the underlying
37 platform: the CPU type and features, the OS version and flavor, the
38 DPMI version, and the available conventional and DPMI memory.
40 <br><dt><code>info dos gdt</code>
41 <dd><dt><code>info dos ldt</code>
42 <dd><dt><code>info dos idt</code>
43 <dd>These 3 commands display entries from, respectively, Global, Local,
44 and Interrupt Descriptor Tables (GDT, LDT, and IDT). The descriptor
45 tables are data structures which store a descriptor for each segment
46 that is currently in use. The segment's selector is an index into a
47 descriptor table; the table entry for that index holds the
48 descriptor's base address and limit, and its attributes and access
49 rights.
51 <p>A typical <small>DJGPP</small> program uses 3 segments: a code segment, a data
52 segment (used for both data and the stack), and a DOS segment (which
53 allows access to DOS/BIOS data structures and absolute addresses in
54 conventional memory). However, the DPMI host will usually define
55 additional segments in order to support the DPMI environment.
57 <p>These commands allow to display entries from the descriptor tables.
58 Without an argument, all entries from the specified table are
59 displayed. An argument, which should be an integer expression, means
60 display a single entry whose index is given by the argument. For
61 example, here's a convenient way to display information about the
62 debugged program's data segment:
64 <pre class="smallexample"> <br><code>(gdb) info dos ldt $ds</code><br>
65 <br><code>0x13f: base=0x11970000 limit=0x0009ffff 32-Bit Data (Read/Write, Exp-up)</code><br>
66 </pre>
68 <p>This comes in handy when you want to see whether a pointer is outside
69 the data segment's limit (i.e. <dfn>garbled</dfn>).
71 <br><dt><code>info dos pde</code>
72 <dd><dt><code>info dos pte</code>
73 <dd>These two commands display entries from, respectively, the Page
74 Directory and the Page Tables. Page Directories and Page Tables are
75 data structures which control how virtual memory addresses are mapped
76 into physical addresses. A Page Table includes an entry for every
77 page of memory that is mapped into the program's address space; there
78 may be several Page Tables, each one holding up to 4096 entries. A
79 Page Directory has up to 4096 entries, one each for every Page Table
80 that is currently in use.
82 <p>Without an argument, <kbd>info dos pde</kbd> displays the entire Page
83 Directory, and <kbd>info dos pte</kbd> displays all the entries in all of
84 the Page Tables. An argument, an integer expression, given to the
85 <kbd>info dos pde</kbd> command means display only that entry from the Page
86 Directory table. An argument given to the <kbd>info dos pte</kbd> command
87 means display entries from a single Page Table, the one pointed to by
88 the specified entry in the Page Directory.
90 <p>These commands are useful when your program uses <dfn>DMA</dfn> (Direct
91 Memory Access), which needs physical addresses to program the DMA
92 controller.
94 <p>These commands are supported only with some DPMI servers.
96 <br><dt><code>info dos address-pte </code><var>addr</var><code></code>
97 <dd>This command displays the Page Table entry for a specified linear
98 address. The argument linear address <var>addr</var> should already have the
99 appropriate segment's base address added to it, because this command
100 accepts addresses which may belong to <em>any</em> segment. For
101 example, here's how to display the Page Table entry for the page where
102 the variable <code>i</code> is stored:
104 <pre class="smallexample"> <br><code>(gdb) info dos address-pte __djgpp_base_address + (char *)&amp;i</code><br>
105 <br><code>Page Table entry for address 0x11a00d30:</code><br>
106 <br><code>Base=0x02698000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0xd30</code><br>
107 </pre>
109 <p>This says that <code>i</code> is stored at offset <code>0xd30</code> from the page
110 whose physical base address is <code>0x02698000</code>, and prints all the
111 attributes of that page.
113 <p>Note that you must cast the addresses of variables to a <code>char *</code>,
114 since otherwise the value of <code>__djgpp_base_address</code>, the base
115 address of all variables and functions in a <small>DJGPP</small> program, will
116 be added using the rules of C pointer arithmetics: if <code>i</code> is
117 declared an <code>int</code>, GDB will add 4 times the value of
118 <code>__djgpp_base_address</code> to the address of <code>i</code>.
120 <p>Here's another example, it displays the Page Table entry for the
121 transfer buffer:
123 <pre class="smallexample"> <br><code>(gdb) info dos address-pte *((unsigned *)&amp;_go32_info_block + 3)</code><br>
124 <br><code>Page Table entry for address 0x29110:</code><br>
125 <br><code>Base=0x00029000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0x110</code><br>
126 </pre>
128 <p>(The <code>+ 3</code> offset is because the transfer buffer's address is the
129 3rd member of the <code>_go32_info_block</code> structure.) The output of
130 this command clearly shows that addresses in conventional memory are
131 mapped 1:1, i.e. the physical and linear addresses are identical.
133 <p>This command is supported only with some DPMI servers.
134 </dl>
136 </body></html>