96 #include "floatformat.h"
109 #include <sys/utsname.h>
114 #include <sys/farptr.h>
115 #include <debug/v2load.h>
116 #include <debug/dbgcom.h>
117 #if __DJGPP_MINOR__ > 2
118 #include <debug/redir.h>
123 #if __DJGPP_MINOR__ < 3
132 unsigned short exponent:15;
133 unsigned short sign:1;
162 asm (
"inb $0xa0, %%al \n\
163 testb $0x20, %%al \n\
187 asm (
"frstor %0":
"=m" (
npx));
237 #define r_ofs(x) (offsetof(TSS,x))
246 {
r_ofs (tss_eax), 4},
247 {
r_ofs (tss_ecx), 4},
248 {
r_ofs (tss_edx), 4},
249 {
r_ofs (tss_ebx), 4},
250 {
r_ofs (tss_esp), 4},
251 {
r_ofs (tss_ebp), 4},
252 {
r_ofs (tss_esi), 4},
253 {
r_ofs (tss_edi), 4},
254 {
r_ofs (tss_eip), 4},
255 {
r_ofs (tss_eflags), 4},
290 {1, GDB_SIGNAL_TRAP},
295 {3, GDB_SIGNAL_TRAP},
297 {5, GDB_SIGNAL_SEGV},
300 {8, GDB_SIGNAL_SEGV},
301 {9, GDB_SIGNAL_SEGV},
302 {10, GDB_SIGNAL_BUS},
303 {11, GDB_SIGNAL_SEGV},
304 {12, GDB_SIGNAL_SEGV},
305 {13, GDB_SIGNAL_SEGV},
306 {14, GDB_SIGNAL_SEGV},
307 {16, GDB_SIGNAL_FPE},
308 {17, GDB_SIGNAL_BUS},
309 {31, GDB_SIGNAL_ILL},
310 {0x1b, GDB_SIGNAL_INT},
311 {0x75, GDB_SIGNAL_FPE},
312 {0x78, GDB_SIGNAL_ALRM},
313 {0x79, GDB_SIGNAL_INT},
314 {0x7a, GDB_SIGNAL_QUIT},
315 {-1, GDB_SIGNAL_LAST}
325 {GDB_SIGNAL_SEGV, 13},
326 {GDB_SIGNAL_BUS, 17},
329 {GDB_SIGNAL_TERM, 0x1b},
330 {GDB_SIGNAL_FPE, 0x75},
331 {GDB_SIGNAL_INT, 0x79},
332 {GDB_SIGNAL_QUIT, 0x7a},
333 {GDB_SIGNAL_ALRM, 0x78},
334 {GDB_SIGNAL_PROF, 0x78},
335 {GDB_SIGNAL_LAST, -1}
342 You cannot attach to a running program on this platform.\n\
343 Use the `run' command to run DJGPP programs."));
351 ptid_t ptid,
int step,
enum gdb_signal siggnal)
355 resume_is_step = step;
357 if (siggnal != GDB_SIGNAL_0 && siggnal != GDB_SIGNAL_TRAP)
359 for (i = 0, resume_signal = -1;
360 excepn_map[i].gdb_sig != GDB_SIGNAL_LAST; i++)
366 if (resume_signal == -1)
379 unsigned char saved_opcode;
380 unsigned long INT3_addr = 0;
381 int stepping_over_INT = 0;
383 a_tss.tss_eflags &= 0xfeff;
400 read_child (a_tss.tss_eip, &saved_opcode, 1);
401 if (saved_opcode == 0xCD || saved_opcode == 0xCE)
403 unsigned char INT3_opcode = 0xCC;
406 = saved_opcode == 0xCD ? a_tss.tss_eip + 2 : a_tss.tss_eip + 1;
407 stepping_over_INT = 1;
408 read_child (INT3_addr, &saved_opcode, 1);
409 write_child (INT3_addr, &INT3_opcode, 1);
412 a_tss.tss_eflags |= 0x0100;
417 if (resume_signal <= -1)
420 a_tss.tss_irqn = 0xff;
424 a_tss.tss_trap = 0xffff;
440 getcwd (child_cwd,
sizeof (child_cwd));
444 #if __DJGPP_MINOR__ < 3
448 #if __DJGPP_MINOR__ < 3
453 if (stepping_over_INT && a_tss.tss_eip == INT3_addr + 1)
457 write_child (a_tss.tss_eip, &saved_opcode, 1);
460 a_tss.tss_eflags |= 0x0100;
463 getcwd (child_cwd,
sizeof (child_cwd));
466 if (a_tss.tss_irqn == 0x21)
473 status->
value.
sig = GDB_SIGNAL_UNKNOWN;
475 for (i = 0;
sig_map[i].go32_sig != -1; i++)
477 if (a_tss.tss_irqn ==
sig_map[i].go32_sig)
479 #if __DJGPP_MINOR__ < 3
505 _(
"Invalid register no. %d in fetch_register."), regno);
536 _(
"Invalid register no. %d in store_register."), regno);
561 static void *
buffer = NULL;
562 static unsigned buffer_len = 0;
565 if (buffer_len < len)
571 memcpy (buffer, buf, len);
572 res = write_child (child_addr, buffer, len);
585 if (writebuf != NULL)
588 res = read_child (memaddr, readbuf, len);
603 const char *annex,
gdb_byte *readbuf,
614 readbuf, writebuf, offset, len,
635 char *args,
char **env,
int from_tty)
660 _(
"Cannot allocate redirection storage: "
661 "not enough memory.\n"));
664 if (strpbrk (args,
"<>"))
669 error (
_(
"Syntax error in command line."));
672 child_cmd.
command = xstrdup (args);
674 cmdlen = strlen (args);
677 if (cmdlen > 1024*1024)
678 error (
_(
"Command line too long."));
680 cmdline =
xmalloc (cmdlen + 4);
681 strcpy (cmdline + 1, args);
687 cmdline[0] = strlen (args);
688 cmdline[cmdlen + 1] = 13;
695 result = v2loadimage (exec_file, cmdline, start_state);
701 error (
_(
"Load failed for image %s"), exec_file);
703 edi_init (start_state);
704 #if __DJGPP_MINOR__ < 3
719 prog_has_started = 1;
745 prog_has_started = 0;
753 #define D_REGS edi.dr
754 #define CONTROL D_REGS[7]
755 #define STATUS D_REGS[6]
765 _(
"Invalid register %d in go32_set_dr.\n"), i);
806 _(
"Invalid register %d in go32_get_dr.\n"), i);
816 int oldmode, newmode;
821 __dpmi_int (0x21, ®s);
822 if (regs.x.flags & 1)
824 newmode = oldmode = regs.x.dx;
835 regs.x.dx = newmode & 0xff;
836 __dpmi_int (0x21, ®s);
837 if (regs.x.flags & 1)
840 return (oldmode & 0x20) == 0x20;
857 terminal_is_ours = 1;
865 ?
"default" : inf_terminal_mode ?
"raw" :
"cooked");
867 #if __DJGPP_MINOR__ > 2
868 if (child_cmd.redirection)
872 for (i = 0; i < DBG_HANDLES; i++)
874 if (child_cmd.redirection[i]->file_name)
876 i, child_cmd.redirection[i]->file_name);
877 else if (_get_dev_info (child_cmd.redirection[i]->inf_handle) == -1)
879 (
"\tFile handle %d appears to be closed by inferior.\n", i);
881 else if ((_get_dev_info (child_cmd.redirection[i]->inf_handle) & 0xdf)
882 != (_get_dev_info (i) & 0xdf))
884 (
"\tFile handle %d appears to be redirected by inferior.\n", i);
898 error (
_(
"Cannot redirect standard handles for program: %s."),
903 if (terminal_is_ours)
907 terminal_is_ours = 0;
916 if (!terminal_is_ours)
919 if (inf_terminal_mode != -1)
925 terminal_is_ours = 1;
932 error (
_(
"Cannot redirect standard handles for debugger: %s."),
985 __dpmi_int (0x21, ®s);
986 if (!(regs.x.flags & 1))
987 return regs.x.bx & 0xffff;
1004 int blen =
sizeof (buf);
1005 int needed = snprintf (buf, blen,
"CP%d",
dos_codepage ());
1009 retval = xstrdup (buf);
1013 retval = xstrdup (
"");
1028 __dpmi_int(0x2f, &r);
1029 if (r.h.al > 2 && r.h.al != 0x80 && r.h.al != 0xff
1030 && (r.h.al > 3 || r.h.ah > 0))
1032 windows_major = r.h.al;
1033 windows_minor = r.h.ah;
1036 windows_major = 0xff;
1041 print_mem (
unsigned long datum,
const char *header,
int in_pages_p)
1043 if (datum != 0xffffffffUL)
1051 if (datum > 1024 * 1024)
1064 static const char test_pattern[] =
1065 "deadbeafdeadbeafdeadbeafdeadbeafdeadbeaf"
1066 "deadbeafdeadbeafdeadbeafdeadbeafdeadbeaf"
1067 "deadbeafdeadbeafdeadbeafdeadbeafdeadbeafdeadbeaf";
1069 char cpuid_vendor[13];
1070 unsigned cpuid_max = 0, cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx;
1071 unsigned true_dos_version = _get_dos_version (1);
1072 unsigned advertized_dos_version = ((
unsigned int)_osmajor << 8) | _osminor;
1074 char dpmi_vendor_info[129];
1075 int dpmi_vendor_available;
1076 __dpmi_version_ret dpmi_version_data;
1078 __dpmi_free_mem_info mem_info;
1081 cpuid_vendor[0] =
'\0';
1083 strcpy (u.machine,
"Unknown x86");
1084 else if (u.machine[0] ==
'i' && u.machine[1] > 4)
1091 unsigned int eax, ebx, ecx, edx;
1093 if (
x86_cpuid (0, &eax, &ebx, &ecx, &edx))
1096 memcpy (&vendor[0], &ebx, 4);
1097 memcpy (&vendor[4], &ecx, 4);
1098 memcpy (&vendor[8], &edx, 4);
1099 cpuid_vendor[12] =
'\0';
1102 __asm__ __volatile__ (
"xorl %%ebx, %%ebx;"
1103 "xorl %%ecx, %%ecx;"
1104 "xorl %%edx, %%edx;"
1111 :
"=m" (cpuid_vendor[0]),
1112 "=m" (cpuid_vendor[4]),
1113 "=m" (cpuid_vendor[8]),
1116 :
"%eax",
"%ebx",
"%ecx",
"%edx");
1117 cpuid_vendor[12] =
'\0';
1122 if (cpuid_vendor[0])
1129 static char *brand_name[] = {
1137 char cpu_string[80];
1140 int intel_p = strcmp (cpuid_vendor,
"GenuineIntel") == 0;
1141 int amd_p = strcmp (cpuid_vendor,
"AuthenticAMD") == 0;
1142 unsigned cpu_family, cpu_model;
1146 x86_cpuid (1, &cpuid_eax, &cpuid_ebx, NULL, &cpuid_edx);
1148 __asm__ __volatile__ (
"movl $1, %%eax;"
1156 brand_idx = cpuid_ebx & 0xff;
1157 cpu_family = (cpuid_eax >> 8) & 0xf;
1158 cpu_model = (cpuid_eax >> 4) & 0xf;
1159 cpu_brand[0] =
'\0';
1163 && brand_idx <
sizeof(brand_name)/
sizeof(brand_name[0])
1164 && *brand_name[brand_idx])
1165 strcpy (cpu_brand, brand_name[brand_idx]);
1166 else if (cpu_family == 5)
1168 if (((cpuid_eax >> 12) & 3) == 0 && cpu_model == 4)
1169 strcpy (cpu_brand,
" MMX");
1170 else if (cpu_model > 1 && ((cpuid_eax >> 12) & 3) == 1)
1171 strcpy (cpu_brand,
" OverDrive");
1172 else if (cpu_model > 1 && ((cpuid_eax >> 12) & 3) == 2)
1173 strcpy (cpu_brand,
" Dual");
1175 else if (cpu_family == 6 && cpu_model < 8)
1180 strcpy (cpu_brand,
" Pro");
1183 strcpy (cpu_brand,
" II");
1186 strcpy (cpu_brand,
" II Xeon");
1189 strcpy (cpu_brand,
" Celeron");
1192 strcpy (cpu_brand,
" III");
1202 strcpy (cpu_brand,
"486/5x86");
1211 strcpy (cpu_brand,
"-K5");
1215 strcpy (cpu_brand,
"-K6");
1218 strcpy (cpu_brand,
"-K6-2");
1221 strcpy (cpu_brand,
"-K6-III");
1231 strcpy (cpu_brand,
" Athlon");
1234 strcpy (cpu_brand,
" Duron");
1240 xsnprintf (cpu_string,
sizeof (cpu_string),
"%s%s Model %d Stepping %d",
1241 intel_p ?
"Pentium" : (amd_p ?
"AMD" :
"ix86"),
1242 cpu_brand, cpu_model, cpuid_eax & 0xf);
1244 if (((cpuid_edx & (6 | (0x0d << 23))) != 0)
1245 || ((cpuid_edx & 1) == 0)
1246 || (amd_p && (cpuid_edx & (3 << 30)) != 0))
1251 if ((cpuid_edx & 1) == 0)
1253 if ((cpuid_edx & (1 << 1)) != 0)
1255 if ((cpuid_edx & (1 << 2)) != 0)
1257 if ((cpuid_edx & (1 << 4)) != 0)
1259 if ((cpuid_edx & (1 << 23)) != 0)
1261 if ((cpuid_edx & (1 << 25)) != 0)
1263 if ((cpuid_edx & (1 << 26)) != 0)
1267 if ((cpuid_edx & (1 << 31)) != 0)
1269 if ((cpuid_edx & (1 << 30)) != 0)
1277 _os_flavor, u.release, u.version);
1278 if (true_dos_version != advertized_dos_version)
1283 if (windows_major != 0xff)
1285 const char *windows_flavor;
1288 windows_major, windows_minor);
1289 switch (windows_major)
1292 windows_flavor =
"3.X";
1295 switch (windows_minor)
1298 windows_flavor =
"95, 95A, or 95B";
1301 windows_flavor =
"95B OSR2.1 or 95C OSR2.5";
1304 windows_flavor =
"98 or 98 SE";
1307 windows_flavor =
"ME";
1310 windows_flavor =
"9X";
1315 windows_flavor =
"??";
1320 else if (true_dos_version == 0x532 && advertized_dos_version == 0x500)
1322 "Windows NT family (W2K/XP/W2K3/Vista/W2K8)\n");
1327 memcpy (dpmi_vendor_info, test_pattern,
sizeof(dpmi_vendor_info));
1328 dpmi_vendor_available =
1329 __dpmi_get_capabilities (&dpmi_flags, dpmi_vendor_info);
1330 if (dpmi_vendor_available == 0
1331 && memcmp (dpmi_vendor_info, test_pattern,
1332 sizeof(dpmi_vendor_info)) != 0)
1336 if (!memchr (&dpmi_vendor_info[2], 0, 126))
1337 dpmi_vendor_info[128] =
'\0';
1339 "%s v%d.%d (capabilities: %#x)\n",
1340 &dpmi_vendor_info[2],
1341 (
unsigned)dpmi_vendor_info[0],
1342 (
unsigned)dpmi_vendor_info[1],
1343 ((
unsigned)dpmi_flags & 0x7f));
1346 printf_filtered (
"DPMI Host......................(Info not available)\n");
1347 __dpmi_get_version (&dpmi_version_data);
1349 dpmi_version_data.major, dpmi_version_data.minor);
1351 "%s-bit DPMI, with%s Virtual Memory support\n",
1352 (dpmi_version_data.flags & 1) ?
"32" :
"16",
1353 (dpmi_version_data.flags & 4) ?
"" :
"out");
1355 (dpmi_version_data.flags & 2) ?
"V86" :
"Real");
1357 dpmi_version_data.cpu);
1359 dpmi_version_data.master_pic, dpmi_version_data.slave_pic);
1362 if (prog_has_started)
1364 __asm__ __volatile__ (
"pushfl ; popl %0" :
"=g" (eflags));
1366 "Ring %d (in %s), with%s I/O protection\n",
1367 a_tss.tss_cs & 3, (a_tss.tss_cs & 4) ?
"LDT" :
"GDT",
1368 (a_tss.tss_cs & 3) > ((eflags >> 12) & 3) ?
"" :
"out");
1371 __dpmi_get_free_memory_information (&mem_info);
1372 print_mem (mem_info.total_number_of_physical_pages,
1373 "DPMI Total Physical Memory.....", 1);
1374 print_mem (mem_info.total_number_of_free_pages,
1375 "DPMI Free Physical Memory......", 1);
1376 print_mem (mem_info.size_of_paging_file_partition_in_pages,
1377 "DPMI Swap Space................", 1);
1378 print_mem (mem_info.linear_address_space_size_in_pages,
1379 "DPMI Total Linear Address Size.", 1);
1380 print_mem (mem_info.free_linear_address_space_in_pages,
1381 "DPMI Free Linear Address Size..", 1);
1382 print_mem (mem_info.largest_available_free_block_in_bytes,
1383 "DPMI Largest Free Memory Block.", 0);
1387 __dpmi_int (0x21, ®s);
1388 print_mem (regs.x.bx << 4,
"Free DOS Memory................", 0);
1390 __dpmi_int (0x21, ®s);
1391 if ((regs.x.flags & 1) == 0)
1393 static const char *dos_hilo[] = {
1394 "Low",
"",
"",
"",
"High",
"",
"",
"",
"High, then Low"
1396 static const char *dos_fit[] = {
1397 "First",
"Best",
"Last"
1399 int hilo_idx = (regs.x.ax >> 4) & 0x0f;
1400 int fit_idx = regs.x.ax & 0x0f;
1406 printf_filtered (
"DOS Memory Allocation..........%s memory, %s fit\n",
1407 dos_hilo[hilo_idx], dos_fit[fit_idx]);
1409 __dpmi_int (0x21, ®s);
1410 if ((regs.x.flags & 1) != 0)
1413 regs.h.al == 0 ?
"not " :
"");
1448 unsigned long dos_ds_limit = __dpmi_get_segment_limit (_dos_ds);
1452 if (addr <= dos_ds_limit - len)
1453 dosmemget (addr, len, dest);
1458 int sel = __dpmi_allocate_ldt_descriptors (1);
1464 int access_rights = __dpmi_get_descriptor_access_rights (sel);
1465 size_t segment_limit = len - 1;
1473 if (len > 1024 * 1024)
1475 access_rights |= 0x8000;
1478 segment_limit |= 0xfff;
1481 access_rights &= ~0x8000;
1483 if (__dpmi_set_segment_base_address (sel, addr) != -1
1484 && __dpmi_set_descriptor_access_rights (sel, access_rights) != -1
1485 && __dpmi_set_segment_limit (sel, segment_limit) != -1
1488 && __dpmi_get_segment_limit (sel) >= segment_limit)
1489 movedata (sel, 0, _my_ds (), (
unsigned)dest, len);
1493 __dpmi_free_ldt_descriptor (sel);
1505 unsigned long addr = table_base + idx * 8;
1508 return (
int)((
struct seg_descr *)descr)->stype;
1527 if (idx == 0 && type == 0)
1533 static unsigned allowed_descriptors[] = {
1541 int cpl = prog_has_started ? (a_tss.tss_cs & 3) : _my_cs () & 3;
1542 unsigned long limit = (descr.
limit1 << 16) | descr.
limit0;
1545 && (allowed_descriptors[type] & (1 << descr.
stype)) != 0)
1549 ? idx : (idx * 8) | (type ? (cpl | 4) : 0));
1551 limit = (limit << 12) | 0xfff;
1558 switch (descr.
stype)
1563 descr.
stype == 3 ?
"" :
"in");
1569 memcpy (&gate, &descr,
sizeof gate);
1581 memcpy (&gate, &descr,
sizeof gate);
1585 descr.
stype == 6 ?
"Interrupt" :
"Trap");
1590 descr.
stype == 3 ?
"" :
"in");
1593 memcpy (&gate, &descr,
sizeof gate);
1601 memcpy (&gate, &descr,
sizeof gate);
1605 descr.
stype == 14 ?
"Interrupt" :
"Trap");
1616 descr.
bit32 ?
"32" :
"16",
1618 ?
"Read/Write," :
"Read-Only, ",
1619 descr.
stype & 4 ?
"down" :
"up",
1620 descr.
stype & 1 ?
"" :
", N.Acc");
1631 descr.
bit32 ?
"32" :
"16",
1632 descr.
stype & 2 ?
"Exec/Read" :
"Exec-Only",
1633 descr.
stype & 4 ?
"" :
"N.",
1634 descr.
stype & 1 ?
"" :
", N.Acc");
1646 ? idx : (idx * 8) | (type ? (cpl | 4) : 0));
1662 unsigned short ldtr = 0;
1665 long ldt_entry = -1
L;
1666 int cpl = (prog_has_started ? a_tss.tss_cs : _my_cs ()) & 3;
1676 || (ldt_entry & 4) == 0
1677 || (ldt_entry & 3) != (cpl & 3))
1678 error (
_(
"Invalid LDT entry 0x%03lx."), (
unsigned long)ldt_entry);
1682 __asm__ __volatile__ (
"sgdt %0" :
"=m" (gdtr) : );
1683 __asm__ __volatile__ (
"sldt %0" :
"=m" (ldtr) : );
1691 | (ldt_descr.
base1 << 16)
1692 | (ldt_descr.
base2 << 24));
1697 | (ldt_descr.
base1 << 16)
1698 | (ldt_descr.
base2 << 24);
1699 unsigned limit = ldt_descr.
limit0 | (ldt_descr.
limit1 << 16);
1705 limit = (limit << 12) | 0xfff;
1711 max_entry = (limit + 1) / 8;
1715 if (ldt_entry > limit)
1716 error (
_(
"Invalid LDT entry %#lx: outside valid limits [0..%#x]"),
1717 (
unsigned long)ldt_entry, limit);
1725 for (i = 0; i < max_entry; i++)
1735 long gdt_entry = -1
L;
1745 if (gdt_entry < 0 || (gdt_entry & 7) != 0)
1746 error (
_(
"Invalid GDT entry 0x%03lx: "
1747 "not an integral multiple of 8."),
1748 (
unsigned long)gdt_entry);
1752 __asm__ __volatile__ (
"sgdt %0" :
"=m" (gdtr) : );
1753 max_entry = (gdtr.limit + 1) / 8;
1757 if (gdt_entry > gdtr.limit)
1758 error (
_(
"Invalid GDT entry %#lx: outside valid limits [0..%#x]"),
1759 (
unsigned long)gdt_entry, gdtr.limit);
1767 for (i = 0; i < max_entry; i++)
1776 long idt_entry = -1
L;
1787 error (
_(
"Invalid (negative) IDT entry %ld."), idt_entry);
1791 __asm__ __volatile__ (
"sidt %0" :
"=m" (idtr) : );
1792 max_entry = (idtr.limit + 1) / 8;
1793 if (max_entry > 0x100)
1798 if (idt_entry > idtr.limit)
1799 error (
_(
"Invalid IDT entry %#lx: outside valid limits [0..%#x]"),
1800 (
unsigned long)idt_entry, idtr.limit);
1808 for (i = 0; i < max_entry; i++)
1818 static unsigned long
1823 unsigned long taskbase, cr3;
1826 if (pdbr > 0 && pdbr <= 0xfffff)
1830 __asm__ __volatile__ (
"sgdt %0" :
"=m" (gdtr) : );
1831 __asm__ __volatile__ (
"str %0" :
"=m" (taskreg) : );
1838 offset = gdtr.base + (taskreg & 0xfff8) + 2;
1842 if (offset > 0xfffff)
1845 _farsetsel (_dos_ds);
1846 taskbase = _farnspeekl (offset) & 0xffffffU;
1847 taskbase += _farnspeekl (offset + 2) & 0xff000000U;
1848 if (taskbase > 0xfffff)
1853 cr3 = _farnspeekl (taskbase + 0x1c) & ~0xfff;
1863 unsigned long addr, pte_idx;
1865 for (addr = 0xb0000, pte_idx = 0xb0;
1867 addr += 0x1000, pte_idx++)
1869 if (((_farnspeekl (addr + 4 * pte_idx) & 0xfffff027) ==
1870 (_farnspeekl (addr + 0x1000) & 0xfffff027))
1871 && ((_farnspeekl (addr + 4 * pte_idx + 4) & 0xfffff000) == cr3))
1873 cr3 = addr + 0x1000;
1887 static unsigned long
1890 unsigned long pde = 0;
1892 if (pdbr && n >= 0 && n < 1024)
1894 pde = _farpeekl (_dos_ds, pdbr + 4*n);
1901 static unsigned long
1904 unsigned long pte = 0;
1908 if ((pde & 1) && !(pde & 0x80) && n >= 0 && n < 1024)
1911 pte = _farpeekl (_dos_ds, pde + 4*n);
1923 if ((entry & 1) != 0)
1926 if ((entry & 0x100) && !is_dir)
1928 if ((entry & 0x40) && !is_dir)
1940 printf_filtered (
"Page%s not present or not supported; value=0x%lx.\n",
1941 is_dir ?
" Table" :
"", entry >> 1);
1947 long pde_idx = -1, i;
1956 if (pde_idx < 0 || pde_idx >= 1024)
1957 error (
_(
"Entry %ld is outside valid limits [0..1023]."), pde_idx);
1964 "not supported on this system.\n");
1965 else if (pde_idx >= 0)
1968 for (i = 0; i < 1024; i++)
1978 unsigned long pde =
get_pde (n);
1985 "Page Directory entry 0x%lx:\n", n);
1986 for (i = 0; i < 1024; i++)
1997 long pde_idx = -1
L, i;
2006 if (pde_idx < 0 || pde_idx >= 1024)
2007 error (
_(
"Entry %ld is outside valid limits [0..1023]."), pde_idx);
2013 puts_filtered (
"Access to Page Tables is not supported on this system.\n");
2014 else if (pde_idx >= 0)
2017 for (i = 0; i < 1024; i++)
2038 puts_filtered (
"Access to Page Tables is not supported on this system.\n");
2041 int pde_idx = (addr >> 22) & 0x3ff;
2042 int pte_idx = (addr >> 12) & 0x3ff;
2043 unsigned offs = addr & 0xfff;
2084 _(
"Cannot allocate redirection storage: "
2085 "not enough memory.\n"));
2091 Print information specific to DJGPP (aka MS-DOS) debugging."),
2092 &info_dos_cmdlist,
"info dos ", 0, &
infolist);
2095 Display information about the target system, including CPU, OS, DPMI, etc."),
2098 Display entries in the LDT (Local Descriptor Table).\n\
2099 Entry number (an expression) as an argument means display only that entry."),
2102 Display entries in the GDT (Global Descriptor Table).\n\
2103 Entry number (an expression) as an argument means display only that entry."),
2106 Display entries in the IDT (Interrupt Descriptor Table).\n\
2107 Entry number (an expression) as an argument means display only that entry."),
2110 Display entries in the Page Directory.\n\
2111 Entry number (an expression) as an argument means display only that entry."),
2114 Display entries in Page Tables.\n\
2115 Entry number (an expression) as an argument means display only entries\n\
2116 from the Page Table pointed to by the specified Page Directory entry."),
2119 Display a Page Table entry for a linear address.\n\
2120 The address argument must be a linear address, after adding to\n\
2121 it the base address of the appropriate segment.\n\
2122 The base address of variables and functions in the debuggee's data\n\
2123 or code segment is stored in the variable __djgpp_base_address,\n\
2124 so use `__djgpp_base_address + (char *)&var' as the argument.\n\
2125 For other segments, look up their base address in the output of\n\
2126 the `info dos ldt' command."),
2142 if (isatty (fd) && pgid ==
SOME_PID)
2144 errno = pgid ==
SOME_PID ? ENOTTY : ENOSYS;
void error_no_arg(const char *why)
void add_target(struct target_ops *t)
void i387_collect_fsave(const struct regcache *regcache, int regnum, void *fsave)
static int go32_thread_alive(struct target_ops *ops, ptid_t ptid)
char * hex_string(LONGEST num)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
static int read_memory_region(unsigned long addr, void *dest, size_t len)
static void display_descriptor(unsigned type, unsigned long base_addr, int idx, int force)
static __inline int x86_cpuid(unsigned int __level, unsigned int *__eax, unsigned int *__ebx, unsigned int *__ecx, unsigned int *__edx)
int redir_debug_init(cmdline_t *ptr)
static ptid_t go32_wait(struct target_ops *ops, ptid_t ptid, struct target_waitstatus *status, int options)
static void go32_set_dr7(unsigned long val)
unsigned short windows_minor
static void load_npx(void)
int ptid_equal(ptid_t ptid1, ptid_t ptid2)
static void go32_store_registers(struct target_ops *ops, struct regcache *regcache, int regno)
void insert_breakpoints(void)
static int resume_is_step
static void print_mem(unsigned long datum, const char *header, int in_pages_p)
static void go32_fetch_registers(struct target_ops *ops, struct regcache *regcache, int regno)
static unsigned long go32_get_dr7(void)
static struct @83 excepn_map[]
static int terminal_is_ours
struct gdbarch * get_regcache_arch(const struct regcache *regcache)
EXTERN unsigned char processing_gcc_compilation
char *(* to_pid_to_str)(struct target_ops *, ptid_t) TARGET_DEFAULT_FUNC(default_pid_to_str)
static void go32_set_dr(int i, CORE_ADDR addr)
void(* to_terminal_init)(struct target_ops *) TARGET_DEFAULT_IGNORE()
void push_target(struct target_ops *t)
void delete_thread_silent(ptid_t)
struct ui_file * gdb_stdout
static void display_ptable_entry(unsigned long entry, int is_dir, int force, unsigned off)
static void go32_terminal_info(struct target_ops *self, const char *args, int from_tty)
void internal_error(const char *file, int line, const char *fmt,...)
void(* to_terminal_ours_for_output)(struct target_ops *) TARGET_DEFAULT_IGNORE()
static int dr_ref_count[4]
static void go32_sldt(char *arg, int from_tty)
void generic_mourn_inferior(void)
static int inf_terminal_mode
static void display_page_table(long n, int force)
int i386_fp_regnum_p(struct gdbarch *gdbarch, int regnum)
static void go32_pte_for_address(char *arg, int from_tty)
void i387_supply_fsave(struct regcache *regcache, int regnum, const void *fsave)
ptid_t(* to_wait)(struct target_ops *, ptid_t, struct target_waitstatus *, int TARGET_DEBUG_PRINTER(target_debug_print_options)) TARGET_DEFAULT_NORETURN(noprocess())
char * skip_spaces(char *chp)
static CORE_ADDR go32_get_dr(int i)
void(* set_control)(unsigned long)
int redir_to_debugger(cmdline_t *ptr)
struct x86_dr_low_type x86_dr_low
void inf_child_maybe_unpush_target(struct target_ops *ops)
static void go32_sysinfo(char *arg, int from_tty)
static void go32_files_info(struct target_ops *target)
CORE_ADDR(* get_addr)(int)
static int my_write_child(unsigned child_addr, const void *buf, unsigned len)
static int device_mode(int fd, int raw_p)
int i386_fpc_regnum_p(struct gdbarch *gdbarch, int regnum)
void printf_filtered(const char *format,...)
char * nl_langinfo(nl_item item)
void(* to_files_info)(struct target_ops *) TARGET_DEFAULT_IGNORE()
static void go32_terminal_inferior(struct target_ops *self)
struct cmd_list_element * infolist
void(* set_addr)(int, CORE_ADDR)
static unsigned long get_pte(unsigned long pde, int n)
static void fetch_register(struct regcache *regcache, int regno)
static int dos_codepage(void)
static enum target_xfer_status go32_xfer_partial(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
static void go32_sidt(char *arg, int from_tty)
void initialize_file_ftype(void)
static int get_descriptor(unsigned long table_base, int idx, void *descr)
unsigned long(* get_status)(void)
int redir_cmdline_parse(const char *args, cmdline_t *ptr)
static void go32_pte(char *arg, int from_tty)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int status
void(* to_resume)(struct target_ops *, ptid_t, int TARGET_DEBUG_PRINTER(target_debug_print_step), enum gdb_signal) TARGET_DEFAULT_NORETURN(noprocess())
void puts_filtered(const char *string)
static cmdline_t child_cmd
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **list)
ptid_t pid_to_ptid(int pid)
union target_waitstatus::@161 value
unsigned short windows_major
unsigned short limit __attribute__((packed))
static void go32_sgdt(char *arg, int from_tty)
static void go32_get_windows_version(void)
struct thread_info * add_thread_silent(ptid_t ptid)
const char * gdb_signal_to_name(enum gdb_signal)
enum target_xfer_status(* to_xfer_partial)(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) TARGET_DEFAULT_RETURN(TARGET_XFER_E_IO)
void printf_unfiltered(const char *format,...)
void printfi_filtered(int spaces, const char *format,...)
static enum target_xfer_status go32_xfer_memory(gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len)
unsigned long(* get_control)(void)
static struct @81 regno_mapping[]
int target_is_pushed(struct target_ops *t)
char * normal_pid_to_str(ptid_t ptid)
void redir_cmdline_delete(cmdline_t *ptr)
static void go32_kill_inferior(struct target_ops *ops)
PTR xrealloc(PTR ptr, size_t size)
const char const char int
struct target_ops * inf_child_target(void)
void help_list(struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream)
void(* to_fetch_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_IGNORE()
void(* to_mourn_inferior)(struct target_ops *) TARGET_DEFAULT_FUNC(default_mourn_inferior)
static int prog_has_started
static unsigned long pdbr
int gdbarch_fp0_regnum(struct gdbarch *gdbarch)
static char child_cwd[FILENAME_MAX]
int xsnprintf(char *str, size_t size, const char *format,...)
CORE_ADDR parse_and_eval_address(const char *exp)
void clear_proceed_status(int step)
enum target_waitkind kind
void(* to_kill)(struct target_ops *) TARGET_DEFAULT_NORETURN(noprocess())
int redir_to_child(cmdline_t *ptr)
static void store_register(const struct regcache *regcache, int regno)
char * safe_strerror(int)
struct dtr_reg __attribute__
void(* to_create_inferior)(struct target_ops *, char *, char *, char **, int)
static void go32_pde(char *arg, int from_tty)
static void save_npx(void)
void(* to_terminal_ours)(struct target_ops *) TARGET_DEFAULT_IGNORE()
struct inferior * current_inferior(void)
void regcache_raw_supply(struct regcache *regcache, int regnum, const void *buf)
void(* to_terminal_inferior)(struct target_ops *) TARGET_DEFAULT_IGNORE()
char * get_exec_file(int err)
unsigned long long ULONGEST
void x86_set_debug_register_length(int len)
static unsigned long get_pde(int n)
void regcache_raw_collect(const struct regcache *regcache, int regnum, void *buf)
static struct @82 sig_map[]
void x86_use_watchpoints(struct target_ops *t)
int tcsetpgrp(int fd, pid_t pgid)
int(* to_thread_alive)(struct target_ops *, ptid_t ptid) TARGET_DEFAULT_RETURN(0)
static void go32_terminal_ours(struct target_ops *self)
static void go32_terminal_init(struct target_ops *self)
void(* to_attach)(struct target_ops *ops, const char *, int)
static void go32_resume(struct target_ops *ops, ptid_t ptid, int step, enum gdb_signal siggnal)
static void go32_create_inferior(struct target_ops *ops, char *exec_file, char *args, char **env, int from_tty)
static unsigned long go32_get_dr6(void)
void x86_cleanup_dregs(void)
static int inf_mode_valid
static void go32_info_dos_command(char *args, int from_tty)
void(* to_store_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_NORETURN(noprocess())
static void go32_mourn_inferior(struct target_ops *ops)
static struct target_ops * go32_target(void)
void error(const char *fmt,...)
static char * go32_pid_to_str(struct target_ops *ops, ptid_t ptid)
struct target_ops * beneath
static unsigned long get_cr3(void)
void inferior_appeared(struct inferior *inf, int pid)
initialize_file_ftype _initialize_go32_nat
void(* to_terminal_info)(struct target_ops *, const char *, int) TARGET_DEFAULT_FUNC(default_terminal_info)
static void go32_attach(struct target_ops *ops, const char *args, int from_tty)
const ULONGEST const LONGEST len
LONGEST parse_and_eval_long(const char *exp)