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
162 asm (
"inb $0xa0, %%al \n\
163 testb $0x20, %%al \n\
187 asm (
"frstor %0":
"=m" (
npx));
236#define r_ofs(x) (offsetof(TSS,x))
245 {
r_ofs (tss_eax), 4},
246 {
r_ofs (tss_ecx), 4},
247 {
r_ofs (tss_edx), 4},
248 {
r_ofs (tss_ebx), 4},
249 {
r_ofs (tss_esp), 4},
250 {
r_ofs (tss_ebp), 4},
251 {
r_ofs (tss_esi), 4},
252 {
r_ofs (tss_edi), 4},
253 {
r_ofs (tss_eip), 4},
254 {
r_ofs (tss_eflags), 4},
289 {1, GDB_SIGNAL_TRAP},
294 {3, GDB_SIGNAL_TRAP},
296 {5, GDB_SIGNAL_SEGV},
299 {8, GDB_SIGNAL_SEGV},
300 {9, GDB_SIGNAL_SEGV},
301 {10, GDB_SIGNAL_BUS},
302 {11, GDB_SIGNAL_SEGV},
303 {12, GDB_SIGNAL_SEGV},
304 {13, GDB_SIGNAL_SEGV},
305 {14, GDB_SIGNAL_SEGV},
306 {16, GDB_SIGNAL_FPE},
307 {17, GDB_SIGNAL_BUS},
308 {31, GDB_SIGNAL_ILL},
309 {0x1b, GDB_SIGNAL_INT},
310 {0x75, GDB_SIGNAL_FPE},
311 {0x78, GDB_SIGNAL_ALRM},
312 {0x79, GDB_SIGNAL_INT},
313 {0x7a, GDB_SIGNAL_QUIT},
314 {-1, GDB_SIGNAL_LAST}
324 {GDB_SIGNAL_SEGV, 13},
325 {GDB_SIGNAL_BUS, 17},
328 {GDB_SIGNAL_TERM, 0x1b},
329 {GDB_SIGNAL_FPE, 0x75},
330 {GDB_SIGNAL_INT, 0x79},
331 {GDB_SIGNAL_QUIT, 0x7a},
332 {GDB_SIGNAL_ALRM, 0x78},
333 {GDB_SIGNAL_PROF, 0x78},
334 {GDB_SIGNAL_LAST, -1}
341 void attach (
const char *,
int)
override;
343 void resume (ptid_t,
int,
enum gdb_signal)
override;
353 const gdb_byte *writebuf,
354 ULONGEST offset, ULONGEST len,
355 ULONGEST *xfered_len)
override;
374 char **,
int)
override;
389You cannot attach to a running program on this platform.\n\
390Use the `run' command to run DJGPP programs."));
403 if (siggnal != GDB_SIGNAL_0 && siggnal != GDB_SIGNAL_TRAP)
406 excepn_map[i].gdb_sig != GDB_SIGNAL_LAST; i++)
414 gdb_signal_to_name (siggnal));
422 target_wait_flags options)
425 unsigned char saved_opcode;
426 unsigned long INT3_addr = 0;
427 int stepping_over_INT = 0;
429 a_tss.tss_eflags &= 0xfeff;
446 read_child (a_tss.tss_eip, &saved_opcode, 1);
447 if (saved_opcode == 0xCD || saved_opcode == 0xCE)
449 unsigned char INT3_opcode = 0xCC;
452 = saved_opcode == 0xCD ? a_tss.tss_eip + 2 : a_tss.tss_eip + 1;
453 stepping_over_INT = 1;
454 read_child (INT3_addr, &saved_opcode, 1);
455 write_child (INT3_addr, &INT3_opcode, 1);
458 a_tss.tss_eflags |= 0x0100;
466 a_tss.tss_irqn = 0xff;
470 a_tss.tss_trap = 0xffff;
490#if __DJGPP_MINOR__ < 3
494#if __DJGPP_MINOR__ < 3
499 if (stepping_over_INT && a_tss.tss_eip == INT3_addr + 1)
503 write_child (a_tss.tss_eip, &saved_opcode, 1);
506 a_tss.tss_eflags |= 0x0100;
510 if (current_directory != NULL)
511 chdir (current_directory);
513 if (a_tss.tss_irqn == 0x21)
514 status->set_exited (a_tss.tss_eax & 0xff);
517 status->set_stopped (GDB_SIGNAL_UNKNOWN);
518 for (i = 0;
sig_map[i].go32_sig != -1; i++)
520 if (a_tss.tss_irqn ==
sig_map[i].go32_sig)
522#if __DJGPP_MINOR__ < 3
524 if (
status->sig () != GDB_SIGNAL_TRAP)
547 internal_error (_(
"Invalid register no. %d in fetch_register."), regno);
576 internal_error (_(
"Invalid register no. %d in store_register."), regno);
600 static void *buffer = NULL;
601 static unsigned buffer_len = 0;
604 if (buffer_len < len)
610 memcpy (buffer, buf, len);
611 res = write_child (child_addr, buffer, len);
620 ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len)
624 if (writebuf != NULL)
627 res = read_child (memaddr, readbuf, len);
642 const char *annex, gdb_byte *readbuf,
643 const gdb_byte *writebuf, ULONGEST offset,
645 ULONGEST *xfered_len)
654 readbuf, writebuf, offset, len,
664 gdb_printf (
"You are running a DJGPP V2 program.\n");
668go32_nat_target::kill_inferior ()
675 const std::string &allargs,
676 char **env,
int from_tty)
685 const char *args = allargs.c_str ();
701 internal_error (_(
"Cannot allocate redirection storage: "
702 "not enough memory.\n"));
705 if (strpbrk (args,
"<>"))
710 error (_(
"Syntax error in command line."));
715 cmdlen = strlen (args);
718 if (cmdlen > 1024*1024)
719 error (_(
"Command line too long."));
721 cmdline = (
char *)
xmalloc (cmdlen + 4);
722 strcpy (cmdline + 1, args);
728 cmdline[0] = strlen (args);
729 cmdline[cmdlen + 1] = 13;
736 result = v2loadimage (exec_file, cmdline, start_state);
742 error (_(
"Load failed for image %s"), exec_file);
744 edi_init (start_state);
745#if __DJGPP_MINOR__ < 3
752 if (!
inf->target_is_pushed (
this))
753 inf->push_target (
this);
790#define CONTROL D_REGS[7]
791#define STATUS D_REGS[6]
800 internal_error (_(
"Invalid register %d in go32_set_dr.\n"), i);
840 internal_error (_(
"Invalid register %d in go32_get_dr.\n"), i);
850 int oldmode, newmode;
855 __dpmi_int (0x21, ®s);
856 if (regs.x.flags & 1)
858 newmode = oldmode = regs.x.dx;
869 regs.x.dx = newmode & 0xff;
870 __dpmi_int (0x21, ®s);
871 if (regs.x.flags & 1)
874 return (oldmode & 0x20) == 0x20;
897 gdb_printf (
"Inferior's terminal is in %s mode.\n",
901#if __DJGPP_MINOR__ > 2
906 for (i = 0; i < DBG_HANDLES; i++)
909 gdb_printf (
"\tFile handle %d is redirected to `%s'.\n",
911 else if (_get_dev_info (
child_cmd.redirection[i]->inf_handle) == -1)
913 (
"\tFile handle %d appears to be closed by inferior.\n", i);
915 else if ((_get_dev_info (
child_cmd.redirection[i]->inf_handle) & 0xdf)
916 != (_get_dev_info (i) & 0xdf))
918 (
"\tFile handle %d appears to be redirected by inferior.\n", i);
932 error (_(
"Cannot redirect standard handles for program: %s."),
933 safe_strerror (errno));
966 error (_(
"Cannot redirect standard handles for debugger: %s."),
967 safe_strerror (errno));
980 return ptid != null_ptid;
996 __dpmi_int (0x21, ®s);
997 if (!(regs.x.flags & 1))
998 return regs.x.bx & 0xffff;
1015 int blen =
sizeof (buf);
1016 int needed = snprintf (buf, blen,
"CP%d",
dos_codepage ());
1020 retval = xstrdup (buf);
1024 retval = xstrdup (
"");
1039 __dpmi_int(0x2f, &r);
1040 if (r.h.al > 2 && r.h.al != 0x80 && r.h.al != 0xff
1041 && (r.h.al > 3 || r.h.ah > 0))
1052print_mem (
unsigned long datum,
const char *header,
int in_pages_p)
1054 if (datum != 0xffffffffUL)
1062 if (datum > 1024 * 1024)
1075 static const char test_pattern[] =
1076 "deadbeafdeadbeafdeadbeafdeadbeafdeadbeaf"
1077 "deadbeafdeadbeafdeadbeafdeadbeafdeadbeaf"
1078 "deadbeafdeadbeafdeadbeafdeadbeafdeadbeafdeadbeaf";
1080 char cpuid_vendor[13];
1081 unsigned cpuid_max = 0, cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx;
1082 unsigned true_dos_version = _get_dos_version (1);
1083 unsigned advertized_dos_version = ((
unsigned int)_osmajor << 8) | _osminor;
1085 char dpmi_vendor_info[129];
1086 int dpmi_vendor_available;
1087 __dpmi_version_ret dpmi_version_data;
1089 __dpmi_free_mem_info mem_info;
1092 cpuid_vendor[0] =
'\0';
1094 strcpy (u.machine,
"Unknown x86");
1095 else if (u.machine[0] ==
'i' && u.machine[1] > 4)
1102 unsigned int eax, ebx, ecx, edx;
1104 if (
x86_cpuid (0, &eax, &ebx, &ecx, &edx))
1107 memcpy (&vendor[0], &ebx, 4);
1108 memcpy (&vendor[4], &ecx, 4);
1109 memcpy (&vendor[8], &edx, 4);
1110 cpuid_vendor[12] =
'\0';
1113 __asm__ __volatile__ (
"xorl %%ebx, %%ebx;"
1114 "xorl %%ecx, %%ecx;"
1115 "xorl %%edx, %%edx;"
1122 :
"=m" (cpuid_vendor[0]),
1123 "=m" (cpuid_vendor[4]),
1124 "=m" (cpuid_vendor[8]),
1127 :
"%eax",
"%ebx",
"%ecx",
"%edx");
1128 cpuid_vendor[12] =
'\0';
1132 gdb_printf (
"CPU Type.......................%s", u.machine);
1133 if (cpuid_vendor[0])
1140 static const char *brand_name[] = {
1148 char cpu_string[80];
1151 int intel_p = strcmp (cpuid_vendor,
"GenuineIntel") == 0;
1152 int amd_p = strcmp (cpuid_vendor,
"AuthenticAMD") == 0;
1153 int hygon_p = strcmp (cpuid_vendor,
"HygonGenuine") == 0;
1154 unsigned cpu_family, cpu_model;
1158 x86_cpuid (1, &cpuid_eax, &cpuid_ebx, NULL, &cpuid_edx);
1160 __asm__ __volatile__ (
"movl $1, %%eax;"
1168 brand_idx = cpuid_ebx & 0xff;
1169 cpu_family = (cpuid_eax >> 8) & 0xf;
1170 cpu_model = (cpuid_eax >> 4) & 0xf;
1171 cpu_brand[0] =
'\0';
1175 && brand_idx <
sizeof(brand_name)/
sizeof(brand_name[0])
1176 && *brand_name[brand_idx])
1177 strcpy (cpu_brand, brand_name[brand_idx]);
1178 else if (cpu_family == 5)
1180 if (((cpuid_eax >> 12) & 3) == 0 && cpu_model == 4)
1181 strcpy (cpu_brand,
" MMX");
1182 else if (cpu_model > 1 && ((cpuid_eax >> 12) & 3) == 1)
1183 strcpy (cpu_brand,
" OverDrive");
1184 else if (cpu_model > 1 && ((cpuid_eax >> 12) & 3) == 2)
1185 strcpy (cpu_brand,
" Dual");
1187 else if (cpu_family == 6 && cpu_model < 8)
1192 strcpy (cpu_brand,
" Pro");
1195 strcpy (cpu_brand,
" II");
1198 strcpy (cpu_brand,
" II Xeon");
1201 strcpy (cpu_brand,
" Celeron");
1204 strcpy (cpu_brand,
" III");
1214 strcpy (cpu_brand,
"486/5x86");
1223 strcpy (cpu_brand,
"-K5");
1227 strcpy (cpu_brand,
"-K6");
1230 strcpy (cpu_brand,
"-K6-2");
1233 strcpy (cpu_brand,
"-K6-III");
1243 strcpy (cpu_brand,
" Athlon");
1246 strcpy (cpu_brand,
" Duron");
1252 xsnprintf (cpu_string,
sizeof (cpu_string),
"%s%s Model %d Stepping %d",
1253 intel_p ?
"Pentium" : (amd_p ?
"AMD" : (hygon_p ?
"Hygon" :
"ix86")),
1254 cpu_brand, cpu_model, cpuid_eax & 0xf);
1256 if (((cpuid_edx & (6 | (0x0d << 23))) != 0)
1257 || ((cpuid_edx & 1) == 0)
1258 || ((amd_p || hygon_p) && (cpuid_edx & (3 << 30)) != 0))
1260 gdb_puts (
"CPU Features...................");
1263 if ((cpuid_edx & 1) == 0)
1265 if ((cpuid_edx & (1 << 1)) != 0)
1267 if ((cpuid_edx & (1 << 2)) != 0)
1269 if ((cpuid_edx & (1 << 4)) != 0)
1271 if ((cpuid_edx & (1 << 23)) != 0)
1273 if ((cpuid_edx & (1 << 25)) != 0)
1275 if ((cpuid_edx & (1 << 26)) != 0)
1277 if (amd_p || hygon_p)
1279 if ((cpuid_edx & (1 << 31)) != 0)
1281 if ((cpuid_edx & (1 << 30)) != 0)
1288 gdb_printf (
"DOS Version....................%s %s.%s",
1289 _os_flavor, u.release, u.version);
1290 if (true_dos_version != advertized_dos_version)
1291 gdb_printf (
" (disguised as v%d.%d)", _osmajor, _osminor);
1297 const char *windows_flavor;
1299 gdb_printf (
"Windows Version................%d.%02d (Windows ",
1304 windows_flavor =
"3.X";
1310 windows_flavor =
"95, 95A, or 95B";
1313 windows_flavor =
"95B OSR2.1 or 95C OSR2.5";
1316 windows_flavor =
"98 or 98 SE";
1319 windows_flavor =
"ME";
1322 windows_flavor =
"9X";
1327 windows_flavor =
"??";
1332 else if (true_dos_version == 0x532 && advertized_dos_version == 0x500)
1333 gdb_printf (
"Windows Version................"
1334 "Windows NT family (W2K/XP/W2K3/Vista/W2K8)\n");
1339 memcpy (dpmi_vendor_info, test_pattern,
sizeof(dpmi_vendor_info));
1340 dpmi_vendor_available =
1341 __dpmi_get_capabilities (&dpmi_flags, dpmi_vendor_info);
1342 if (dpmi_vendor_available == 0
1343 && memcmp (dpmi_vendor_info, test_pattern,
1344 sizeof(dpmi_vendor_info)) != 0)
1348 if (!memchr (&dpmi_vendor_info[2], 0, 126))
1349 dpmi_vendor_info[128] =
'\0';
1350 gdb_printf (
"DPMI Host......................"
1351 "%s v%d.%d (capabilities: %#x)\n",
1352 &dpmi_vendor_info[2],
1353 (
unsigned)dpmi_vendor_info[0],
1354 (
unsigned)dpmi_vendor_info[1],
1355 ((
unsigned)dpmi_flags & 0x7f));
1358 gdb_printf (
"DPMI Host......................(Info not available)\n");
1359 __dpmi_get_version (&dpmi_version_data);
1360 gdb_printf (
"DPMI Version...................%d.%02d\n",
1361 dpmi_version_data.major, dpmi_version_data.minor);
1362 gdb_printf (
"DPMI Info......................"
1363 "%s-bit DPMI, with%s Virtual Memory support\n",
1364 (dpmi_version_data.flags & 1) ?
"32" :
"16",
1365 (dpmi_version_data.flags & 4) ?
"" :
"out");
1366 gdb_printf (
"%*sInterrupts reflected to %s mode\n", 31,
"",
1367 (dpmi_version_data.flags & 2) ?
"V86" :
"Real");
1368 gdb_printf (
"%*sProcessor type: i%d86\n", 31,
"",
1369 dpmi_version_data.cpu);
1370 gdb_printf (
"%*sPIC base interrupt: Master: %#x Slave: %#x\n", 31,
"",
1371 dpmi_version_data.master_pic, dpmi_version_data.slave_pic);
1376 __asm__ __volatile__ (
"pushfl ; popl %0" :
"=g" (eflags));
1377 gdb_printf (
"Protection....................."
1378 "Ring %d (in %s), with%s I/O protection\n",
1379 a_tss.tss_cs & 3, (a_tss.tss_cs & 4) ?
"LDT" :
"GDT",
1380 (a_tss.tss_cs & 3) > ((eflags >> 12) & 3) ?
"" :
"out");
1383 __dpmi_get_free_memory_information (&mem_info);
1384 print_mem (mem_info.total_number_of_physical_pages,
1385 "DPMI Total Physical Memory.....", 1);
1386 print_mem (mem_info.total_number_of_free_pages,
1387 "DPMI Free Physical Memory......", 1);
1388 print_mem (mem_info.size_of_paging_file_partition_in_pages,
1389 "DPMI Swap Space................", 1);
1390 print_mem (mem_info.linear_address_space_size_in_pages,
1391 "DPMI Total Linear Address Size.", 1);
1392 print_mem (mem_info.free_linear_address_space_in_pages,
1393 "DPMI Free Linear Address Size..", 1);
1394 print_mem (mem_info.largest_available_free_block_in_bytes,
1395 "DPMI Largest Free Memory Block.", 0);
1399 __dpmi_int (0x21, ®s);
1400 print_mem (regs.x.bx << 4,
"Free DOS Memory................", 0);
1402 __dpmi_int (0x21, ®s);
1403 if ((regs.x.flags & 1) == 0)
1405 static const char *dos_hilo[] = {
1406 "Low",
"",
"",
"",
"High",
"",
"",
"",
"High, then Low"
1408 static const char *dos_fit[] = {
1409 "First",
"Best",
"Last"
1411 int hilo_idx = (regs.x.ax >> 4) & 0x0f;
1412 int fit_idx = regs.x.ax & 0x0f;
1418 gdb_printf (
"DOS Memory Allocation..........%s memory, %s fit\n",
1419 dos_hilo[hilo_idx], dos_fit[fit_idx]);
1421 __dpmi_int (0x21, ®s);
1422 if ((regs.x.flags & 1) != 0)
1424 gdb_printf (
"%*sUMBs %sin DOS memory chain\n", 31,
"",
1425 regs.h.al == 0 ?
"not " :
"");
1460 unsigned long dos_ds_limit = __dpmi_get_segment_limit (_dos_ds);
1464 if (addr <= dos_ds_limit - len)
1465 dosmemget (addr, len, dest);
1470 int sel = __dpmi_allocate_ldt_descriptors (1);
1476 int access_rights = __dpmi_get_descriptor_access_rights (sel);
1477 size_t segment_limit = len - 1;
1485 if (len > 1024 * 1024)
1487 access_rights |= 0x8000;
1490 segment_limit |= 0xfff;
1493 access_rights &= ~0x8000;
1495 if (__dpmi_set_segment_base_address (sel, addr) != -1
1496 && __dpmi_set_descriptor_access_rights (sel, access_rights) != -1
1497 && __dpmi_set_segment_limit (sel, segment_limit) != -1
1500 && __dpmi_get_segment_limit (sel) >= segment_limit)
1501 movedata (sel, 0, _my_ds (), (
unsigned)dest, len);
1505 __dpmi_free_ldt_descriptor (sel);
1517 unsigned long addr = table_base + idx * 8;
1520 return (
int)((
struct seg_descr *)descr)->stype;
1539 if (idx == 0 &&
type == 0)
1540 gdb_puts (
"0x000: null descriptor\n");
1545 static unsigned allowed_descriptors[] = {
1554 unsigned long limit = (descr.
limit1 << 16) | descr.
limit0;
1557 && (allowed_descriptors[
type] & (1 << descr.
stype)) != 0)
1561 ? idx : (idx * 8) | (
type ? (cpl | 4) : 0));
1563 limit = (limit << 12) | 0xfff;
1567 gdb_printf (
"base=0x%02x%02x%04x limit=0x%08lx",
1570 switch (descr.
stype)
1575 descr.
stype == 3 ?
"" :
"in");
1581 memcpy (&gate, &descr,
sizeof gate);
1582 gdb_printf (
"selector=0x%04x offs=0x%04x%04x",
1593 memcpy (&gate, &descr,
sizeof gate);
1594 gdb_printf (
"selector=0x%04x offs=0x%04x%04x",
1597 descr.
stype == 6 ?
"Interrupt" :
"Trap");
1602 descr.
stype == 3 ?
"" :
"in");
1605 memcpy (&gate, &descr,
sizeof gate);
1606 gdb_printf (
"selector=0x%04x offs=0x%04x%04x",
1613 memcpy (&gate, &descr,
sizeof gate);
1614 gdb_printf (
"selector=0x%04x offs=0x%04x%04x",
1617 descr.
stype == 14 ?
"Interrupt" :
"Trap");
1628 descr.
bit32 ?
"32" :
"16",
1630 ?
"Read/Write," :
"Read-Only, ",
1631 descr.
stype & 4 ?
"down" :
"up",
1632 descr.
stype & 1 ?
"" :
", N.Acc");
1643 descr.
bit32 ?
"32" :
"16",
1644 descr.
stype & 2 ?
"Exec/Read" :
"Exec-Only",
1645 descr.
stype & 4 ?
"" :
"N.",
1646 descr.
stype & 1 ?
"" :
", N.Acc");
1658 ? idx : (idx * 8) | (
type ? (cpl | 4) : 0));
1660 gdb_puts (
"Segment not present\n");
1662 gdb_printf (
"Segment type 0x%02x is invalid in this table\n",
1667 gdb_printf (
"0x%03x: Cannot read this descriptor\n", idx);
1674 unsigned short ldtr = 0;
1677 long ldt_entry = -1L;
1682 arg = skip_spaces (arg);
1688 || (ldt_entry & 4) == 0
1689 || (ldt_entry & 3) != (cpl & 3))
1690 error (_(
"Invalid LDT entry 0x%03lx."), (
unsigned long)ldt_entry);
1694 __asm__ __volatile__ (
"sgdt %0" :
"=m" (gdtr) : );
1695 __asm__ __volatile__ (
"sldt %0" :
"=m" (ldtr) : );
1701 gdb_printf (
"LDT is present (at %#x), but unreadable by GDB.\n",
1703 | (ldt_descr.
base1 << 16)
1704 | (ldt_descr.
base2 << 24));
1709 | (ldt_descr.
base1 << 16)
1710 | (ldt_descr.
base2 << 24);
1711 unsigned limit = ldt_descr.
limit0 | (ldt_descr.
limit1 << 16);
1717 limit = (limit << 12) | 0xfff;
1723 max_entry = (limit + 1) / 8;
1727 if (ldt_entry > limit)
1728 error (_(
"Invalid LDT entry %#lx: outside valid limits [0..%#x]"),
1729 (
unsigned long)ldt_entry, limit);
1737 for (i = 0; i < max_entry; i++)
1747 long gdt_entry = -1L;
1752 arg = skip_spaces (arg);
1757 if (gdt_entry < 0 || (gdt_entry & 7) != 0)
1758 error (_(
"Invalid GDT entry 0x%03lx: "
1759 "not an integral multiple of 8."),
1760 (
unsigned long)gdt_entry);
1764 __asm__ __volatile__ (
"sgdt %0" :
"=m" (gdtr) : );
1765 max_entry = (gdtr.limit + 1) / 8;
1769 if (gdt_entry > gdtr.limit)
1770 error (_(
"Invalid GDT entry %#lx: outside valid limits [0..%#x]"),
1771 (
unsigned long)gdt_entry, gdtr.limit);
1779 for (i = 0; i < max_entry; i++)
1788 long idt_entry = -1L;
1793 arg = skip_spaces (arg);
1799 error (_(
"Invalid (negative) IDT entry %ld."), idt_entry);
1803 __asm__ __volatile__ (
"sidt %0" :
"=m" (idtr) : );
1804 max_entry = (idtr.limit + 1) / 8;
1805 if (max_entry > 0x100)
1810 if (idt_entry > idtr.limit)
1811 error (_(
"Invalid IDT entry %#lx: outside valid limits [0..%#x]"),
1812 (
unsigned long)idt_entry, idtr.limit);
1820 for (i = 0; i < max_entry; i++)
1835 unsigned long taskbase, cr3;
1842 __asm__ __volatile__ (
"sgdt %0" :
"=m" (gdtr) : );
1843 __asm__ __volatile__ (
"str %0" :
"=m" (taskreg) : );
1850 offset = gdtr.base + (taskreg & 0xfff8) + 2;
1854 if (offset > 0xfffff)
1857 _farsetsel (_dos_ds);
1858 taskbase = _farnspeekl (offset) & 0xffffffU;
1859 taskbase += _farnspeekl (offset + 2) & 0xff000000U;
1860 if (taskbase > 0xfffff)
1865 cr3 = _farnspeekl (taskbase + 0x1c) & ~0xfff;
1875 unsigned long addr, pte_idx;
1877 for (addr = 0xb0000, pte_idx = 0xb0;
1879 addr += 0x1000, pte_idx++)
1881 if (((_farnspeekl (addr + 4 * pte_idx) & 0xfffff027) ==
1882 (_farnspeekl (addr + 0x1000) & 0xfffff027))
1883 && ((_farnspeekl (addr + 4 * pte_idx + 4) & 0xfffff000) == cr3))
1885 cr3 = addr + 0x1000;
1902 unsigned long pde = 0;
1904 if (
pdbr && n >= 0 && n < 1024)
1906 pde = _farpeekl (_dos_ds,
pdbr + 4*n);
1916 unsigned long pte = 0;
1920 if ((pde & 1) && !(pde & 0x80) && n >= 0 && n < 1024)
1923 pte = _farpeekl (_dos_ds, pde + 4*n);
1935 if ((entry & 1) != 0)
1938 if ((entry & 0x100) && !is_dir)
1940 if ((entry & 0x40) && !is_dir)
1942 gdb_printf (
" %sAcc.", (entry & 0x20) ?
"" :
"Not-");
1943 gdb_printf (
" %sCached", (entry & 0x10) ?
"" :
"Not-");
1944 gdb_printf (
" Write-%s", (entry & 8) ?
"Thru" :
"Back");
1945 gdb_printf (
" %s", (entry & 4) ?
"Usr" :
"Sup");
1946 gdb_printf (
" Read-%s", (entry & 2) ?
"Write" :
"Only");
1952 gdb_printf (
"Page%s not present or not supported; value=0x%lx.\n",
1953 is_dir ?
" Table" :
"", entry >> 1);
1959 long pde_idx = -1, i;
1963 arg = skip_spaces (arg);
1968 if (pde_idx < 0 || pde_idx >= 1024)
1969 error (_(
"Entry %ld is outside valid limits [0..1023]."), pde_idx);
1975 gdb_puts (
"Access to Page Directories is "
1976 "not supported on this system.\n");
1977 else if (pde_idx >= 0)
1980 for (i = 0; i < 1024; i++)
1990 unsigned long pde =
get_pde (n);
1997 "Page Directory entry 0x%lx:\n", n);
1998 for (i = 0; i < 1024; i++)
2003 gdb_printf (
"Page Table not present; value=0x%lx.\n", pde >> 1);
2009 long pde_idx = -1L, i;
2013 arg = skip_spaces (arg);
2018 if (pde_idx < 0 || pde_idx >= 1024)
2019 error (_(
"Entry %ld is outside valid limits [0..1023]."), pde_idx);
2025 gdb_puts (
"Access to Page Tables is not supported on this system.\n");
2026 else if (pde_idx >= 0)
2029 for (i = 0; i < 1024; i++)
2036 CORE_ADDR addr = 0, i;
2040 arg = skip_spaces (arg);
2050 gdb_puts (
"Access to Page Tables is not supported on this system.\n");
2053 int pde_idx = (addr >> 22) & 0x3ff;
2054 int pte_idx = (addr >> 12) & 0x3ff;
2055 unsigned offs = addr & 0xfff;
2057 gdb_printf (
"Page Table entry for address %s:\n",
2084 internal_error (_(
"Cannot allocate redirection storage: "
2085 "not enough memory.\n"));
2091Print information specific to DJGPP (aka MS-DOS) debugging."),
2095Display information about the target system, including CPU, OS, DPMI, etc."),
2098Display entries in the LDT (Local Descriptor Table).\n\
2099Entry number (an expression) as an argument means display only that entry."),
2102Display entries in the GDT (Global Descriptor Table).\n\
2103Entry number (an expression) as an argument means display only that entry."),
2106Display entries in the IDT (Interrupt Descriptor Table).\n\
2107Entry number (an expression) as an argument means display only that entry."),
2110Display entries in the Page Directory.\n\
2111Entry number (an expression) as an argument means display only that entry."),
2114Display entries in Page Tables.\n\
2115Entry number (an expression) as an argument means display only entries\n\
2116from the Page Table pointed to by the specified Page Directory entry."),
2119Display a Page Table entry for a linear address.\n\
2120The address argument must be a linear address, after adding to\n\
2121it the base address of the appropriate segment.\n\
2122The base address of variables and functions in the debuggee's data\n\
2123or code segment is stored in the variable __djgpp_base_address,\n\
2124so use `__djgpp_base_address + (char *)&var' as the argument.\n\
2125For other segments, look up their base address in the output of\n\
2126the `info dos ldt' command."),
2142 if (isatty (fd) && pgid ==
SOME_PID)
2144 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 unsigned long get_pde(int n)
static int resume_is_step
static struct @72 excepn_map[]
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 void go32_sldt(const char *arg, int from_tty)
static struct @70 regno_mapping[]
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 struct @71 sig_map[]
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)