djgpp is a port of the gnu development tools to MS-DOS and MS-Windows. djgpp programs are 32-bit protected-mode programs that use the DPMI (DOS Protected-Mode Interface) API to run on top of real-mode DOS systems and their emulations.
gdb supports native debugging of djgpp programs, and defines a few commands specific to the djgpp port. This subsection describes those commands.
info dos sysinfo
info dos gdt
info dos ldt
info dos idt
A typical djgpp program uses 3 segments: a code segment, a data segment (used for both data and the stack), and a DOS segment (which allows access to DOS/BIOS data structures and absolute addresses in conventional memory). However, the DPMI host will usually define additional segments in order to support the DPMI environment.
These commands allow to display entries from the descriptor tables. Without an argument, all entries from the specified table are displayed. An argument, which should be an integer expression, means display a single entry whose index is given by the argument. For example, here's a convenient way to display information about the debugged program's data segment:
(gdb) info dos ldt $ds
0x13f: base=0x11970000 limit=0x0009ffff 32-Bit Data (Read/Write, Exp-up)
This comes in handy when you want to see whether a pointer is outside the data segment's limit (i.e. garbled).
info dos pde
info dos pte
Without an argument, info dos pde displays the entire Page Directory, and info dos pte displays all the entries in all of the Page Tables. An argument, an integer expression, given to the info dos pde command means display only that entry from the Page Directory table. An argument given to the info dos pte command means display entries from a single Page Table, the one pointed to by the specified entry in the Page Directory.
These commands are useful when your program uses DMA (Direct Memory Access), which needs physical addresses to program the DMA controller.
These commands are supported only with some DPMI servers.
info dos address-pteaddr
(gdb) info dos address-pte __djgpp_base_address + (char *)&i
Page Table entry for address 0x11a00d30:
Base=0x02698000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0xd30
This says that
i is stored at offset
0xd30 from the page
whose physical base address is
0x02698000, and shows all the
attributes of that page.
Note that you must cast the addresses of variables to a
since otherwise the value of
__djgpp_base_address, the base
address of all variables and functions in a djgpp program, will
be added using the rules of C pointer arithmetics: if
int, gdb will add 4 times the value of
__djgpp_base_address to the address of
Here's another example, it displays the Page Table entry for the transfer buffer:
(gdb) info dos address-pte *((unsigned *)&_go32_info_block + 3)
Page Table entry for address 0x29110:
Base=0x00029000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0x110
+ 3 offset is because the transfer buffer's address is the
3rd member of the
_go32_info_block structure.) The output
clearly shows that this DPMI server maps the addresses in conventional
memory 1:1, i.e. the physical (
0x29110) addresses are identical.
This command is supported only with some DPMI servers.
In addition to native debugging, the DJGPP port supports remote debugging via a serial data link. The following commands are specific to remote serial debugging in the DJGPP port of gdb.
IRQ) line to use for the COM1 serial port.
There are similar commands ‘set com2base’, ‘set com3irq’,
etc. for setting the port address and the
IRQ lines for the
other 3 COM ports.
The related commands ‘show com1base’, ‘show com1irq’ etc.
display the current settings of the base address and the
lines used by the COM ports.