diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:36:23 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:46:02 -0500 |
commit | c583a2520616c2736cffc389c89a48b159366e6c (patch) | |
tree | b4925f26506fcee96c16119431c01760f05db95d /gdb/go32-nat.c | |
parent | ca7f92c2f15b86b09c4a8ad14806bef666308d31 (diff) | |
download | binutils-users/simark/clang-format.zip binutils-users/simark/clang-format.tar.gz binutils-users/simark/clang-format.tar.bz2 |
Run clang-format.shusers/simark/clang-format
Change-Id: Ia948cc26d534b0dd02702244d52434b1a2093968
Diffstat (limited to 'gdb/go32-nat.c')
-rw-r--r-- | gdb/go32-nat.c | 915 |
1 files changed, 446 insertions, 469 deletions
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c index 566d6d5..2aa39f2 100644 --- a/gdb/go32-nat.c +++ b/gdb/go32-nat.c @@ -124,33 +124,31 @@ /* This code will be provided from DJGPP 2.03 on. Until then I code it here. */ typedef struct - { - unsigned short sig0; - unsigned short sig1; - unsigned short sig2; - unsigned short sig3; - unsigned short exponent:15; - unsigned short sign:1; - } -NPXREG; +{ + unsigned short sig0; + unsigned short sig1; + unsigned short sig2; + unsigned short sig3; + unsigned short exponent : 15; + unsigned short sign : 1; +} NPXREG; typedef struct - { - unsigned int control; - unsigned int status; - unsigned int tag; - unsigned int eip; - unsigned int cs; - unsigned int dataptr; - unsigned int datasel; - NPXREG reg[8]; - } -NPX; +{ + unsigned int control; + unsigned int status; + unsigned int tag; + unsigned int eip; + unsigned int cs; + unsigned int dataptr; + unsigned int datasel; + NPXREG reg[8]; +} NPX; static NPX npx; -static void save_npx (void); /* Save the FPU of the debugged program. */ -static void load_npx (void); /* Restore the FPU of the debugged program. */ +static void save_npx (void); /* Save the FPU of the debugged program. */ +static void load_npx (void); /* Restore the FPU of the debugged program. */ /* ------------------------------------------------------------------------- */ /* Store the contents of the NPX in the global variable `npx'. */ @@ -170,25 +168,26 @@ save_npx (void) 1: \n\ fnsave %0 \n\ fwait " -: "=m" (npx) -: /* No input */ -: "%eax"); + : "=m"(npx) + : /* No input */ + : "%eax"); } /* *INDENT-ON* */ - /* ------------------------------------------------------------------------- */ /* Reload the contents of the NPX from the global variable `npx'. */ static void load_npx (void) { - asm ("frstor %0":"=m" (npx)); + asm ("frstor %0" : "=m"(npx)); } + /* ------------------------------------------------------------------------- */ /* Stubs for the missing redirection functions. */ -typedef struct { +typedef struct +{ char *command; int redirected; } cmdline_t; @@ -224,7 +223,12 @@ redir_debug_init (cmdline_t *ptr) } #endif /* __DJGPP_MINOR < 3 */ -typedef enum { wp_insert, wp_remove, wp_count } wp_op; +typedef enum +{ + wp_insert, + wp_remove, + wp_count +} wp_op; /* This holds the current reference counts for each debug register. */ static int dr_ref_count[4]; @@ -233,106 +237,101 @@ static int dr_ref_count[4]; static int prog_has_started = 0; -#define r_ofs(x) (offsetof(TSS,x)) +#define r_ofs(x) (offsetof (TSS, x)) static struct { size_t tss_ofs; size_t size; -} -regno_mapping[] = -{ - {r_ofs (tss_eax), 4}, /* normal registers, from a_tss */ - {r_ofs (tss_ecx), 4}, - {r_ofs (tss_edx), 4}, - {r_ofs (tss_ebx), 4}, - {r_ofs (tss_esp), 4}, - {r_ofs (tss_ebp), 4}, - {r_ofs (tss_esi), 4}, - {r_ofs (tss_edi), 4}, - {r_ofs (tss_eip), 4}, - {r_ofs (tss_eflags), 4}, - {r_ofs (tss_cs), 2}, - {r_ofs (tss_ss), 2}, - {r_ofs (tss_ds), 2}, - {r_ofs (tss_es), 2}, - {r_ofs (tss_fs), 2}, - {r_ofs (tss_gs), 2}, - {0, 10}, /* 8 FP registers, from npx.reg[] */ - {1, 10}, - {2, 10}, - {3, 10}, - {4, 10}, - {5, 10}, - {6, 10}, - {7, 10}, - /* The order of the next 7 registers must be consistent +} regno_mapping[] = { + { r_ofs (tss_eax), 4 }, /* normal registers, from a_tss */ + { r_ofs (tss_ecx), 4 }, + { r_ofs (tss_edx), 4 }, + { r_ofs (tss_ebx), 4 }, + { r_ofs (tss_esp), 4 }, + { r_ofs (tss_ebp), 4 }, + { r_ofs (tss_esi), 4 }, + { r_ofs (tss_edi), 4 }, + { r_ofs (tss_eip), 4 }, + { r_ofs (tss_eflags), 4 }, + { r_ofs (tss_cs), 2 }, + { r_ofs (tss_ss), 2 }, + { r_ofs (tss_ds), 2 }, + { r_ofs (tss_es), 2 }, + { r_ofs (tss_fs), 2 }, + { r_ofs (tss_gs), 2 }, + { 0, 10 }, /* 8 FP registers, from npx.reg[] */ + { 1, 10 }, + { 2, 10 }, + { 3, 10 }, + { 4, 10 }, + { 5, 10 }, + { 6, 10 }, + { 7, 10 }, + /* The order of the next 7 registers must be consistent with their numbering in config/i386/tm-i386.h, which see. */ - {0, 2}, /* control word, from npx */ - {4, 2}, /* status word, from npx */ - {8, 2}, /* tag word, from npx */ - {16, 2}, /* last FP exception CS from npx */ - {12, 4}, /* last FP exception EIP from npx */ - {24, 2}, /* last FP exception operand selector from npx */ - {20, 4}, /* last FP exception operand offset from npx */ - {18, 2} /* last FP opcode from npx */ + { 0, 2 }, /* control word, from npx */ + { 4, 2 }, /* status word, from npx */ + { 8, 2 }, /* tag word, from npx */ + { 16, 2 }, /* last FP exception CS from npx */ + { 12, 4 }, /* last FP exception EIP from npx */ + { 24, 2 }, /* last FP exception operand selector from npx */ + { 20, 4 }, /* last FP exception operand offset from npx */ + { 18, 2 } /* last FP opcode from npx */ }; static struct - { - int go32_sig; - enum gdb_signal gdb_sig; - } -sig_map[] = -{ - {0, GDB_SIGNAL_FPE}, - {1, GDB_SIGNAL_TRAP}, - /* Exception 2 is triggered by the NMI. DJGPP handles it as SIGILL, +{ + int go32_sig; + enum gdb_signal gdb_sig; +} sig_map[] + = { { 0, GDB_SIGNAL_FPE }, + { 1, GDB_SIGNAL_TRAP }, + /* Exception 2 is triggered by the NMI. DJGPP handles it as SIGILL, but I think SIGBUS is better, since the NMI is usually activated as a result of a memory parity check failure. */ - {2, GDB_SIGNAL_BUS}, - {3, GDB_SIGNAL_TRAP}, - {4, GDB_SIGNAL_FPE}, - {5, GDB_SIGNAL_SEGV}, - {6, GDB_SIGNAL_ILL}, - {7, GDB_SIGNAL_EMT}, /* no-coprocessor exception */ - {8, GDB_SIGNAL_SEGV}, - {9, GDB_SIGNAL_SEGV}, - {10, GDB_SIGNAL_BUS}, - {11, GDB_SIGNAL_SEGV}, - {12, GDB_SIGNAL_SEGV}, - {13, GDB_SIGNAL_SEGV}, - {14, GDB_SIGNAL_SEGV}, - {16, GDB_SIGNAL_FPE}, - {17, GDB_SIGNAL_BUS}, - {31, GDB_SIGNAL_ILL}, - {0x1b, GDB_SIGNAL_INT}, - {0x75, GDB_SIGNAL_FPE}, - {0x78, GDB_SIGNAL_ALRM}, - {0x79, GDB_SIGNAL_INT}, - {0x7a, GDB_SIGNAL_QUIT}, - {-1, GDB_SIGNAL_LAST} -}; + { 2, GDB_SIGNAL_BUS }, + { 3, GDB_SIGNAL_TRAP }, + { 4, GDB_SIGNAL_FPE }, + { 5, GDB_SIGNAL_SEGV }, + { 6, GDB_SIGNAL_ILL }, + { 7, GDB_SIGNAL_EMT }, /* no-coprocessor exception */ + { 8, GDB_SIGNAL_SEGV }, + { 9, GDB_SIGNAL_SEGV }, + { 10, GDB_SIGNAL_BUS }, + { 11, GDB_SIGNAL_SEGV }, + { 12, GDB_SIGNAL_SEGV }, + { 13, GDB_SIGNAL_SEGV }, + { 14, GDB_SIGNAL_SEGV }, + { 16, GDB_SIGNAL_FPE }, + { 17, GDB_SIGNAL_BUS }, + { 31, GDB_SIGNAL_ILL }, + { 0x1b, GDB_SIGNAL_INT }, + { 0x75, GDB_SIGNAL_FPE }, + { 0x78, GDB_SIGNAL_ALRM }, + { 0x79, GDB_SIGNAL_INT }, + { 0x7a, GDB_SIGNAL_QUIT }, + { -1, GDB_SIGNAL_LAST } }; -static struct { +static struct +{ enum gdb_signal gdb_sig; int djgpp_excepno; -} excepn_map[] = { - {GDB_SIGNAL_0, -1}, - {GDB_SIGNAL_ILL, 6}, /* Invalid Opcode */ - {GDB_SIGNAL_EMT, 7}, /* triggers SIGNOFP */ - {GDB_SIGNAL_SEGV, 13}, /* GPF */ - {GDB_SIGNAL_BUS, 17}, /* Alignment Check */ - /* The rest are fake exceptions, see dpmiexcp.c in djlsr*.zip for +} excepn_map[] + = { { GDB_SIGNAL_0, -1 }, + { GDB_SIGNAL_ILL, 6 }, /* Invalid Opcode */ + { GDB_SIGNAL_EMT, 7 }, /* triggers SIGNOFP */ + { GDB_SIGNAL_SEGV, 13 }, /* GPF */ + { GDB_SIGNAL_BUS, 17 }, /* Alignment Check */ + /* The rest are fake exceptions, see dpmiexcp.c in djlsr*.zip for details. */ - {GDB_SIGNAL_TERM, 0x1b}, /* triggers Ctrl-Break type of SIGINT */ - {GDB_SIGNAL_FPE, 0x75}, - {GDB_SIGNAL_INT, 0x79}, - {GDB_SIGNAL_QUIT, 0x7a}, - {GDB_SIGNAL_ALRM, 0x78}, /* triggers SIGTIMR */ - {GDB_SIGNAL_PROF, 0x78}, - {GDB_SIGNAL_LAST, -1} -}; + { GDB_SIGNAL_TERM, 0x1b }, /* triggers Ctrl-Break type of SIGINT */ + { GDB_SIGNAL_FPE, 0x75 }, + { GDB_SIGNAL_INT, 0x79 }, + { GDB_SIGNAL_QUIT, 0x7a }, + { GDB_SIGNAL_ALRM, 0x78 }, /* triggers SIGTIMR */ + { GDB_SIGNAL_PROF, 0x78 }, + { GDB_SIGNAL_LAST, -1 } }; /* The go32 target. */ @@ -348,8 +347,7 @@ struct go32_nat_target final : public x86_nat_target<inf_child_target> void store_registers (struct regcache *, int) override; enum target_xfer_status xfer_partial (enum target_object object, - const char *annex, - gdb_byte *readbuf, + const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) override; @@ -370,8 +368,8 @@ struct go32_nat_target final : public x86_nat_target<inf_child_target> void kill () override; - void create_inferior (const char *, const std::string &, - char **, int) override; + void create_inferior (const char *, const std::string &, char **, + int) override; void mourn_inferior () override; @@ -385,7 +383,7 @@ static go32_nat_target the_go32_nat_target; void go32_nat_target::attach (const char *args, int from_tty) { - error (_("\ + error (_ ("\ You cannot attach to a running program on this platform.\n\ Use the `run' command to run DJGPP programs.")); } @@ -402,8 +400,8 @@ go32_nat_target::resume (ptid_t ptid, int step, enum gdb_signal siggnal) if (siggnal != GDB_SIGNAL_0 && siggnal != GDB_SIGNAL_TRAP) { - for (i = 0, resume_signal = -1; - excepn_map[i].gdb_sig != GDB_SIGNAL_LAST; i++) + for (i = 0, resume_signal = -1; excepn_map[i].gdb_sig != GDB_SIGNAL_LAST; + i++) if (excepn_map[i].gdb_sig == siggnal) { resume_signal = excepn_map[i].djgpp_excepno; @@ -426,7 +424,7 @@ go32_nat_target::wait (ptid_t ptid, struct target_waitstatus *status, unsigned long INT3_addr = 0; int stepping_over_INT = 0; - a_tss.tss_eflags &= 0xfeff; /* Reset the single-step flag (TF). */ + a_tss.tss_eflags &= 0xfeff; /* Reset the single-step flag (TF). */ if (resume_is_step) { /* If the next instruction is INT xx or INTO, we need to handle @@ -467,7 +465,7 @@ go32_nat_target::wait (ptid_t ptid, struct target_waitstatus *status, } else { - a_tss.tss_trap = 0xffff; /* run_child looks for this. */ + a_tss.tss_trap = 0xffff; /* run_child looks for this. */ a_tss.tss_irqn = resume_signal; } @@ -499,7 +497,7 @@ go32_nat_target::wait (ptid_t ptid, struct target_waitstatus *status, if (stepping_over_INT && a_tss.tss_eip == INT3_addr + 1) { /* Restore the original opcode. */ - a_tss.tss_eip--; /* EIP points *after* the INT3 instruction. */ + a_tss.tss_eip--; /* EIP points *after* the INT3 instruction. */ write_child (a_tss.tss_eip, &saved_opcode, 1); /* Simulate a TRAP exception. */ a_tss.tss_irqn = 1; @@ -540,11 +538,11 @@ fetch_register (struct regcache *regcache, int regno) if (regno < gdbarch_fp0_regnum (gdbarch)) regcache->raw_supply (regno, (char *) &a_tss + regno_mapping[regno].tss_ofs); - else if (i386_fp_regnum_p (gdbarch, regno) || i386_fpc_regnum_p (gdbarch, - regno)) + else if (i386_fp_regnum_p (gdbarch, regno) + || i386_fpc_regnum_p (gdbarch, regno)) i387_supply_fsave (regcache, regno, &npx); else - internal_error (_("Invalid register no. %d in fetch_register."), regno); + internal_error (_ ("Invalid register no. %d in fetch_register."), regno); } void @@ -554,9 +552,7 @@ go32_nat_target::fetch_registers (struct regcache *regcache, int regno) fetch_register (regcache, regno); else { - for (regno = 0; - regno < gdbarch_fp0_regnum (regcache->arch ()); - regno++) + for (regno = 0; regno < gdbarch_fp0_regnum (regcache->arch ()); regno++) fetch_register (regcache, regno); i387_supply_fsave (regcache, -1, &npx); } @@ -569,11 +565,11 @@ store_register (const struct regcache *regcache, int regno) if (regno < gdbarch_fp0_regnum (gdbarch)) regcache->raw_collect (regno, (char *) &a_tss + regno_mapping[regno].tss_ofs); - else if (i386_fp_regnum_p (gdbarch, regno) || i386_fpc_regnum_p (gdbarch, - regno)) + else if (i386_fp_regnum_p (gdbarch, regno) + || i386_fpc_regnum_p (gdbarch, regno)) i387_collect_fsave (regcache, regno, &npx); else - internal_error (_("Invalid register no. %d in store_register."), regno); + internal_error (_ ("Invalid register no. %d in store_register."), regno); } void @@ -638,10 +634,9 @@ go32_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf, /* Target to_xfer_partial implementation. */ enum target_xfer_status -go32_nat_target::xfer_partial (enum target_object object, - const char *annex, gdb_byte *readbuf, - const gdb_byte *writebuf, ULONGEST offset, - ULONGEST len, +go32_nat_target::xfer_partial (enum target_object object, const char *annex, + gdb_byte *readbuf, const gdb_byte *writebuf, + ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) { switch (object) @@ -650,13 +645,12 @@ go32_nat_target::xfer_partial (enum target_object object, return go32_xfer_memory (readbuf, writebuf, offset, len, xfered_len); default: - return this->beneath ()->xfer_partial (object, annex, - readbuf, writebuf, offset, len, - xfered_len); + return this->beneath ()->xfer_partial (object, annex, readbuf, writebuf, + offset, len, xfered_len); } } -static cmdline_t child_cmd; /* Parsed child's command line kept here. */ +static cmdline_t child_cmd; /* Parsed child's command line kept here. */ void go32_nat_target::files_info () @@ -672,8 +666,8 @@ go32_nat_target::kill_inferior () void go32_nat_target::create_inferior (const char *exec_file, - const std::string &allargs, - char **env, int from_tty) + const std::string &allargs, char **env, + int from_tty) { extern char **environ; jmp_buf start_state; @@ -698,8 +692,8 @@ go32_nat_target::create_inferior (const char *exec_file, /* Init command line storage. */ if (redir_debug_init (&child_cmd) == -1) - internal_error (_("Cannot allocate redirection storage: " - "not enough memory.\n")); + internal_error (_ ("Cannot allocate redirection storage: " + "not enough memory.\n")); /* Parse the command line and create redirections. */ if (strpbrk (args, "<>")) @@ -707,7 +701,7 @@ go32_nat_target::create_inferior (const char *exec_file, if (redir_cmdline_parse (args, &child_cmd) == 0) args = child_cmd.command; else - error (_("Syntax error in command line.")); + error (_ ("Syntax error in command line.")); } else child_cmd.command = xstrdup (args); @@ -715,8 +709,8 @@ go32_nat_target::create_inferior (const char *exec_file, cmdlen = strlen (args); /* v2loadimage passes command lines via DOS memory, so it cannot possibly handle commands longer than 1MB. */ - if (cmdlen > 1024*1024) - error (_("Command line too long.")); + if (cmdlen > 1024 * 1024) + error (_ ("Command line too long.")); cmdline = (char *) xmalloc (cmdlen + 4); strcpy (cmdline + 1, args); @@ -729,7 +723,7 @@ go32_nat_target::create_inferior (const char *exec_file, cmdline[cmdlen + 1] = 13; } else - cmdline[0] = 0xff; /* Signal v2loadimage it's a long command. */ + cmdline[0] = 0xff; /* Signal v2loadimage it's a long command. */ environ = env; @@ -739,7 +733,7 @@ go32_nat_target::create_inferior (const char *exec_file, xfree (cmdline); if (result != 0) - error (_("Load failed for image %s"), exec_file); + error (_ ("Load failed for image %s"), exec_file); edi_init (start_state); #if __DJGPP_MINOR__ < 3 @@ -797,7 +791,7 @@ static void go32_set_dr (int i, CORE_ADDR addr) { if (i < 0 || i > 3) - internal_error (_("Invalid register %d in go32_set_dr.\n"), i); + internal_error (_ ("Invalid register %d in go32_set_dr.\n"), i); D_REGS[i] = addr; } @@ -837,7 +831,7 @@ static CORE_ADDR go32_get_dr (int i) { if (i < 0 || i > 3) - internal_error (_("Invalid register %d in go32_get_dr.\n"), i); + internal_error (_ ("Invalid register %d in go32_get_dr.\n"), i); return D_REGS[i]; } @@ -862,11 +856,11 @@ device_mode (int fd, int raw_p) else newmode &= ~0x20; - if (oldmode & 0x80) /* Only for character dev. */ + if (oldmode & 0x80) /* Only for character dev. */ { regs.x.ax = 0x4401; regs.x.bx = fd; - regs.x.dx = newmode & 0xff; /* Force upper byte zero, else it fails. */ + regs.x.dx = newmode & 0xff; /* Force upper byte zero, else it fails. */ __dpmi_int (0x21, ®s); if (regs.x.flags & 1) return -1; @@ -874,7 +868,6 @@ device_mode (int fd, int raw_p) return (oldmode & 0x20) == 0x20; } - static int inf_mode_valid = 0; static int inf_terminal_mode; @@ -887,7 +880,7 @@ static int terminal_is_ours = 1; void go32_nat_target::terminal_init () { - inf_mode_valid = 0; /* Reinitialize, in case they are restarting child. */ + inf_mode_valid = 0; /* Reinitialize, in case they are restarting child. */ terminal_is_ours = 1; } @@ -895,8 +888,9 @@ void go32_nat_target::terminal_info (const char *args, int from_tty) { gdb_printf ("Inferior's terminal is in %s mode.\n", - !inf_mode_valid - ? "default" : inf_terminal_mode ? "raw" : "cooked"); + !inf_mode_valid ? "default" + : inf_terminal_mode ? "raw" + : "cooked"); #if __DJGPP_MINOR__ > 2 if (child_cmd.redirection) @@ -906,16 +900,17 @@ go32_nat_target::terminal_info (const char *args, int from_tty) for (i = 0; i < DBG_HANDLES; i++) { if (child_cmd.redirection[i]->file_name) - gdb_printf ("\tFile handle %d is redirected to `%s'.\n", - i, child_cmd.redirection[i]->file_name); + gdb_printf ("\tFile handle %d is redirected to `%s'.\n", i, + child_cmd.redirection[i]->file_name); else if (_get_dev_info (child_cmd.redirection[i]->inf_handle) == -1) - gdb_printf - ("\tFile handle %d appears to be closed by inferior.\n", i); + gdb_printf ("\tFile handle %d appears to be closed by inferior.\n", + i); /* Mask off the raw/cooked bit when comparing device info words. */ - else if ((_get_dev_info (child_cmd.redirection[i]->inf_handle) & 0xdf) + else if ((_get_dev_info (child_cmd.redirection[i]->inf_handle) + & 0xdf) != (_get_dev_info (i) & 0xdf)) - gdb_printf - ("\tFile handle %d appears to be redirected by inferior.\n", i); + gdb_printf ( + "\tFile handle %d appears to be redirected by inferior.\n", i); } } #endif @@ -929,7 +924,7 @@ go32_nat_target::terminal_inferior () if (redir_to_child (&child_cmd) == -1) { redir_to_debugger (&child_cmd); - error (_("Cannot redirect standard handles for program: %s."), + error (_ ("Cannot redirect standard handles for program: %s."), safe_strerror (errno)); } /* Set the console device of the inferior to whatever mode @@ -963,7 +958,7 @@ go32_nat_target::terminal_ours () if (redir_to_debugger (&child_cmd) == -1) { redir_to_child (&child_cmd); - error (_("Cannot redirect standard handles for debugger: %s."), + error (_ ("Cannot redirect standard handles for debugger: %s."), safe_strerror (errno)); } } @@ -997,7 +992,7 @@ dos_codepage (void) if (!(regs.x.flags & 1)) return regs.x.bx & 0xffff; else - return 437; /* default */ + return 437; /* default */ } /* Limited emulation of `nl_langinfo', for charset.c. */ @@ -1008,21 +1003,21 @@ nl_langinfo (nl_item item) switch (item) { - case CODESET: - { - /* 8 is enough for SHORT_MAX + "CP" + null. */ - char buf[8]; - int blen = sizeof (buf); - int needed = snprintf (buf, blen, "CP%d", dos_codepage ()); - - if (needed > blen) /* Should never happen. */ - buf[0] = 0; - retval = xstrdup (buf); - } - break; - default: - retval = xstrdup (""); - break; + case CODESET: + { + /* 8 is enough for SHORT_MAX + "CP" + null. */ + char buf[8]; + int blen = sizeof (buf); + int needed = snprintf (buf, blen, "CP%d", dos_codepage ()); + + if (needed > blen) /* Should never happen. */ + buf[0] = 0; + retval = xstrdup (buf); + } + break; + default: + retval = xstrdup (""); + break; } return retval; } @@ -1031,12 +1026,12 @@ unsigned short windows_major, windows_minor; /* Compute the version Windows reports via Int 2Fh/AX=1600h. */ static void -go32_get_windows_version(void) +go32_get_windows_version (void) { __dpmi_regs r; r.x.ax = 0x1600; - __dpmi_int(0x2f, &r); + __dpmi_int (0x2f, &r); if (r.h.al > 2 && r.h.al != 0x80 && r.h.al != 0xff && (r.h.al > 3 || r.h.ah > 0)) { @@ -1044,7 +1039,7 @@ go32_get_windows_version(void) windows_minor = r.h.ah; } else - windows_major = 0xff; /* meaning no Windows */ + windows_major = 0xff; /* meaning no Windows */ } /* A subroutine of go32_sysinfo to display memory info. */ @@ -1072,15 +1067,15 @@ print_mem (unsigned long datum, const char *header, int in_pages_p) static void go32_sysinfo (const char *arg, int from_tty) { - static const char test_pattern[] = - "deadbeafdeadbeafdeadbeafdeadbeafdeadbeaf" - "deadbeafdeadbeafdeadbeafdeadbeafdeadbeaf" - "deadbeafdeadbeafdeadbeafdeadbeafdeadbeafdeadbeaf"; + static const char test_pattern[] + = "deadbeafdeadbeafdeadbeafdeadbeafdeadbeaf" + "deadbeafdeadbeafdeadbeafdeadbeafdeadbeaf" + "deadbeafdeadbeafdeadbeafdeadbeafdeadbeafdeadbeaf"; struct utsname u; char cpuid_vendor[13]; unsigned cpuid_max = 0, cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx; unsigned true_dos_version = _get_dos_version (1); - unsigned advertized_dos_version = ((unsigned int)_osmajor << 8) | _osminor; + unsigned advertized_dos_version = ((unsigned int) _osmajor << 8) | _osminor; int dpmi_flags; char dpmi_vendor_info[129]; int dpmi_vendor_available; @@ -1119,10 +1114,8 @@ go32_sysinfo (const char *arg, int from_tty) "movl %%edx, %1;" "movl %%ecx, %2;" "movl %%eax, %3;" - : "=m" (cpuid_vendor[0]), - "=m" (cpuid_vendor[4]), - "=m" (cpuid_vendor[8]), - "=m" (cpuid_max) + : "=m"(cpuid_vendor[0]), "=m"(cpuid_vendor[4]), + "=m"(cpuid_vendor[8]), "=m"(cpuid_max) : : "%eax", "%ebx", "%ecx", "%edx"); cpuid_vendor[12] = '\0'; @@ -1137,14 +1130,8 @@ go32_sysinfo (const char *arg, int from_tty) /* CPUID with EAX = 1 returns processor signature and features. */ if (cpuid_max >= 1) { - static const char *brand_name[] = { - "", - " Celeron", - " III", - " III Xeon", - "", "", "", "", - " 4" - }; + static const char *brand_name[] + = { "", " Celeron", " III", " III Xeon", "", "", "", "", " 4" }; char cpu_string[80]; char cpu_brand[20]; unsigned brand_idx; @@ -1159,20 +1146,18 @@ go32_sysinfo (const char *arg, int from_tty) #else __asm__ __volatile__ ("movl $1, %%eax;" "cpuid;" - : "=a" (cpuid_eax), - "=b" (cpuid_ebx), - "=d" (cpuid_edx) + : "=a"(cpuid_eax), "=b"(cpuid_ebx), "=d"(cpuid_edx) : : "%ecx"); #endif brand_idx = cpuid_ebx & 0xff; cpu_family = (cpuid_eax >> 8) & 0xf; - cpu_model = (cpuid_eax >> 4) & 0xf; + cpu_model = (cpuid_eax >> 4) & 0xf; cpu_brand[0] = '\0'; if (intel_p) { if (brand_idx > 0 - && brand_idx < sizeof(brand_name)/sizeof(brand_name[0]) + && brand_idx < sizeof (brand_name) / sizeof (brand_name[0]) && *brand_name[brand_idx]) strcpy (cpu_brand, brand_name[brand_idx]); else if (cpu_family == 5) @@ -1188,21 +1173,21 @@ go32_sysinfo (const char *arg, int from_tty) { switch (cpu_model) { - case 1: - strcpy (cpu_brand, " Pro"); - break; - case 3: - strcpy (cpu_brand, " II"); - break; - case 5: - strcpy (cpu_brand, " II Xeon"); - break; - case 6: - strcpy (cpu_brand, " Celeron"); - break; - case 7: - strcpy (cpu_brand, " III"); - break; + case 1: + strcpy (cpu_brand, " Pro"); + break; + case 3: + strcpy (cpu_brand, " II"); + break; + case 5: + strcpy (cpu_brand, " II Xeon"); + break; + case 6: + strcpy (cpu_brand, " Celeron"); + break; + case 7: + strcpy (cpu_brand, " III"); + break; } } } @@ -1210,51 +1195,51 @@ go32_sysinfo (const char *arg, int from_tty) { switch (cpu_family) { - case 4: - strcpy (cpu_brand, "486/5x86"); - break; - case 5: - switch (cpu_model) - { - case 0: - case 1: - case 2: - case 3: - strcpy (cpu_brand, "-K5"); - break; - case 6: - case 7: - strcpy (cpu_brand, "-K6"); - break; - case 8: - strcpy (cpu_brand, "-K6-2"); - break; - case 9: - strcpy (cpu_brand, "-K6-III"); - break; - } - break; - case 6: - switch (cpu_model) - { - case 1: - case 2: - case 4: - strcpy (cpu_brand, " Athlon"); - break; - case 3: - strcpy (cpu_brand, " Duron"); - break; - } - break; + case 4: + strcpy (cpu_brand, "486/5x86"); + break; + case 5: + switch (cpu_model) + { + case 0: + case 1: + case 2: + case 3: + strcpy (cpu_brand, "-K5"); + break; + case 6: + case 7: + strcpy (cpu_brand, "-K6"); + break; + case 8: + strcpy (cpu_brand, "-K6-2"); + break; + case 9: + strcpy (cpu_brand, "-K6-III"); + break; + } + break; + case 6: + switch (cpu_model) + { + case 1: + case 2: + case 4: + strcpy (cpu_brand, " Athlon"); + break; + case 3: + strcpy (cpu_brand, " Duron"); + break; + } + break; } } xsnprintf (cpu_string, sizeof (cpu_string), "%s%s Model %d Stepping %d", - intel_p ? "Pentium" : (amd_p ? "AMD" : (hygon_p ? "Hygon" : "ix86")), + intel_p ? "Pentium" + : (amd_p ? "AMD" : (hygon_p ? "Hygon" : "ix86")), cpu_brand, cpu_model, cpuid_eax & 0xf); gdb_printf ("%*s%s\n", 31, "", cpu_string); - if (((cpuid_edx & (6 | (0x0d << 23))) != 0) - || ((cpuid_edx & 1) == 0) + if (((cpuid_edx & (6 | (0x0d << 23))) != 0) || ((cpuid_edx & 1) == 0) || ((amd_p || hygon_p) && (cpuid_edx & (3 << 30)) != 0)) { gdb_puts ("CPU Features..................."); @@ -1285,8 +1270,8 @@ go32_sysinfo (const char *arg, int from_tty) } } gdb_puts ("\n"); - gdb_printf ("DOS Version....................%s %s.%s", - _os_flavor, u.release, u.version); + gdb_printf ("DOS Version....................%s %s.%s", _os_flavor, u.release, + u.version); if (true_dos_version != advertized_dos_version) gdb_printf (" (disguised as v%d.%d)", _osmajor, _osminor); gdb_puts ("\n"); @@ -1300,32 +1285,32 @@ go32_sysinfo (const char *arg, int from_tty) windows_major, windows_minor); switch (windows_major) { - case 3: - windows_flavor = "3.X"; - break; - case 4: - switch (windows_minor) - { - case 0: - windows_flavor = "95, 95A, or 95B"; - break; - case 3: - windows_flavor = "95B OSR2.1 or 95C OSR2.5"; - break; - case 10: - windows_flavor = "98 or 98 SE"; - break; - case 90: - windows_flavor = "ME"; - break; - default: - windows_flavor = "9X"; - break; - } - break; - default: - windows_flavor = "??"; - break; + case 3: + windows_flavor = "3.X"; + break; + case 4: + switch (windows_minor) + { + case 0: + windows_flavor = "95, 95A, or 95B"; + break; + case 3: + windows_flavor = "95B OSR2.1 or 95C OSR2.5"; + break; + case 10: + windows_flavor = "98 or 98 SE"; + break; + case 90: + windows_flavor = "ME"; + break; + default: + windows_flavor = "9X"; + break; + } + break; + default: + windows_flavor = "??"; + break; } gdb_printf ("%s)\n", windows_flavor); } @@ -1336,12 +1321,12 @@ go32_sysinfo (const char *arg, int from_tty) /* On some versions of Windows, __dpmi_get_capabilities returns zero, but the buffer is not filled with info, so we fill the buffer with a known pattern and test for it afterwards. */ - memcpy (dpmi_vendor_info, test_pattern, sizeof(dpmi_vendor_info)); - dpmi_vendor_available = - __dpmi_get_capabilities (&dpmi_flags, dpmi_vendor_info); + memcpy (dpmi_vendor_info, test_pattern, sizeof (dpmi_vendor_info)); + dpmi_vendor_available + = __dpmi_get_capabilities (&dpmi_flags, dpmi_vendor_info); if (dpmi_vendor_available == 0 - && memcmp (dpmi_vendor_info, test_pattern, - sizeof(dpmi_vendor_info)) != 0) + && memcmp (dpmi_vendor_info, test_pattern, sizeof (dpmi_vendor_info)) + != 0) { /* The DPMI spec says the vendor string should be ASCIIZ, but I don't trust the vendors to follow that... */ @@ -1349,10 +1334,9 @@ go32_sysinfo (const char *arg, int from_tty) dpmi_vendor_info[128] = '\0'; gdb_printf ("DPMI Host......................" "%s v%d.%d (capabilities: %#x)\n", - &dpmi_vendor_info[2], - (unsigned)dpmi_vendor_info[0], - (unsigned)dpmi_vendor_info[1], - ((unsigned)dpmi_flags & 0x7f)); + &dpmi_vendor_info[2], (unsigned) dpmi_vendor_info[0], + (unsigned) dpmi_vendor_info[1], + ((unsigned) dpmi_flags & 0x7f)); } else gdb_printf ("DPMI Host......................(Info not available)\n"); @@ -1365,15 +1349,14 @@ go32_sysinfo (const char *arg, int from_tty) (dpmi_version_data.flags & 4) ? "" : "out"); gdb_printf ("%*sInterrupts reflected to %s mode\n", 31, "", (dpmi_version_data.flags & 2) ? "V86" : "Real"); - gdb_printf ("%*sProcessor type: i%d86\n", 31, "", - dpmi_version_data.cpu); + gdb_printf ("%*sProcessor type: i%d86\n", 31, "", dpmi_version_data.cpu); gdb_printf ("%*sPIC base interrupt: Master: %#x Slave: %#x\n", 31, "", dpmi_version_data.master_pic, dpmi_version_data.slave_pic); /* a_tss is only initialized when the debuggee is first run. */ if (prog_has_started) { - __asm__ __volatile__ ("pushfl ; popl %0" : "=g" (eflags)); + __asm__ __volatile__ ("pushfl ; popl %0" : "=g"(eflags)); gdb_printf ("Protection....................." "Ring %d (in %s), with%s I/O protection\n", a_tss.tss_cs & 3, (a_tss.tss_cs & 4) ? "LDT" : "GDT", @@ -1402,14 +1385,11 @@ go32_sysinfo (const char *arg, int from_tty) __dpmi_int (0x21, ®s); if ((regs.x.flags & 1) == 0) { - static const char *dos_hilo[] = { - "Low", "", "", "", "High", "", "", "", "High, then Low" - }; - static const char *dos_fit[] = { - "First", "Best", "Last" - }; + static const char *dos_hilo[] + = { "Low", "", "", "", "High", "", "", "", "High, then Low" }; + static const char *dos_fit[] = { "First", "Best", "Last" }; int hilo_idx = (regs.x.ax >> 4) & 0x0f; - int fit_idx = regs.x.ax & 0x0f; + int fit_idx = regs.x.ax & 0x0f; if (hilo_idx > 8) hilo_idx = 0; @@ -1426,29 +1406,31 @@ go32_sysinfo (const char *arg, int from_tty) } } -struct seg_descr { +struct seg_descr +{ unsigned short limit0; unsigned short base0; - unsigned char base1; - unsigned stype:5; - unsigned dpl:2; - unsigned present:1; - unsigned limit1:4; - unsigned available:1; - unsigned dummy:1; - unsigned bit32:1; - unsigned page_granular:1; - unsigned char base2; + unsigned char base1; + unsigned stype : 5; + unsigned dpl : 2; + unsigned present : 1; + unsigned limit1 : 4; + unsigned available : 1; + unsigned dummy : 1; + unsigned bit32 : 1; + unsigned page_granular : 1; + unsigned char base2; } __attribute__ ((packed)); -struct gate_descr { +struct gate_descr +{ unsigned short offset0; unsigned short selector; - unsigned param_count:5; - unsigned dummy:3; - unsigned stype:5; - unsigned dpl:2; - unsigned present:1; + unsigned param_count : 5; + unsigned dummy : 3; + unsigned stype : 5; + unsigned dpl : 2; + unsigned present : 1; unsigned short offset1; } __attribute__ ((packed)); @@ -1498,7 +1480,7 @@ read_memory_region (unsigned long addr, void *dest, size_t len) /* W2K silently fails to set the segment limit, leaving it at zero; this test avoids the resulting crash. */ && __dpmi_get_segment_limit (sel) >= segment_limit) - movedata (sel, 0, _my_ds (), (unsigned)dest, len); + movedata (sel, 0, _my_ds (), (unsigned) dest, len); else retval = 0; @@ -1517,13 +1499,14 @@ get_descriptor (unsigned long table_base, int idx, void *descr) unsigned long addr = table_base + idx * 8; /* 8 bytes per entry */ if (read_memory_region (addr, descr, 8)) - return (int)((struct seg_descr *)descr)->stype; + return (int) ((struct seg_descr *) descr)->stype; return -1; } -struct dtr_reg { - unsigned short limit __attribute__((packed)); - unsigned long base __attribute__((packed)); +struct dtr_reg +{ + unsigned short limit __attribute__ ((packed)); + unsigned long base __attribute__ ((packed)); }; /* Display a segment descriptor stored at index IDX in a descriptor @@ -1543,9 +1526,9 @@ display_descriptor (unsigned type, unsigned long base_addr, int idx, int force) /* For each type of descriptor table, this has a bit set if the corresponding type of selectors is valid in that table. */ static unsigned allowed_descriptors[] = { - 0xffffdafeL, /* GDT */ - 0x0000c0e0L, /* IDT */ - 0xffffdafaL /* LDT */ + 0xffffdafeL, /* GDT */ + 0x0000c0e0L, /* IDT */ + 0xffffdafaL /* LDT */ }; /* If the program hasn't started yet, assume the debuggee will @@ -1557,105 +1540,100 @@ display_descriptor (unsigned type, unsigned long base_addr, int idx, int force) && (allowed_descriptors[type] & (1 << descr.stype)) != 0) { gdb_printf ("0x%03x: ", - type == 1 - ? idx : (idx * 8) | (type ? (cpl | 4) : 0)); + type == 1 ? idx : (idx * 8) | (type ? (cpl | 4) : 0)); if (descr.page_granular) limit = (limit << 12) | 0xfff; /* big segment: low 12 bit set */ if (descr.stype == 1 || descr.stype == 2 || descr.stype == 3 || descr.stype == 9 || descr.stype == 11 || (descr.stype >= 16 && descr.stype < 32)) - gdb_printf ("base=0x%02x%02x%04x limit=0x%08lx", - descr.base2, descr.base1, descr.base0, limit); + gdb_printf ("base=0x%02x%02x%04x limit=0x%08lx", descr.base2, + descr.base1, descr.base0, limit); switch (descr.stype) { - case 1: - case 3: - gdb_printf (" 16-bit TSS (task %sactive)", - descr.stype == 3 ? "" : "in"); - break; - case 2: - gdb_puts (" LDT"); - break; - case 4: - memcpy (&gate, &descr, sizeof gate); - gdb_printf ("selector=0x%04x offs=0x%04x%04x", - gate.selector, gate.offset1, gate.offset0); - gdb_printf (" 16-bit Call Gate (params=%d)", - gate.param_count); - break; - case 5: - gdb_printf ("TSS selector=0x%04x", descr.base0); - gdb_printf ("%*sTask Gate", 16, ""); - break; - case 6: - case 7: - memcpy (&gate, &descr, sizeof gate); - gdb_printf ("selector=0x%04x offs=0x%04x%04x", - gate.selector, gate.offset1, gate.offset0); - gdb_printf (" 16-bit %s Gate", - descr.stype == 6 ? "Interrupt" : "Trap"); - break; - case 9: - case 11: - gdb_printf (" 32-bit TSS (task %sactive)", - descr.stype == 3 ? "" : "in"); - break; - case 12: - memcpy (&gate, &descr, sizeof gate); - gdb_printf ("selector=0x%04x offs=0x%04x%04x", - gate.selector, gate.offset1, gate.offset0); - gdb_printf (" 32-bit Call Gate (params=%d)", - gate.param_count); - break; - case 14: - case 15: - memcpy (&gate, &descr, sizeof gate); - gdb_printf ("selector=0x%04x offs=0x%04x%04x", - gate.selector, gate.offset1, gate.offset0); - gdb_printf (" 32-bit %s Gate", - descr.stype == 14 ? "Interrupt" : "Trap"); - break; - case 16: /* data segments */ - case 17: - case 18: - case 19: - case 20: - case 21: - case 22: - case 23: - gdb_printf (" %s-bit Data (%s Exp-%s%s)", - descr.bit32 ? "32" : "16", - descr.stype & 2 - ? "Read/Write," : "Read-Only, ", - descr.stype & 4 ? "down" : "up", - descr.stype & 1 ? "" : ", N.Acc"); - break; - case 24: /* code segments */ - case 25: - case 26: - case 27: - case 28: - case 29: - case 30: - case 31: - gdb_printf (" %s-bit Code (%s, %sConf%s)", - descr.bit32 ? "32" : "16", - descr.stype & 2 ? "Exec/Read" : "Exec-Only", - descr.stype & 4 ? "" : "N.", - descr.stype & 1 ? "" : ", N.Acc"); - break; - default: - gdb_printf ("Unknown type 0x%02x", descr.stype); - break; + case 1: + case 3: + gdb_printf (" 16-bit TSS (task %sactive)", + descr.stype == 3 ? "" : "in"); + break; + case 2: + gdb_puts (" LDT"); + break; + case 4: + memcpy (&gate, &descr, sizeof gate); + gdb_printf ("selector=0x%04x offs=0x%04x%04x", gate.selector, + gate.offset1, gate.offset0); + gdb_printf (" 16-bit Call Gate (params=%d)", gate.param_count); + break; + case 5: + gdb_printf ("TSS selector=0x%04x", descr.base0); + gdb_printf ("%*sTask Gate", 16, ""); + break; + case 6: + case 7: + memcpy (&gate, &descr, sizeof gate); + gdb_printf ("selector=0x%04x offs=0x%04x%04x", gate.selector, + gate.offset1, gate.offset0); + gdb_printf (" 16-bit %s Gate", + descr.stype == 6 ? "Interrupt" : "Trap"); + break; + case 9: + case 11: + gdb_printf (" 32-bit TSS (task %sactive)", + descr.stype == 3 ? "" : "in"); + break; + case 12: + memcpy (&gate, &descr, sizeof gate); + gdb_printf ("selector=0x%04x offs=0x%04x%04x", gate.selector, + gate.offset1, gate.offset0); + gdb_printf (" 32-bit Call Gate (params=%d)", gate.param_count); + break; + case 14: + case 15: + memcpy (&gate, &descr, sizeof gate); + gdb_printf ("selector=0x%04x offs=0x%04x%04x", gate.selector, + gate.offset1, gate.offset0); + gdb_printf (" 32-bit %s Gate", + descr.stype == 14 ? "Interrupt" : "Trap"); + break; + case 16: /* data segments */ + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + case 23: + gdb_printf (" %s-bit Data (%s Exp-%s%s)", + descr.bit32 ? "32" : "16", + descr.stype & 2 ? "Read/Write," : "Read-Only, ", + descr.stype & 4 ? "down" : "up", + descr.stype & 1 ? "" : ", N.Acc"); + break; + case 24: /* code segments */ + case 25: + case 26: + case 27: + case 28: + case 29: + case 30: + case 31: + gdb_printf (" %s-bit Code (%s, %sConf%s)", + descr.bit32 ? "32" : "16", + descr.stype & 2 ? "Exec/Read" : "Exec-Only", + descr.stype & 4 ? "" : "N.", + descr.stype & 1 ? "" : ", N.Acc"); + break; + default: + gdb_printf ("Unknown type 0x%02x", descr.stype); + break; } gdb_puts ("\n"); } else if (force) { gdb_printf ("0x%03x: ", - type == 1 - ? idx : (idx * 8) | (type ? (cpl | 4) : 0)); + type == 1 ? idx : (idx * 8) | (type ? (cpl | 4) : 0)); if (!descr.present) gdb_puts ("Segment not present\n"); else @@ -1684,30 +1662,27 @@ go32_sldt (const char *arg, int from_tty) if (*arg) { ldt_entry = parse_and_eval_long (arg); - if (ldt_entry < 0 - || (ldt_entry & 4) == 0 + if (ldt_entry < 0 || (ldt_entry & 4) == 0 || (ldt_entry & 3) != (cpl & 3)) - error (_("Invalid LDT entry 0x%03lx."), (unsigned long)ldt_entry); + error (_ ("Invalid LDT entry 0x%03lx."), + (unsigned long) ldt_entry); } } - __asm__ __volatile__ ("sgdt %0" : "=m" (gdtr) : /* no inputs */ ); - __asm__ __volatile__ ("sldt %0" : "=m" (ldtr) : /* no inputs */ ); + __asm__ __volatile__ ("sgdt %0" : "=m"(gdtr) : /* no inputs */); + __asm__ __volatile__ ("sldt %0" : "=m"(ldtr) : /* no inputs */); ldt_idx = ldtr / 8; if (ldt_idx == 0) gdb_puts ("There is no LDT.\n"); /* LDT's entry in the GDT must have the type LDT, which is 2. */ else if (get_descriptor (gdtr.base, ldt_idx, &ldt_descr) != 2) gdb_printf ("LDT is present (at %#x), but unreadable by GDB.\n", - ldt_descr.base0 - | (ldt_descr.base1 << 16) - | (ldt_descr.base2 << 24)); + ldt_descr.base0 | (ldt_descr.base1 << 16) + | (ldt_descr.base2 << 24)); else { - unsigned base = - ldt_descr.base0 - | (ldt_descr.base1 << 16) - | (ldt_descr.base2 << 24); + unsigned base + = ldt_descr.base0 | (ldt_descr.base1 << 16) | (ldt_descr.base2 << 24); unsigned limit = ldt_descr.limit0 | (ldt_descr.limit1 << 16); int max_entry; @@ -1725,8 +1700,8 @@ go32_sldt (const char *arg, int from_tty) if (ldt_entry >= 0) { if (ldt_entry > limit) - error (_("Invalid LDT entry %#lx: outside valid limits [0..%#x]"), - (unsigned long)ldt_entry, limit); + error (_ ("Invalid LDT entry %#lx: outside valid limits [0..%#x]"), + (unsigned long) ldt_entry, limit); display_descriptor (ldt_descr.stype, base, ldt_entry / 8, 1); } @@ -1755,20 +1730,20 @@ go32_sgdt (const char *arg, int from_tty) { gdt_entry = parse_and_eval_long (arg); if (gdt_entry < 0 || (gdt_entry & 7) != 0) - error (_("Invalid GDT entry 0x%03lx: " - "not an integral multiple of 8."), - (unsigned long)gdt_entry); + error (_ ("Invalid GDT entry 0x%03lx: " + "not an integral multiple of 8."), + (unsigned long) gdt_entry); } } - __asm__ __volatile__ ("sgdt %0" : "=m" (gdtr) : /* no inputs */ ); + __asm__ __volatile__ ("sgdt %0" : "=m"(gdtr) : /* no inputs */); max_entry = (gdtr.limit + 1) / 8; if (gdt_entry >= 0) { if (gdt_entry > gdtr.limit) - error (_("Invalid GDT entry %#lx: outside valid limits [0..%#x]"), - (unsigned long)gdt_entry, gdtr.limit); + error (_ ("Invalid GDT entry %#lx: outside valid limits [0..%#x]"), + (unsigned long) gdt_entry, gdtr.limit); display_descriptor (0, gdtr.base, gdt_entry / 8, 1); } @@ -1796,20 +1771,20 @@ go32_sidt (const char *arg, int from_tty) { idt_entry = parse_and_eval_long (arg); if (idt_entry < 0) - error (_("Invalid (negative) IDT entry %ld."), idt_entry); + error (_ ("Invalid (negative) IDT entry %ld."), idt_entry); } } - __asm__ __volatile__ ("sidt %0" : "=m" (idtr) : /* no inputs */ ); + __asm__ __volatile__ ("sidt %0" : "=m"(idtr) : /* no inputs */); max_entry = (idtr.limit + 1) / 8; - if (max_entry > 0x100) /* No more than 256 entries. */ + if (max_entry > 0x100) /* No more than 256 entries. */ max_entry = 0x100; if (idt_entry >= 0) { if (idt_entry > idtr.limit) - error (_("Invalid IDT entry %#lx: outside valid limits [0..%#x]"), - (unsigned long)idt_entry, idtr.limit); + error (_ ("Invalid IDT entry %#lx: outside valid limits [0..%#x]"), + (unsigned long) idt_entry, idtr.limit); display_descriptor (1, idtr.base, idt_entry, 1); } @@ -1839,8 +1814,8 @@ get_cr3 (void) return pdbr; /* Get the linear address of GDT and the Task Register. */ - __asm__ __volatile__ ("sgdt %0" : "=m" (gdtr) : /* no inputs */ ); - __asm__ __volatile__ ("str %0" : "=m" (taskreg) : /* no inputs */ ); + __asm__ __volatile__ ("sgdt %0" : "=m"(gdtr) : /* no inputs */); + __asm__ __volatile__ ("str %0" : "=m"(taskreg) : /* no inputs */); /* Task Register is a segment selector for the TSS of the current task. Therefore, it can be used as an index into the GDT to get @@ -1849,13 +1824,12 @@ get_cr3 (void) offset to point to the 3 low bytes of the base address. */ offset = gdtr.base + (taskreg & 0xfff8) + 2; - /* CWSDPMI's task base is always under the 1MB mark. */ if (offset > 0xfffff) return 0; _farsetsel (_dos_ds); - taskbase = _farnspeekl (offset) & 0xffffffU; + taskbase = _farnspeekl (offset) & 0xffffffU; taskbase += _farnspeekl (offset + 2) & 0xff000000U; if (taskbase > 0xfffff) return 0; @@ -1865,7 +1839,7 @@ get_cr3 (void) cr3 = _farnspeekl (taskbase + 0x1c) & ~0xfff; if (cr3 > 0xfffff) { -#if 0 /* Not fully supported yet. */ +#if 0 /* Not fully supported yet. */ /* The Page Directory is in UMBs. In that case, CWSDPMI puts the first Page Table right below the Page Directory. Thus, the first Page Table's entry for its own address and the Page @@ -1903,7 +1877,7 @@ get_pde (int n) if (pdbr && n >= 0 && n < 1024) { - pde = _farpeekl (_dos_ds, pdbr + 4*n); + pde = _farpeekl (_dos_ds, pdbr + 4 * n); } return pde; } @@ -1919,8 +1893,8 @@ get_pte (unsigned long pde, int n) page tables, for now. */ if ((pde & 1) && !(pde & 0x80) && n >= 0 && n < 1024) { - pde &= ~0xfff; /* Clear non-address bits. */ - pte = _farpeekl (_dos_ds, pde + 4*n); + pde &= ~0xfff; /* Clear non-address bits. */ + pte = _farpeekl (_dos_ds, pde + 4 * n); } return pte; } @@ -1966,7 +1940,8 @@ go32_pde (const char *arg, int from_tty) { pde_idx = parse_and_eval_long (arg); if (pde_idx < 0 || pde_idx >= 1024) - error (_("Entry %ld is outside valid limits [0..1023]."), pde_idx); + error (_ ("Entry %ld is outside valid limits [0..1023]."), + pde_idx); } } @@ -1994,7 +1969,8 @@ display_page_table (long n, int force) int i; gdb_printf ("Page Table pointed to by " - "Page Directory entry 0x%lx:\n", n); + "Page Directory entry 0x%lx:\n", + n); for (i = 0; i < 1024; i++) display_ptable_entry (get_pte (pde, i), 0, 0, 0); gdb_puts ("\n"); @@ -2016,7 +1992,8 @@ go32_pte (const char *arg, int from_tty) { pde_idx = parse_and_eval_long (arg); if (pde_idx < 0 || pde_idx >= 1024) - error (_("Entry %ld is outside valid limits [0..1023]."), pde_idx); + error (_ ("Entry %ld is outside valid limits [0..1023]."), + pde_idx); } } @@ -2043,7 +2020,7 @@ go32_pte_for_address (const char *arg, int from_tty) addr = parse_and_eval_address (arg); } if (!addr) - error_no_arg (_("linear address")); + error_no_arg (_ ("linear address")); pdbr = get_cr3 (); if (!pdbr) @@ -2054,8 +2031,7 @@ go32_pte_for_address (const char *arg, int from_tty) int pte_idx = (addr >> 12) & 0x3ff; unsigned offs = addr & 0xfff; - gdb_printf ("Page Table entry for address %s:\n", - hex_string(addr)); + gdb_printf ("Page Table entry for address %s:\n", hex_string (addr)); display_ptable_entry (get_pte (get_pde (pde_idx), pte_idx), 0, 1, offs); } } @@ -2063,6 +2039,7 @@ go32_pte_for_address (const char *arg, int from_tty) static struct cmd_list_element *info_dos_cmdlist = NULL; void _initialize_go32_nat (); + void _initialize_go32_nat () { @@ -2081,41 +2058,41 @@ _initialize_go32_nat () /* Initialize child's command line storage. */ if (redir_debug_init (&child_cmd) == -1) - internal_error (_("Cannot allocate redirection storage: " - "not enough memory.\n")); + internal_error (_ ("Cannot allocate redirection storage: " + "not enough memory.\n")); /* We are always processing GCC-compiled programs. */ processing_gcc_compilation = 2; - add_basic_prefix_cmd ("dos", class_info, _("\ + add_basic_prefix_cmd ("dos", class_info, _ ("\ Print information specific to DJGPP (aka MS-DOS) debugging."), &info_dos_cmdlist, 0, &infolist); - add_cmd ("sysinfo", class_info, go32_sysinfo, _("\ + add_cmd ("sysinfo", class_info, go32_sysinfo, _ ("\ Display information about the target system, including CPU, OS, DPMI, etc."), &info_dos_cmdlist); - add_cmd ("ldt", class_info, go32_sldt, _("\ + add_cmd ("ldt", class_info, go32_sldt, _ ("\ Display entries in the LDT (Local Descriptor Table).\n\ Entry number (an expression) as an argument means display only that entry."), &info_dos_cmdlist); - add_cmd ("gdt", class_info, go32_sgdt, _("\ + add_cmd ("gdt", class_info, go32_sgdt, _ ("\ Display entries in the GDT (Global Descriptor Table).\n\ Entry number (an expression) as an argument means display only that entry."), &info_dos_cmdlist); - add_cmd ("idt", class_info, go32_sidt, _("\ + add_cmd ("idt", class_info, go32_sidt, _ ("\ Display entries in the IDT (Interrupt Descriptor Table).\n\ Entry number (an expression) as an argument means display only that entry."), &info_dos_cmdlist); - add_cmd ("pde", class_info, go32_pde, _("\ + add_cmd ("pde", class_info, go32_pde, _ ("\ Display entries in the Page Directory.\n\ Entry number (an expression) as an argument means display only that entry."), &info_dos_cmdlist); - add_cmd ("pte", class_info, go32_pte, _("\ + add_cmd ("pte", class_info, go32_pte, _ ("\ Display entries in Page Tables.\n\ Entry number (an expression) as an argument means display only entries\n\ from the Page Table pointed to by the specified Page Directory entry."), &info_dos_cmdlist); - add_cmd ("address-pte", class_info, go32_pte_for_address, _("\ + add_cmd ("address-pte", class_info, go32_pte_for_address, _ ("\ Display a Page Table entry for a linear address.\n\ The address argument must be a linear address, after adding to\n\ it the base address of the appropriate segment.\n\ |