92#include "gdbsupport/gdb_wait.h"
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
161 asm (
"inb $0xa0, %%al \n\
162 testb $0x20, %%al \n\
185 asm (
"frstor %0":
"=m" (
npx));
234#define r_ofs(x) (offsetof(TSS,x))
243 {
r_ofs (tss_eax), 4},
244 {
r_ofs (tss_ecx), 4},
245 {
r_ofs (tss_edx), 4},
246 {
r_ofs (tss_ebx), 4},
247 {
r_ofs (tss_esp), 4},
248 {
r_ofs (tss_ebp), 4},
249 {
r_ofs (tss_esi), 4},
250 {
r_ofs (tss_edi), 4},
251 {
r_ofs (tss_eip), 4},
252 {
r_ofs (tss_eflags), 4},
287 {1, GDB_SIGNAL_TRAP},
292 {3, GDB_SIGNAL_TRAP},
294 {5, GDB_SIGNAL_SEGV},
297 {8, GDB_SIGNAL_SEGV},
298 {9, GDB_SIGNAL_SEGV},
299 {10, GDB_SIGNAL_BUS},
300 {11, GDB_SIGNAL_SEGV},
301 {12, GDB_SIGNAL_SEGV},
302 {13, GDB_SIGNAL_SEGV},
303 {14, GDB_SIGNAL_SEGV},
304 {16, GDB_SIGNAL_FPE},
305 {17, GDB_SIGNAL_BUS},
306 {31, GDB_SIGNAL_ILL},
307 {0x1b, GDB_SIGNAL_INT},
308 {0x75, GDB_SIGNAL_FPE},
309 {0x78, GDB_SIGNAL_ALRM},
310 {0x79, GDB_SIGNAL_INT},
311 {0x7a, GDB_SIGNAL_QUIT},
312 {-1, GDB_SIGNAL_LAST}
322 {GDB_SIGNAL_SEGV, 13},
323 {GDB_SIGNAL_BUS, 17},
326 {GDB_SIGNAL_TERM, 0x1b},
327 {GDB_SIGNAL_FPE, 0x75},
328 {GDB_SIGNAL_INT, 0x79},
329 {GDB_SIGNAL_QUIT, 0x7a},
330 {GDB_SIGNAL_ALRM, 0x78},
331 {GDB_SIGNAL_PROF, 0x78},
332 {GDB_SIGNAL_LAST, -1}
339 void attach (
const char *,
int)
override;
341 void resume (ptid_t,
int,
enum gdb_signal)
override;
351 const gdb_byte *writebuf,
352 ULONGEST offset, ULONGEST len,
353 ULONGEST *xfered_len)
override;
372 char **,
int)
override;
387You cannot attach to a running program on this platform.\n\
388Use the `run' command to run DJGPP programs."));
401 if (siggnal != GDB_SIGNAL_0 && siggnal != GDB_SIGNAL_TRAP)
404 excepn_map[i].gdb_sig != GDB_SIGNAL_LAST; i++)
412 gdb_signal_to_name (siggnal));
420 target_wait_flags options)
423 unsigned char saved_opcode;
424 unsigned long INT3_addr = 0;
425 int stepping_over_INT = 0;
427 a_tss.tss_eflags &= 0xfeff;
444 read_child (a_tss.tss_eip, &saved_opcode, 1);
445 if (saved_opcode == 0xCD || saved_opcode == 0xCE)
447 unsigned char INT3_opcode = 0xCC;
450 = saved_opcode == 0xCD ? a_tss.tss_eip + 2 : a_tss.tss_eip + 1;
451 stepping_over_INT = 1;
452 read_child (INT3_addr, &saved_opcode, 1);
453 write_child (INT3_addr, &INT3_opcode, 1);
456 a_tss.tss_eflags |= 0x0100;
464 a_tss.tss_irqn = 0xff;
468 a_tss.tss_trap = 0xffff;
488#if __DJGPP_MINOR__ < 3
492#if __DJGPP_MINOR__ < 3
497 if (stepping_over_INT && a_tss.tss_eip == INT3_addr + 1)
501 write_child (a_tss.tss_eip, &saved_opcode, 1);
504 a_tss.tss_eflags |= 0x0100;
508 if (current_directory != NULL)
509 chdir (current_directory);
511 if (a_tss.tss_irqn == 0x21)
512 status->set_exited (a_tss.tss_eax & 0xff);
515 status->set_stopped (GDB_SIGNAL_UNKNOWN);
516 for (i = 0;
sig_map[i].go32_sig != -1; i++)
518 if (a_tss.tss_irqn ==
sig_map[i].go32_sig)
520#if __DJGPP_MINOR__ < 3
522 if (
status->sig () != GDB_SIGNAL_TRAP)
545 internal_error (_(
"Invalid register no. %d in fetch_register."), regno);
574 internal_error (_(
"Invalid register no. %d in store_register."), regno);
598 static void *buffer = NULL;
599 static unsigned buffer_len = 0;
602 if (buffer_len < len)
608 memcpy (buffer, buf, len);
609 res = write_child (child_addr, buffer, len);
618 ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len)
622 if (writebuf != NULL)
625 res = read_child (memaddr, readbuf, len);
640 const char *annex, gdb_byte *readbuf,
641 const gdb_byte *writebuf, ULONGEST offset,
643 ULONGEST *xfered_len)
652 readbuf, writebuf, offset, len,
662 gdb_printf (
"You are running a DJGPP V2 program.\n");
666go32_nat_target::kill_inferior ()
673 const std::string &allargs,
674 char **env,
int from_tty)
683 const char *args = allargs.c_str ();
699 internal_error (_(
"Cannot allocate redirection storage: "
700 "not enough memory.\n"));
703 if (strpbrk (args,
"<>"))
708 error (_(
"Syntax error in command line."));
713 cmdlen = strlen (args);
716 if (cmdlen > 1024*1024)
717 error (_(
"Command line too long."));
719 cmdline = (
char *)
xmalloc (cmdlen + 4);
720 strcpy (cmdline + 1, args);
726 cmdline[0] = strlen (args);
727 cmdline[cmdlen + 1] = 13;
734 result = v2loadimage (exec_file, cmdline, start_state);
740 error (_(
"Load failed for image %s"), exec_file);
742 edi_init (start_state);
743#if __DJGPP_MINOR__ < 3
750 if (!
inf->target_is_pushed (
this))
751 inf->push_target (
this);
788#define CONTROL D_REGS[7]
789#define STATUS D_REGS[6]
798 internal_error (_(
"Invalid register %d in go32_set_dr.\n"), i);
838 internal_error (_(
"Invalid register %d in go32_get_dr.\n"), i);
848 int oldmode, newmode;
853 __dpmi_int (0x21, ®s);
854 if (regs.x.flags & 1)
856 newmode = oldmode = regs.x.dx;
867 regs.x.dx = newmode & 0xff;
868 __dpmi_int (0x21, ®s);
869 if (regs.x.flags & 1)
872 return (oldmode & 0x20) == 0x20;
895 gdb_printf (
"Inferior's terminal is in %s mode.\n",
899#if __DJGPP_MINOR__ > 2
904 for (i = 0; i < DBG_HANDLES; i++)
907 gdb_printf (
"\tFile handle %d is redirected to `%s'.\n",
909 else if (_get_dev_info (
child_cmd.redirection[i]->inf_handle) == -1)
911 (
"\tFile handle %d appears to be closed by inferior.\n", i);
913 else if ((_get_dev_info (
child_cmd.redirection[i]->inf_handle) & 0xdf)
914 != (_get_dev_info (i) & 0xdf))
916 (
"\tFile handle %d appears to be redirected by inferior.\n", i);
930 error (_(
"Cannot redirect standard handles for program: %s."),
931 safe_strerror (errno));
964 error (_(
"Cannot redirect standard handles for debugger: %s."),
965 safe_strerror (errno));
978 return ptid != null_ptid;
994 __dpmi_int (0x21, ®s);
995 if (!(regs.x.flags & 1))
996 return regs.x.bx & 0xffff;
1013 int blen =
sizeof (buf);
1014 int needed = snprintf (buf, blen,
"CP%d",
dos_codepage ());
1018 retval = xstrdup (buf);
1022 retval = xstrdup (
"");
1037 __dpmi_int(0x2f, &r);
1038 if (r.h.al > 2 && r.h.al != 0x80 && r.h.al != 0xff
1039 && (r.h.al > 3 || r.h.ah > 0))
1050print_mem (
unsigned long datum,
const char *header,
int in_pages_p)
1052 if (datum != 0xffffffffUL)
1060 if (datum > 1024 * 1024)
1073 static const char test_pattern[] =
1074 "deadbeafdeadbeafdeadbeafdeadbeafdeadbeaf"
1075 "deadbeafdeadbeafdeadbeafdeadbeafdeadbeaf"
1076 "deadbeafdeadbeafdeadbeafdeadbeafdeadbeafdeadbeaf";
1078 char cpuid_vendor[13];
1079 unsigned cpuid_max = 0, cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx;
1080 unsigned true_dos_version = _get_dos_version (1);
1081 unsigned advertized_dos_version = ((
unsigned int)_osmajor << 8) | _osminor;
1083 char dpmi_vendor_info[129];
1084 int dpmi_vendor_available;
1085 __dpmi_version_ret dpmi_version_data;
1087 __dpmi_free_mem_info mem_info;
1090 cpuid_vendor[0] =
'\0';
1092 strcpy (u.machine,
"Unknown x86");
1093 else if (u.machine[0] ==
'i' && u.machine[1] > 4)
1100 unsigned int eax, ebx, ecx, edx;
1102 if (
x86_cpuid (0, &eax, &ebx, &ecx, &edx))
1105 memcpy (&vendor[0], &ebx, 4);
1106 memcpy (&vendor[4], &ecx, 4);
1107 memcpy (&vendor[8], &edx, 4);
1108 cpuid_vendor[12] =
'\0';
1111 __asm__ __volatile__ (
"xorl %%ebx, %%ebx;"
1112 "xorl %%ecx, %%ecx;"
1113 "xorl %%edx, %%edx;"
1120 :
"=m" (cpuid_vendor[0]),
1121 "=m" (cpuid_vendor[4]),
1122 "=m" (cpuid_vendor[8]),
1125 :
"%eax",
"%ebx",
"%ecx",
"%edx");
1126 cpuid_vendor[12] =
'\0';
1130 gdb_printf (
"CPU Type.......................%s", u.machine);
1131 if (cpuid_vendor[0])
1138 static const char *brand_name[] = {
1146 char cpu_string[80];
1149 int intel_p = strcmp (cpuid_vendor,
"GenuineIntel") == 0;
1150 int amd_p = strcmp (cpuid_vendor,
"AuthenticAMD") == 0;
1151 int hygon_p = strcmp (cpuid_vendor,
"HygonGenuine") == 0;
1152 unsigned cpu_family, cpu_model;
1156 x86_cpuid (1, &cpuid_eax, &cpuid_ebx, NULL, &cpuid_edx);
1158 __asm__ __volatile__ (
"movl $1, %%eax;"
1166 brand_idx = cpuid_ebx & 0xff;
1167 cpu_family = (cpuid_eax >> 8) & 0xf;
1168 cpu_model = (cpuid_eax >> 4) & 0xf;
1169 cpu_brand[0] =
'\0';
1173 && brand_idx <
sizeof(brand_name)/
sizeof(brand_name[0])
1174 && *brand_name[brand_idx])
1175 strcpy (cpu_brand, brand_name[brand_idx]);
1176 else if (cpu_family == 5)
1178 if (((cpuid_eax >> 12) & 3) == 0 && cpu_model == 4)
1179 strcpy (cpu_brand,
" MMX");
1180 else if (cpu_model > 1 && ((cpuid_eax >> 12) & 3) == 1)
1181 strcpy (cpu_brand,
" OverDrive");
1182 else if (cpu_model > 1 && ((cpuid_eax >> 12) & 3) == 2)
1183 strcpy (cpu_brand,
" Dual");
1185 else if (cpu_family == 6 && cpu_model < 8)
1190 strcpy (cpu_brand,
" Pro");
1193 strcpy (cpu_brand,
" II");
1196 strcpy (cpu_brand,
" II Xeon");
1199 strcpy (cpu_brand,
" Celeron");
1202 strcpy (cpu_brand,
" III");
1212 strcpy (cpu_brand,
"486/5x86");
1221 strcpy (cpu_brand,
"-K5");
1225 strcpy (cpu_brand,
"-K6");
1228 strcpy (cpu_brand,
"-K6-2");
1231 strcpy (cpu_brand,
"-K6-III");
1241 strcpy (cpu_brand,
" Athlon");
1244 strcpy (cpu_brand,
" Duron");
1250 xsnprintf (cpu_string,
sizeof (cpu_string),
"%s%s Model %d Stepping %d",
1251 intel_p ?
"Pentium" : (amd_p ?
"AMD" : (hygon_p ?
"Hygon" :
"ix86")),
1252 cpu_brand, cpu_model, cpuid_eax & 0xf);
1254 if (((cpuid_edx & (6 | (0x0d << 23))) != 0)
1255 || ((cpuid_edx & 1) == 0)
1256 || ((amd_p || hygon_p) && (cpuid_edx & (3 << 30)) != 0))
1258 gdb_puts (
"CPU Features...................");
1261 if ((cpuid_edx & 1) == 0)
1263 if ((cpuid_edx & (1 << 1)) != 0)
1265 if ((cpuid_edx & (1 << 2)) != 0)
1267 if ((cpuid_edx & (1 << 4)) != 0)
1269 if ((cpuid_edx & (1 << 23)) != 0)
1271 if ((cpuid_edx & (1 << 25)) != 0)
1273 if ((cpuid_edx & (1 << 26)) != 0)
1275 if (amd_p || hygon_p)
1277 if ((cpuid_edx & (1 << 31)) != 0)
1279 if ((cpuid_edx & (1 << 30)) != 0)
1286 gdb_printf (
"DOS Version....................%s %s.%s",
1287 _os_flavor, u.release, u.version);
1288 if (true_dos_version != advertized_dos_version)
1289 gdb_printf (
" (disguised as v%d.%d)", _osmajor, _osminor);
1295 const char *windows_flavor;
1297 gdb_printf (
"Windows Version................%d.%02d (Windows ",
1302 windows_flavor =
"3.X";
1308 windows_flavor =
"95, 95A, or 95B";
1311 windows_flavor =
"95B OSR2.1 or 95C OSR2.5";
1314 windows_flavor =
"98 or 98 SE";
1317 windows_flavor =
"ME";
1320 windows_flavor =
"9X";
1325 windows_flavor =
"??";
1330 else if (true_dos_version == 0x532 && advertized_dos_version == 0x500)
1331 gdb_printf (
"Windows Version................"
1332 "Windows NT family (W2K/XP/W2K3/Vista/W2K8)\n");
1337 memcpy (dpmi_vendor_info, test_pattern,
sizeof(dpmi_vendor_info));
1338 dpmi_vendor_available =
1339 __dpmi_get_capabilities (&dpmi_flags, dpmi_vendor_info);
1340 if (dpmi_vendor_available == 0
1341 && memcmp (dpmi_vendor_info, test_pattern,
1342 sizeof(dpmi_vendor_info)) != 0)
1346 if (!memchr (&dpmi_vendor_info[2], 0, 126))
1347 dpmi_vendor_info[128] =
'\0';
1348 gdb_printf (
"DPMI Host......................"
1349 "%s v%d.%d (capabilities: %#x)\n",
1350 &dpmi_vendor_info[2],
1351 (
unsigned)dpmi_vendor_info[0],
1352 (
unsigned)dpmi_vendor_info[1],
1353 ((
unsigned)dpmi_flags & 0x7f));
1356 gdb_printf (
"DPMI Host......................(Info not available)\n");
1357 __dpmi_get_version (&dpmi_version_data);
1358 gdb_printf (
"DPMI Version...................%d.%02d\n",
1359 dpmi_version_data.major, dpmi_version_data.minor);
1360 gdb_printf (
"DPMI Info......................"
1361 "%s-bit DPMI, with%s Virtual Memory support\n",
1362 (dpmi_version_data.flags & 1) ?
"32" :
"16",
1363 (dpmi_version_data.flags & 4) ?
"" :
"out");
1364 gdb_printf (
"%*sInterrupts reflected to %s mode\n", 31,
"",
1365 (dpmi_version_data.flags & 2) ?
"V86" :
"Real");
1366 gdb_printf (
"%*sProcessor type: i%d86\n", 31,
"",
1367 dpmi_version_data.cpu);
1368 gdb_printf (
"%*sPIC base interrupt: Master: %#x Slave: %#x\n", 31,
"",
1369 dpmi_version_data.master_pic, dpmi_version_data.slave_pic);
1374 __asm__ __volatile__ (
"pushfl ; popl %0" :
"=g" (eflags));
1375 gdb_printf (
"Protection....................."
1376 "Ring %d (in %s), with%s I/O protection\n",
1377 a_tss.tss_cs & 3, (a_tss.tss_cs & 4) ?
"LDT" :
"GDT",
1378 (a_tss.tss_cs & 3) > ((eflags >> 12) & 3) ?
"" :
"out");
1381 __dpmi_get_free_memory_information (&mem_info);
1382 print_mem (mem_info.total_number_of_physical_pages,
1383 "DPMI Total Physical Memory.....", 1);
1384 print_mem (mem_info.total_number_of_free_pages,
1385 "DPMI Free Physical Memory......", 1);
1386 print_mem (mem_info.size_of_paging_file_partition_in_pages,
1387 "DPMI Swap Space................", 1);
1388 print_mem (mem_info.linear_address_space_size_in_pages,
1389 "DPMI Total Linear Address Size.", 1);
1390 print_mem (mem_info.free_linear_address_space_in_pages,
1391 "DPMI Free Linear Address Size..", 1);
1392 print_mem (mem_info.largest_available_free_block_in_bytes,
1393 "DPMI Largest Free Memory Block.", 0);
1397 __dpmi_int (0x21, ®s);
1398 print_mem (regs.x.bx << 4,
"Free DOS Memory................", 0);
1400 __dpmi_int (0x21, ®s);
1401 if ((regs.x.flags & 1) == 0)
1403 static const char *dos_hilo[] = {
1404 "Low",
"",
"",
"",
"High",
"",
"",
"",
"High, then Low"
1406 static const char *dos_fit[] = {
1407 "First",
"Best",
"Last"
1409 int hilo_idx = (regs.x.ax >> 4) & 0x0f;
1410 int fit_idx = regs.x.ax & 0x0f;
1416 gdb_printf (
"DOS Memory Allocation..........%s memory, %s fit\n",
1417 dos_hilo[hilo_idx], dos_fit[fit_idx]);
1419 __dpmi_int (0x21, ®s);
1420 if ((regs.x.flags & 1) != 0)
1422 gdb_printf (
"%*sUMBs %sin DOS memory chain\n", 31,
"",
1423 regs.h.al == 0 ?
"not " :
"");
1458 unsigned long dos_ds_limit = __dpmi_get_segment_limit (_dos_ds);
1462 if (addr <= dos_ds_limit - len)
1463 dosmemget (addr, len, dest);
1468 int sel = __dpmi_allocate_ldt_descriptors (1);
1474 int access_rights = __dpmi_get_descriptor_access_rights (sel);
1475 size_t segment_limit = len - 1;
1483 if (len > 1024 * 1024)
1485 access_rights |= 0x8000;
1488 segment_limit |= 0xfff;
1491 access_rights &= ~0x8000;
1493 if (__dpmi_set_segment_base_address (sel, addr) != -1
1494 && __dpmi_set_descriptor_access_rights (sel, access_rights) != -1
1495 && __dpmi_set_segment_limit (sel, segment_limit) != -1
1498 && __dpmi_get_segment_limit (sel) >= segment_limit)
1499 movedata (sel, 0, _my_ds (), (
unsigned)dest, len);
1503 __dpmi_free_ldt_descriptor (sel);
1515 unsigned long addr = table_base + idx * 8;
1518 return (
int)((
struct seg_descr *)descr)->stype;
1537 if (idx == 0 &&
type == 0)
1538 gdb_puts (
"0x000: null descriptor\n");
1543 static unsigned allowed_descriptors[] = {
1552 unsigned long limit = (descr.
limit1 << 16) | descr.
limit0;
1555 && (allowed_descriptors[
type] & (1 << descr.
stype)) != 0)
1559 ? idx : (idx * 8) | (
type ? (cpl | 4) : 0));
1561 limit = (limit << 12) | 0xfff;
1565 gdb_printf (
"base=0x%02x%02x%04x limit=0x%08lx",
1568 switch (descr.
stype)
1573 descr.
stype == 3 ?
"" :
"in");
1579 memcpy (&gate, &descr,
sizeof gate);
1580 gdb_printf (
"selector=0x%04x offs=0x%04x%04x",
1591 memcpy (&gate, &descr,
sizeof gate);
1592 gdb_printf (
"selector=0x%04x offs=0x%04x%04x",
1595 descr.
stype == 6 ?
"Interrupt" :
"Trap");
1600 descr.
stype == 3 ?
"" :
"in");
1603 memcpy (&gate, &descr,
sizeof gate);
1604 gdb_printf (
"selector=0x%04x offs=0x%04x%04x",
1611 memcpy (&gate, &descr,
sizeof gate);
1612 gdb_printf (
"selector=0x%04x offs=0x%04x%04x",
1615 descr.
stype == 14 ?
"Interrupt" :
"Trap");
1626 descr.
bit32 ?
"32" :
"16",
1628 ?
"Read/Write," :
"Read-Only, ",
1629 descr.
stype & 4 ?
"down" :
"up",
1630 descr.
stype & 1 ?
"" :
", N.Acc");
1641 descr.
bit32 ?
"32" :
"16",
1642 descr.
stype & 2 ?
"Exec/Read" :
"Exec-Only",
1643 descr.
stype & 4 ?
"" :
"N.",
1644 descr.
stype & 1 ?
"" :
", N.Acc");
1656 ? idx : (idx * 8) | (
type ? (cpl | 4) : 0));
1658 gdb_puts (
"Segment not present\n");
1660 gdb_printf (
"Segment type 0x%02x is invalid in this table\n",
1665 gdb_printf (
"0x%03x: Cannot read this descriptor\n", idx);
1672 unsigned short ldtr = 0;
1675 long ldt_entry = -1L;
1680 arg = skip_spaces (arg);
1686 || (ldt_entry & 4) == 0
1687 || (ldt_entry & 3) != (cpl & 3))
1688 error (_(
"Invalid LDT entry 0x%03lx."), (
unsigned long)ldt_entry);
1692 __asm__ __volatile__ (
"sgdt %0" :
"=m" (gdtr) : );
1693 __asm__ __volatile__ (
"sldt %0" :
"=m" (ldtr) : );
1699 gdb_printf (
"LDT is present (at %#x), but unreadable by GDB.\n",
1701 | (ldt_descr.
base1 << 16)
1702 | (ldt_descr.
base2 << 24));
1707 | (ldt_descr.
base1 << 16)
1708 | (ldt_descr.
base2 << 24);
1709 unsigned limit = ldt_descr.
limit0 | (ldt_descr.
limit1 << 16);
1715 limit = (limit << 12) | 0xfff;
1721 max_entry = (limit + 1) / 8;
1725 if (ldt_entry > limit)
1726 error (_(
"Invalid LDT entry %#lx: outside valid limits [0..%#x]"),
1727 (
unsigned long)ldt_entry, limit);
1735 for (i = 0; i < max_entry; i++)
1745 long gdt_entry = -1L;
1750 arg = skip_spaces (arg);
1755 if (gdt_entry < 0 || (gdt_entry & 7) != 0)
1756 error (_(
"Invalid GDT entry 0x%03lx: "
1757 "not an integral multiple of 8."),
1758 (
unsigned long)gdt_entry);
1762 __asm__ __volatile__ (
"sgdt %0" :
"=m" (gdtr) : );
1763 max_entry = (gdtr.limit + 1) / 8;
1767 if (gdt_entry > gdtr.limit)
1768 error (_(
"Invalid GDT entry %#lx: outside valid limits [0..%#x]"),
1769 (
unsigned long)gdt_entry, gdtr.limit);
1777 for (i = 0; i < max_entry; i++)
1786 long idt_entry = -1L;
1791 arg = skip_spaces (arg);
1797 error (_(
"Invalid (negative) IDT entry %ld."), idt_entry);
1801 __asm__ __volatile__ (
"sidt %0" :
"=m" (idtr) : );
1802 max_entry = (idtr.limit + 1) / 8;
1803 if (max_entry > 0x100)
1808 if (idt_entry > idtr.limit)
1809 error (_(
"Invalid IDT entry %#lx: outside valid limits [0..%#x]"),
1810 (
unsigned long)idt_entry, idtr.limit);
1818 for (i = 0; i < max_entry; i++)
1833 unsigned long taskbase, cr3;
1840 __asm__ __volatile__ (
"sgdt %0" :
"=m" (gdtr) : );
1841 __asm__ __volatile__ (
"str %0" :
"=m" (taskreg) : );
1848 offset = gdtr.base + (taskreg & 0xfff8) + 2;
1852 if (offset > 0xfffff)
1855 _farsetsel (_dos_ds);
1856 taskbase = _farnspeekl (offset) & 0xffffffU;
1857 taskbase += _farnspeekl (offset + 2) & 0xff000000U;
1858 if (taskbase > 0xfffff)
1863 cr3 = _farnspeekl (taskbase + 0x1c) & ~0xfff;
1873 unsigned long addr, pte_idx;
1875 for (addr = 0xb0000, pte_idx = 0xb0;
1877 addr += 0x1000, pte_idx++)
1879 if (((_farnspeekl (addr + 4 * pte_idx) & 0xfffff027) ==
1880 (_farnspeekl (addr + 0x1000) & 0xfffff027))
1881 && ((_farnspeekl (addr + 4 * pte_idx + 4) & 0xfffff000) == cr3))
1883 cr3 = addr + 0x1000;
1900 unsigned long pde = 0;
1902 if (
pdbr && n >= 0 && n < 1024)
1904 pde = _farpeekl (_dos_ds,
pdbr + 4*n);
1914 unsigned long pte = 0;
1918 if ((pde & 1) && !(pde & 0x80) && n >= 0 && n < 1024)
1921 pte = _farpeekl (_dos_ds, pde + 4*n);
1933 if ((entry & 1) != 0)
1936 if ((entry & 0x100) && !is_dir)
1938 if ((entry & 0x40) && !is_dir)
1940 gdb_printf (
" %sAcc.", (entry & 0x20) ?
"" :
"Not-");
1941 gdb_printf (
" %sCached", (entry & 0x10) ?
"" :
"Not-");
1942 gdb_printf (
" Write-%s", (entry & 8) ?
"Thru" :
"Back");
1943 gdb_printf (
" %s", (entry & 4) ?
"Usr" :
"Sup");
1944 gdb_printf (
" Read-%s", (entry & 2) ?
"Write" :
"Only");
1950 gdb_printf (
"Page%s not present or not supported; value=0x%lx.\n",
1951 is_dir ?
" Table" :
"", entry >> 1);
1957 long pde_idx = -1, i;
1961 arg = skip_spaces (arg);
1966 if (pde_idx < 0 || pde_idx >= 1024)
1967 error (_(
"Entry %ld is outside valid limits [0..1023]."), pde_idx);
1973 gdb_puts (
"Access to Page Directories is "
1974 "not supported on this system.\n");
1975 else if (pde_idx >= 0)
1978 for (i = 0; i < 1024; i++)
1988 unsigned long pde =
get_pde (n);
1995 "Page Directory entry 0x%lx:\n", n);
1996 for (i = 0; i < 1024; i++)
2001 gdb_printf (
"Page Table not present; value=0x%lx.\n", pde >> 1);
2007 long pde_idx = -1L, i;
2011 arg = skip_spaces (arg);
2016 if (pde_idx < 0 || pde_idx >= 1024)
2017 error (_(
"Entry %ld is outside valid limits [0..1023]."), pde_idx);
2023 gdb_puts (
"Access to Page Tables is not supported on this system.\n");
2024 else if (pde_idx >= 0)
2027 for (i = 0; i < 1024; i++)
2034 CORE_ADDR addr = 0, i;
2038 arg = skip_spaces (arg);
2048 gdb_puts (
"Access to Page Tables is not supported on this system.\n");
2051 int pde_idx = (addr >> 22) & 0x3ff;
2052 int pte_idx = (addr >> 12) & 0x3ff;
2053 unsigned offs = addr & 0xfff;
2055 gdb_printf (
"Page Table entry for address %s:\n",
2082 internal_error (_(
"Cannot allocate redirection storage: "
2083 "not enough memory.\n"));
2089Print information specific to DJGPP (aka MS-DOS) debugging."),
2093Display information about the target system, including CPU, OS, DPMI, etc."),
2096Display entries in the LDT (Local Descriptor Table).\n\
2097Entry number (an expression) as an argument means display only that entry."),
2100Display entries in the GDT (Global Descriptor Table).\n\
2101Entry number (an expression) as an argument means display only that entry."),
2104Display entries in the IDT (Interrupt Descriptor Table).\n\
2105Entry number (an expression) as an argument means display only that entry."),
2108Display entries in the Page Directory.\n\
2109Entry number (an expression) as an argument means display only that entry."),
2112Display entries in Page Tables.\n\
2113Entry number (an expression) as an argument means display only entries\n\
2114from the Page Table pointed to by the specified Page Directory entry."),
2117Display a Page Table entry for a linear address.\n\
2118The address argument must be a linear address, after adding to\n\
2119it the base address of the appropriate segment.\n\
2120The base address of variables and functions in the debuggee's data\n\
2121or code segment is stored in the variable __djgpp_base_address,\n\
2122so use `__djgpp_base_address + (char *)&var' as the argument.\n\
2123For other segments, look up their base address in the output of\n\
2124the `info dos ldt' command."),
2140 if (isatty (fd) && pgid ==
SOME_PID)
2142 errno = pgid ==
SOME_PID ? ENOTTY : ENOSYS;
void * xrealloc(void *ptr, size_t size)
void insert_breakpoints(void)
void maybe_unpush_target()
const std::string & args() const
void raw_collect(int regnum, void *buf) const override
void raw_supply(int regnum, const void *buf) override
struct cmd_list_element * infolist
void error_no_arg(const char *why)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
struct cmd_list_element * add_basic_prefix_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
const char * get_exec_file(int err)
LONGEST parse_and_eval_long(const char *exp)
CORE_ADDR parse_and_eval_address(const char *exp)
int gdbarch_fp0_regnum(struct gdbarch *gdbarch)
struct thread_info * add_thread_silent(process_stratum_target *targ, ptid_t ptid)
void switch_to_thread(struct thread_info *thr)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
static int prog_has_started
static void go32_set_dr7(unsigned long val)
static void go32_sidt(const char *arg, int from_tty)
static void go32_pde(const char *arg, int from_tty)
static void fetch_register(struct regcache *regcache, int regno)
static void go32_sysinfo(const char *arg, int from_tty)
static void display_descriptor(unsigned type, unsigned long base_addr, int idx, int force)
static int get_descriptor(unsigned long table_base, int idx, void *descr)
unsigned short windows_minor
static struct @73 regno_mapping[]
static unsigned long get_pde(int n)
static struct @74 sig_map[]
static int resume_is_step
static void go32_get_windows_version(void)
static struct cmd_list_element * info_dos_cmdlist
static unsigned long get_cr3(void)
static unsigned long go32_get_dr7(void)
static int my_write_child(unsigned child_addr, const void *buf, unsigned len)
static void go32_set_dr(int i, CORE_ADDR addr)
static struct @75 excepn_map[]
static void go32_sldt(const char *arg, int from_tty)
static void go32_pte_for_address(const char *arg, int from_tty)
static unsigned long pdbr
static void display_page_table(long n, int force)
static int inf_mode_valid
static go32_nat_target the_go32_nat_target
static void store_register(const struct regcache *regcache, int regno)
static unsigned long go32_get_dr6(void)
int tcsetpgrp(int fd, pid_t pgid)
struct dtr_reg __attribute__
int redir_to_debugger(cmdline_t *ptr)
static CORE_ADDR go32_get_dr(int i)
static void display_ptable_entry(unsigned long entry, int is_dir, int force, unsigned off)
char * nl_langinfo(nl_item item)
int redir_cmdline_parse(const char *args, cmdline_t *ptr)
static void print_mem(unsigned long datum, const char *header, int in_pages_p)
static char child_cwd[FILENAME_MAX]
static unsigned long get_pte(unsigned long pde, int n)
static int dos_codepage(void)
void _initialize_go32_nat()
static int dr_ref_count[4]
unsigned short windows_major
int redir_debug_init(cmdline_t *ptr)
static int inf_terminal_mode
static void go32_sgdt(const char *arg, int from_tty)
void redir_cmdline_delete(cmdline_t *ptr)
static cmdline_t child_cmd
static int device_mode(int fd, int raw_p)
static void save_npx(void)
static int read_memory_region(unsigned long addr, void *dest, size_t len)
static int terminal_is_ours
static void go32_pte(const char *arg, int from_tty)
int redir_to_child(cmdline_t *ptr)
static enum target_xfer_status go32_xfer_memory(gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len)
static void load_npx(void)
int i386_fp_regnum_p(struct gdbarch *gdbarch, int regnum)
int i386_fpc_regnum_p(struct gdbarch *gdbarch, int regnum)
void i387_supply_fsave(struct regcache *regcache, int regnum, const void *fsave)
void i387_collect_fsave(const struct regcache *regcache, int regnum, void *fsave)
void add_inf_child_target(inf_child_target *target)
void inferior_appeared(struct inferior *inf, int pid)
struct inferior * current_inferior(void)
void generic_mourn_inferior(void)
void clear_proceed_status(int step)
unsigned char processing_gcc_compilation
unsigned short limit __attribute__((packed))
unsigned long base __attribute__((packed))
ptid_t wait(ptid_t, struct target_waitstatus *, target_wait_flags) override
void fetch_registers(struct regcache *, int) override
void terminal_ours_for_output() override
void terminal_inferior() override
bool thread_alive(ptid_t ptid) override
void pass_ctrlc() override
void store_registers(struct regcache *, int) override
void attach(const char *, int) override
void terminal_info(const char *, int) override
void mourn_inferior() override
void create_inferior(const char *, const std::string &, char **, int) override
void terminal_ours() override
std::string pid_to_str(ptid_t) override
void files_info() override
void resume(ptid_t, int, enum gdb_signal) override
void terminal_init() override
enum target_xfer_status xfer_partial(enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) override
target_ops * beneath() const
virtual enum target_xfer_status xfer_partial(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(* set_addr)(int, CORE_ADDR)
unsigned long(* get_control)(void)
unsigned long(* get_status)(void)
void(* set_control)(unsigned long)
CORE_ADDR(* get_addr)(int)
std::string normal_pid_to_str(ptid_t ptid)
void gdb_printf(struct ui_file *stream, const char *format,...)
void printf_unfiltered(const char *format,...)
void gdb_puts(const char *linebuffer, struct ui_file *stream)
static __inline int x86_cpuid(unsigned int __level, unsigned int *__eax, unsigned int *__ebx, unsigned int *__ecx, unsigned int *__edx)
struct x86_dr_low_type x86_dr_low
void x86_cleanup_dregs(void)
void x86_set_debug_register_length(int len)