/* Native debugging support for Intel x86 running DJGPP.
- Copyright (C) 1997-2016 Free Software Foundation, Inc.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
Written by Robert Hoehne.
This file is part of GDB.
#include "inferior.h"
#include "infrun.h"
#include "gdbthread.h"
-#include "gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
#include "gdbcore.h"
#include "command.h"
#include "gdbcmd.h"
#include "floatformat.h"
-#include "buildsym.h"
+#include "buildsym-legacy.h"
#include "i387-tdep.h"
#include "i386-tdep.h"
#include "nat/x86-cpuid.h"
#define SOME_PID 42
static int prog_has_started = 0;
-static void go32_mourn_inferior (struct target_ops *ops);
#define r_ofs(x) (offsetof(TSS,x))
{GDB_SIGNAL_LAST, -1}
};
-static void
-go32_attach (struct target_ops *ops, const char *args, int from_tty)
+/* The go32 target. */
+
+struct go32_nat_target final : public x86_nat_target<inf_child_target>
+{
+ void attach (const char *, int) override;
+
+ void resume (ptid_t, int, enum gdb_signal) override;
+
+ ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
+
+ void fetch_registers (struct regcache *, int) override;
+ void store_registers (struct regcache *, int) 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;
+
+ void files_info () override;
+
+ void terminal_init () override;
+
+ void terminal_inferior () override;
+
+ void terminal_ours_for_output () override;
+
+ void terminal_ours () override;
+
+ void terminal_info (const char *, int) override;
+
+ void pass_ctrlc () override;
+
+ void kill () override;
+
+ void create_inferior (const char *, const std::string &,
+ char **, int) override;
+
+ void mourn_inferior () override;
+
+ bool thread_alive (ptid_t ptid) override;
+
+ std::string pid_to_str (ptid_t) override;
+};
+
+static go32_nat_target the_go32_nat_target;
+
+void
+go32_nat_target::attach (const char *args, int from_tty)
{
error (_("\
You cannot attach to a running program on this platform.\n\
static int resume_is_step;
static int resume_signal = -1;
-static void
-go32_resume (struct target_ops *ops,
- ptid_t ptid, int step, enum gdb_signal siggnal)
+void
+go32_nat_target::resume (ptid_t ptid, int step, enum gdb_signal siggnal)
{
int i;
resume_is_step = step;
if (siggnal != GDB_SIGNAL_0 && siggnal != GDB_SIGNAL_TRAP)
- {
- 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;
- break;
- }
- if (resume_signal == -1)
- printf_unfiltered ("Cannot deliver signal %s on this platform.\n",
- gdb_signal_to_name (siggnal));
- }
+ {
+ 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;
+ break;
+ }
+ if (resume_signal == -1)
+ printf_unfiltered ("Cannot deliver signal %s on this platform.\n",
+ gdb_signal_to_name (siggnal));
+ }
}
static char child_cwd[FILENAME_MAX];
-static ptid_t
-go32_wait (struct target_ops *ops,
- ptid_t ptid, struct target_waitstatus *status, int options)
+ptid_t
+go32_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
+ target_wait_flags options)
{
int i;
unsigned char saved_opcode;
}
getcwd (child_cwd, sizeof (child_cwd)); /* in case it has changed */
- chdir (current_directory);
+ if (current_directory != NULL)
+ chdir (current_directory);
if (a_tss.tss_irqn == 0x21)
- {
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = a_tss.tss_eax & 0xff;
- }
+ status->set_exited (a_tss.tss_eax & 0xff);
else
{
- status->value.sig = GDB_SIGNAL_UNKNOWN;
- status->kind = TARGET_WAITKIND_STOPPED;
+ status->set_stopped (GDB_SIGNAL_UNKNOWN);
for (i = 0; sig_map[i].go32_sig != -1; i++)
{
if (a_tss.tss_irqn == sig_map[i].go32_sig)
{
#if __DJGPP_MINOR__ < 3
- if ((status->value.sig = sig_map[i].gdb_sig) !=
- GDB_SIGNAL_TRAP)
- status->kind = TARGET_WAITKIND_SIGNALLED;
+ status->set_stopped (sig_map[i].gdb_sig);
+ if (status->sig () != GDB_SIGNAL_TRAP)
+ status->set_signalled (status->sig ());
#else
- status->value.sig = sig_map[i].gdb_sig;
+ status->set_stopped (sig_map[i].gdb_sig);
#endif
break;
}
}
}
- return pid_to_ptid (SOME_PID);
+ return ptid_t (SOME_PID);
}
static void
fetch_register (struct regcache *regcache, int regno)
{
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct gdbarch *gdbarch = regcache->arch ();
if (regno < gdbarch_fp0_regnum (gdbarch))
- regcache_raw_supply (regcache, regno,
- (char *) &a_tss + regno_mapping[regno].tss_ofs);
+ 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))
i387_supply_fsave (regcache, regno, &npx);
else
- internal_error (__FILE__, __LINE__,
- _("Invalid register no. %d in fetch_register."), regno);
+ internal_error (_("Invalid register no. %d in fetch_register."), regno);
}
-static void
-go32_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+void
+go32_nat_target::fetch_registers (struct regcache *regcache, int regno)
{
if (regno >= 0)
fetch_register (regcache, regno);
else
{
for (regno = 0;
- regno < gdbarch_fp0_regnum (get_regcache_arch (regcache));
+ regno < gdbarch_fp0_regnum (regcache->arch ());
regno++)
fetch_register (regcache, regno);
i387_supply_fsave (regcache, -1, &npx);
static void
store_register (const struct regcache *regcache, int regno)
{
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct gdbarch *gdbarch = regcache->arch ();
if (regno < gdbarch_fp0_regnum (gdbarch))
- regcache_raw_collect (regcache, regno,
- (char *) &a_tss + regno_mapping[regno].tss_ofs);
+ 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))
i387_collect_fsave (regcache, regno, &npx);
else
- internal_error (__FILE__, __LINE__,
- _("Invalid register no. %d in store_register."), regno);
+ internal_error (_("Invalid register no. %d in store_register."), regno);
}
-static void
-go32_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+void
+go32_nat_target::store_registers (struct regcache *regcache, int regno)
{
unsigned r;
store_register (regcache, regno);
else
{
- for (r = 0; r < gdbarch_fp0_regnum (get_regcache_arch (regcache)); r++)
+ for (r = 0; r < gdbarch_fp0_regnum (regcache->arch ()); r++)
store_register (regcache, r);
i387_collect_fsave (regcache, -1, &npx);
}
/* Target to_xfer_partial implementation. */
-static enum target_xfer_status
-go32_xfer_partial (struct target_ops *ops, enum target_object object,
- const char *annex, gdb_byte *readbuf,
- const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
- ULONGEST *xfered_len)
+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,
+ ULONGEST *xfered_len)
{
switch (object)
{
return go32_xfer_memory (readbuf, writebuf, offset, len, xfered_len);
default:
- return ops->beneath->to_xfer_partial (ops->beneath, 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 void
-go32_files_info (struct target_ops *target)
+void
+go32_nat_target::files_info ()
{
- printf_unfiltered ("You are running a DJGPP V2 program.\n");
+ gdb_printf ("You are running a DJGPP V2 program.\n");
}
-static void
-go32_kill_inferior (struct target_ops *ops)
+void
+go32_nat_target::kill_inferior ()
{
- go32_mourn_inferior (ops);
+ mourn_inferior ();
}
-static void
-go32_create_inferior (struct target_ops *ops, char *exec_file,
- char *args, char **env, int from_tty)
+void
+go32_nat_target::create_inferior (const char *exec_file,
+ const std::string &allargs,
+ char **env, int from_tty)
{
extern char **environ;
jmp_buf start_state;
size_t cmdlen;
struct inferior *inf;
int result;
+ const char *args = allargs.c_str ();
/* If no exec file handed to us, get it from the exec-file command -- with
a good, common error message if none is specified. */
/* Init command line storage. */
if (redir_debug_init (&child_cmd) == -1)
- internal_error (__FILE__, __LINE__,
- _("Cannot allocate redirection storage: "
+ internal_error (_("Cannot allocate redirection storage: "
"not enough memory.\n"));
/* Parse the command line and create redirections. */
save_npx ();
#endif
- inferior_ptid = pid_to_ptid (SOME_PID);
inf = current_inferior ();
inferior_appeared (inf, SOME_PID);
- if (!target_is_pushed (ops))
- push_target (ops);
+ if (!inf->target_is_pushed (this))
+ inf->push_target (this);
- add_thread_silent (inferior_ptid);
+ thread_info *thr = add_thread_silent (ptid_t (SOME_PID));
+ switch_to_thread (thr);
clear_proceed_status (0);
insert_breakpoints ();
prog_has_started = 1;
}
-static void
-go32_mourn_inferior (struct target_ops *ops)
+void
+go32_nat_target::mourn_inferior ()
{
- ptid_t ptid;
-
redir_cmdline_delete (&child_cmd);
resume_signal = -1;
resume_is_step = 0;
the OS cleans up when the debuggee exits. */
x86_cleanup_dregs ();
- ptid = inferior_ptid;
- inferior_ptid = null_ptid;
- delete_thread_silent (ptid);
prog_has_started = 0;
generic_mourn_inferior ();
- inf_child_maybe_unpush_target (ops);
+ maybe_unpush_target ();
}
/* Hardware watchpoint support. */
go32_set_dr (int i, CORE_ADDR addr)
{
if (i < 0 || i > 3)
- internal_error (__FILE__, __LINE__,
- _("Invalid register %d in go32_set_dr.\n"), i);
+ internal_error (_("Invalid register %d in go32_set_dr.\n"), i);
D_REGS[i] = addr;
}
go32_get_dr (int i)
{
if (i < 0 || i > 3)
- internal_error (__FILE__, __LINE__,
- _("Invalid register %d in go32_get_dr.\n"), i);
+ internal_error (_("Invalid register %d in go32_get_dr.\n"), i);
return D_REGS[i];
}
newmode &= ~0x20;
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. */
- __dpmi_int (0x21, ®s);
- if (regs.x.flags & 1)
- return -1;
- }
+ {
+ regs.x.ax = 0x4401;
+ regs.x.bx = fd;
+ regs.x.dx = newmode & 0xff; /* Force upper byte zero, else it fails. */
+ __dpmi_int (0x21, ®s);
+ if (regs.x.flags & 1)
+ return -1;
+ }
return (oldmode & 0x20) == 0x20;
}
second call will always see GDB's own cooked terminal. */
static int terminal_is_ours = 1;
-static void
-go32_terminal_init (struct target_ops *self)
+void
+go32_nat_target::terminal_init ()
{
inf_mode_valid = 0; /* Reinitialize, in case they are restarting child. */
terminal_is_ours = 1;
}
-static void
-go32_terminal_info (struct target_ops *self, const char *args, int from_tty)
+void
+go32_nat_target::terminal_info (const char *args, int from_tty)
{
- printf_unfiltered ("Inferior's terminal is in %s mode.\n",
- !inf_mode_valid
- ? "default" : inf_terminal_mode ? "raw" : "cooked");
+ gdb_printf ("Inferior's terminal is in %s mode.\n",
+ !inf_mode_valid
+ ? "default" : inf_terminal_mode ? "raw" : "cooked");
#if __DJGPP_MINOR__ > 2
if (child_cmd.redirection)
- {
- int i;
-
- for (i = 0; i < DBG_HANDLES; i++)
{
- if (child_cmd.redirection[i]->file_name)
- printf_unfiltered ("\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)
- printf_unfiltered
- ("\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)
- != (_get_dev_info (i) & 0xdf))
- printf_unfiltered
- ("\tFile handle %d appears to be redirected by inferior.\n", i);
+ int i;
+
+ 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);
+ 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);
+ /* Mask off the raw/cooked bit when comparing device info words. */
+ 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);
+ }
}
- }
#endif
}
-static void
-go32_terminal_inferior (struct target_ops *self)
+void
+go32_nat_target::terminal_inferior ()
{
/* Redirect standard handles as child wants them. */
errno = 0;
if (redir_to_child (&child_cmd) == -1)
- {
- redir_to_debugger (&child_cmd);
- error (_("Cannot redirect standard handles for program: %s."),
- safe_strerror (errno));
- }
+ {
+ redir_to_debugger (&child_cmd);
+ error (_("Cannot redirect standard handles for program: %s."),
+ safe_strerror (errno));
+ }
/* Set the console device of the inferior to whatever mode
(raw or cooked) we found it last time. */
if (terminal_is_ours)
- {
- if (inf_mode_valid)
- device_mode (0, inf_terminal_mode);
- terminal_is_ours = 0;
- }
+ {
+ if (inf_mode_valid)
+ device_mode (0, inf_terminal_mode);
+ terminal_is_ours = 0;
+ }
}
-static void
-go32_terminal_ours (struct target_ops *self)
+void
+go32_nat_target::terminal_ours ()
{
/* Switch to cooked mode on the gdb terminal and save the inferior
terminal mode to be restored when it is resumed. */
if (!terminal_is_ours)
- {
- inf_terminal_mode = device_mode (0, 0);
- if (inf_terminal_mode != -1)
- inf_mode_valid = 1;
- else
- /* If device_mode returned -1, we don't know what happens with
- handle 0 anymore, so make the info invalid. */
- inf_mode_valid = 0;
- terminal_is_ours = 1;
-
- /* Restore debugger's standard handles. */
- errno = 0;
- if (redir_to_debugger (&child_cmd) == -1)
{
- redir_to_child (&child_cmd);
- error (_("Cannot redirect standard handles for debugger: %s."),
- safe_strerror (errno));
+ inf_terminal_mode = device_mode (0, 0);
+ if (inf_terminal_mode != -1)
+ inf_mode_valid = 1;
+ else
+ /* If device_mode returned -1, we don't know what happens with
+ handle 0 anymore, so make the info invalid. */
+ inf_mode_valid = 0;
+ terminal_is_ours = 1;
+
+ /* Restore debugger's standard handles. */
+ errno = 0;
+ if (redir_to_debugger (&child_cmd) == -1)
+ {
+ redir_to_child (&child_cmd);
+ error (_("Cannot redirect standard handles for debugger: %s."),
+ safe_strerror (errno));
+ }
}
- }
}
-static int
-go32_thread_alive (struct target_ops *ops, ptid_t ptid)
+void
+go32_nat_target::pass_ctrlc ()
{
- return !ptid_equal (inferior_ptid, null_ptid);
}
-static char *
-go32_pid_to_str (struct target_ops *ops, ptid_t ptid)
+bool
+go32_nat_target::thread_alive (ptid_t ptid)
{
- return normal_pid_to_str (ptid);
+ return ptid != null_ptid;
}
-/* Create a go32 target. */
-
-static struct target_ops *
-go32_target (void)
+std::string
+go32_nat_target::pid_to_str (ptid_t ptid)
{
- struct target_ops *t = inf_child_target ();
-
- t->to_attach = go32_attach;
- t->to_resume = go32_resume;
- t->to_wait = go32_wait;
- t->to_fetch_registers = go32_fetch_registers;
- t->to_store_registers = go32_store_registers;
- t->to_xfer_partial = go32_xfer_partial;
- t->to_files_info = go32_files_info;
- t->to_terminal_init = go32_terminal_init;
- t->to_terminal_inferior = go32_terminal_inferior;
- t->to_terminal_ours_for_output = go32_terminal_ours;
- t->to_terminal_ours = go32_terminal_ours;
- t->to_terminal_info = go32_terminal_info;
- t->to_kill = go32_kill_inferior;
- t->to_create_inferior = go32_create_inferior;
- t->to_mourn_inferior = go32_mourn_inferior;
- t->to_thread_alive = go32_thread_alive;
- t->to_pid_to_str = go32_pid_to_str;
-
- return t;
+ return normal_pid_to_str (ptid);
}
/* Return the current DOS codepage number. */
{
if (in_pages_p)
datum <<= 12;
- puts_filtered (header);
+ gdb_puts (header);
if (datum > 1024)
{
- printf_filtered ("%lu KB", datum >> 10);
+ gdb_printf ("%lu KB", datum >> 10);
if (datum > 1024 * 1024)
- printf_filtered (" (%lu MB)", datum >> 20);
+ gdb_printf (" (%lu MB)", datum >> 20);
}
else
- printf_filtered ("%lu Bytes", datum);
- puts_filtered ("\n");
+ gdb_printf ("%lu Bytes", datum);
+ gdb_puts ("\n");
}
}
/* Display assorted information about the underlying OS. */
static void
-go32_sysinfo (char *arg, int from_tty)
+go32_sysinfo (const char *arg, int from_tty)
{
static const char test_pattern[] =
"deadbeafdeadbeafdeadbeafdeadbeafdeadbeaf"
/* CPUID with EAX = 0 returns the Vendor ID. */
#if 0
/* Ideally we would use x86_cpuid(), but it needs someone to run
- native tests first to make sure things actually work. They should.
- http://sourceware.org/ml/gdb-patches/2013-05/msg00164.html */
+ native tests first to make sure things actually work. They should.
+ http://sourceware.org/ml/gdb-patches/2013-05/msg00164.html */
unsigned int eax, ebx, ecx, edx;
if (x86_cpuid (0, &eax, &ebx, &ecx, &edx))
#endif
}
- printf_filtered ("CPU Type.......................%s", u.machine);
+ gdb_printf ("CPU Type.......................%s", u.machine);
if (cpuid_vendor[0])
- printf_filtered (" (%s)", cpuid_vendor);
- puts_filtered ("\n");
+ gdb_printf (" (%s)", cpuid_vendor);
+ gdb_puts ("\n");
/* CPUID with EAX = 1 returns processor signature and features. */
if (cpuid_max >= 1)
{
- static char *brand_name[] = {
+ static const char *brand_name[] = {
"",
" Celeron",
" III",
unsigned brand_idx;
int intel_p = strcmp (cpuid_vendor, "GenuineIntel") == 0;
int amd_p = strcmp (cpuid_vendor, "AuthenticAMD") == 0;
+ int hygon_p = strcmp (cpuid_vendor, "HygonGenuine") == 0;
unsigned cpu_family, cpu_model;
#if 0
}
}
xsnprintf (cpu_string, sizeof (cpu_string), "%s%s Model %d Stepping %d",
- intel_p ? "Pentium" : (amd_p ? "AMD" : "ix86"),
- cpu_brand, cpu_model, cpuid_eax & 0xf);
- printfi_filtered (31, "%s\n", cpu_string);
+ 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)
- || (amd_p && (cpuid_edx & (3 << 30)) != 0))
+ || ((amd_p || hygon_p) && (cpuid_edx & (3 << 30)) != 0))
{
- puts_filtered ("CPU Features...................");
+ gdb_puts ("CPU Features...................");
/* We only list features which might be useful in the DPMI
environment. */
if ((cpuid_edx & 1) == 0)
- puts_filtered ("No FPU "); /* It's unusual to not have an FPU. */
+ gdb_puts ("No FPU "); /* It's unusual to not have an FPU. */
if ((cpuid_edx & (1 << 1)) != 0)
- puts_filtered ("VME ");
+ gdb_puts ("VME ");
if ((cpuid_edx & (1 << 2)) != 0)
- puts_filtered ("DE ");
+ gdb_puts ("DE ");
if ((cpuid_edx & (1 << 4)) != 0)
- puts_filtered ("TSC ");
+ gdb_puts ("TSC ");
if ((cpuid_edx & (1 << 23)) != 0)
- puts_filtered ("MMX ");
+ gdb_puts ("MMX ");
if ((cpuid_edx & (1 << 25)) != 0)
- puts_filtered ("SSE ");
+ gdb_puts ("SSE ");
if ((cpuid_edx & (1 << 26)) != 0)
- puts_filtered ("SSE2 ");
- if (amd_p)
+ gdb_puts ("SSE2 ");
+ if (amd_p || hygon_p)
{
if ((cpuid_edx & (1 << 31)) != 0)
- puts_filtered ("3DNow! ");
+ gdb_puts ("3DNow! ");
if ((cpuid_edx & (1 << 30)) != 0)
- puts_filtered ("3DNow!Ext");
+ gdb_puts ("3DNow!Ext");
}
- puts_filtered ("\n");
+ gdb_puts ("\n");
}
}
- puts_filtered ("\n");
- printf_filtered ("DOS Version....................%s %s.%s",
- _os_flavor, u.release, u.version);
+ gdb_puts ("\n");
+ gdb_printf ("DOS Version....................%s %s.%s",
+ _os_flavor, u.release, u.version);
if (true_dos_version != advertized_dos_version)
- printf_filtered (" (disguised as v%d.%d)", _osmajor, _osminor);
- puts_filtered ("\n");
+ gdb_printf (" (disguised as v%d.%d)", _osmajor, _osminor);
+ gdb_puts ("\n");
if (!windows_major)
go32_get_windows_version ();
if (windows_major != 0xff)
{
const char *windows_flavor;
- printf_filtered ("Windows Version................%d.%02d (Windows ",
- windows_major, windows_minor);
+ gdb_printf ("Windows Version................%d.%02d (Windows ",
+ windows_major, windows_minor);
switch (windows_major)
{
case 3:
windows_flavor = "??";
break;
}
- printf_filtered ("%s)\n", windows_flavor);
+ gdb_printf ("%s)\n", windows_flavor);
}
else if (true_dos_version == 0x532 && advertized_dos_version == 0x500)
- printf_filtered ("Windows Version................"
- "Windows NT family (W2K/XP/W2K3/Vista/W2K8)\n");
- puts_filtered ("\n");
+ gdb_printf ("Windows Version................"
+ "Windows NT family (W2K/XP/W2K3/Vista/W2K8)\n");
+ gdb_puts ("\n");
/* 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. */
I don't trust the vendors to follow that... */
if (!memchr (&dpmi_vendor_info[2], 0, 126))
dpmi_vendor_info[128] = '\0';
- printf_filtered ("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));
+ 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));
}
else
- printf_filtered ("DPMI Host......................(Info not available)\n");
+ gdb_printf ("DPMI Host......................(Info not available)\n");
__dpmi_get_version (&dpmi_version_data);
- printf_filtered ("DPMI Version...................%d.%02d\n",
- dpmi_version_data.major, dpmi_version_data.minor);
- printf_filtered ("DPMI Info......................"
- "%s-bit DPMI, with%s Virtual Memory support\n",
- (dpmi_version_data.flags & 1) ? "32" : "16",
- (dpmi_version_data.flags & 4) ? "" : "out");
- printfi_filtered (31, "Interrupts reflected to %s mode\n",
- (dpmi_version_data.flags & 2) ? "V86" : "Real");
- printfi_filtered (31, "Processor type: i%d86\n",
- dpmi_version_data.cpu);
- printfi_filtered (31, "PIC base interrupt: Master: %#x Slave: %#x\n",
- dpmi_version_data.master_pic, dpmi_version_data.slave_pic);
+ gdb_printf ("DPMI Version...................%d.%02d\n",
+ dpmi_version_data.major, dpmi_version_data.minor);
+ gdb_printf ("DPMI Info......................"
+ "%s-bit DPMI, with%s Virtual Memory support\n",
+ (dpmi_version_data.flags & 1) ? "32" : "16",
+ (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 ("%*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));
- printf_filtered ("Protection....................."
- "Ring %d (in %s), with%s I/O protection\n",
- a_tss.tss_cs & 3, (a_tss.tss_cs & 4) ? "LDT" : "GDT",
- (a_tss.tss_cs & 3) > ((eflags >> 12) & 3) ? "" : "out");
+ 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",
+ (a_tss.tss_cs & 3) > ((eflags >> 12) & 3) ? "" : "out");
}
- puts_filtered ("\n");
+ gdb_puts ("\n");
__dpmi_get_free_memory_information (&mem_info);
print_mem (mem_info.total_number_of_physical_pages,
"DPMI Total Physical Memory.....", 1);
hilo_idx = 0;
if (fit_idx > 2)
fit_idx = 0;
- printf_filtered ("DOS Memory Allocation..........%s memory, %s fit\n",
- dos_hilo[hilo_idx], dos_fit[fit_idx]);
+ gdb_printf ("DOS Memory Allocation..........%s memory, %s fit\n",
+ dos_hilo[hilo_idx], dos_fit[fit_idx]);
regs.x.ax = 0x5802;
__dpmi_int (0x21, ®s);
if ((regs.x.flags & 1) != 0)
regs.h.al = 0;
- printfi_filtered (31, "UMBs %sin DOS memory chain\n",
- regs.h.al == 0 ? "not " : "");
+ gdb_printf ("%*sUMBs %sin DOS memory chain\n", 31, "",
+ regs.h.al == 0 ? "not " : "");
}
}
/* Get the descriptor from the table. */
if (idx == 0 && type == 0)
- puts_filtered ("0x000: null descriptor\n");
+ gdb_puts ("0x000: null descriptor\n");
else if (get_descriptor (base_addr, idx, &descr) != -1)
{
/* For each type of descriptor table, this has a bit set if the
if (descr.present
&& (allowed_descriptors[type] & (1 << descr.stype)) != 0)
{
- printf_filtered ("0x%03x: ",
- type == 1
- ? idx : (idx * 8) | (type ? (cpl | 4) : 0));
+ gdb_printf ("0x%03x: ",
+ 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))
- printf_filtered ("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:
- printf_filtered (" 16-bit TSS (task %sactive)",
- descr.stype == 3 ? "" : "in");
+ gdb_printf (" 16-bit TSS (task %sactive)",
+ descr.stype == 3 ? "" : "in");
break;
case 2:
- puts_filtered (" LDT");
+ gdb_puts (" LDT");
break;
case 4:
memcpy (&gate, &descr, sizeof gate);
- printf_filtered ("selector=0x%04x offs=0x%04x%04x",
- gate.selector, gate.offset1, gate.offset0);
- printf_filtered (" 16-bit Call Gate (params=%d)",
- gate.param_count);
+ 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:
- printf_filtered ("TSS selector=0x%04x", descr.base0);
- printfi_filtered (16, "Task Gate");
+ gdb_printf ("TSS selector=0x%04x", descr.base0);
+ gdb_printf ("%*sTask Gate", 16, "");
break;
case 6:
case 7:
memcpy (&gate, &descr, sizeof gate);
- printf_filtered ("selector=0x%04x offs=0x%04x%04x",
- gate.selector, gate.offset1, gate.offset0);
- printf_filtered (" 16-bit %s Gate",
- descr.stype == 6 ? "Interrupt" : "Trap");
+ 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:
- printf_filtered (" 32-bit TSS (task %sactive)",
- descr.stype == 3 ? "" : "in");
+ gdb_printf (" 32-bit TSS (task %sactive)",
+ descr.stype == 3 ? "" : "in");
break;
case 12:
memcpy (&gate, &descr, sizeof gate);
- printf_filtered ("selector=0x%04x offs=0x%04x%04x",
- gate.selector, gate.offset1, gate.offset0);
- printf_filtered (" 32-bit Call Gate (params=%d)",
- gate.param_count);
+ 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);
- printf_filtered ("selector=0x%04x offs=0x%04x%04x",
- gate.selector, gate.offset1, gate.offset0);
- printf_filtered (" 32-bit %s Gate",
- descr.stype == 14 ? "Interrupt" : "Trap");
+ 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 21:
case 22:
case 23:
- printf_filtered (" %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");
+ 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 29:
case 30:
case 31:
- printf_filtered (" %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");
+ 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:
- printf_filtered ("Unknown type 0x%02x", descr.stype);
+ gdb_printf ("Unknown type 0x%02x", descr.stype);
break;
}
- puts_filtered ("\n");
+ gdb_puts ("\n");
}
else if (force)
{
- printf_filtered ("0x%03x: ",
- type == 1
- ? idx : (idx * 8) | (type ? (cpl | 4) : 0));
+ gdb_printf ("0x%03x: ",
+ type == 1
+ ? idx : (idx * 8) | (type ? (cpl | 4) : 0));
if (!descr.present)
- puts_filtered ("Segment not present\n");
+ gdb_puts ("Segment not present\n");
else
- printf_filtered ("Segment type 0x%02x is invalid in this table\n",
- descr.stype);
+ gdb_printf ("Segment type 0x%02x is invalid in this table\n",
+ descr.stype);
}
}
else if (force)
- printf_filtered ("0x%03x: Cannot read this descriptor\n", idx);
+ gdb_printf ("0x%03x: Cannot read this descriptor\n", idx);
}
static void
-go32_sldt (char *arg, int from_tty)
+go32_sldt (const char *arg, int from_tty)
{
struct dtr_reg gdtr;
unsigned short ldtr = 0;
__asm__ __volatile__ ("sldt %0" : "=m" (ldtr) : /* no inputs */ );
ldt_idx = ldtr / 8;
if (ldt_idx == 0)
- puts_filtered ("There is no LDT.\n");
+ 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)
- printf_filtered ("LDT is present (at %#x), but unreadable by GDB.\n",
- ldt_descr.base0
- | (ldt_descr.base1 << 16)
- | (ldt_descr.base2 << 24));
+ gdb_printf ("LDT is present (at %#x), but unreadable by GDB.\n",
+ ldt_descr.base0
+ | (ldt_descr.base1 << 16)
+ | (ldt_descr.base2 << 24));
else
{
unsigned base =
}
static void
-go32_sgdt (char *arg, int from_tty)
+go32_sgdt (const char *arg, int from_tty)
{
struct dtr_reg gdtr;
long gdt_entry = -1L;
}
static void
-go32_sidt (char *arg, int from_tty)
+go32_sidt (const char *arg, int from_tty)
{
struct dtr_reg idtr;
long idt_entry = -1L;
cr3 = _farnspeekl (taskbase + 0x1c) & ~0xfff;
if (cr3 > 0xfffff)
{
-#if 0 /* Not fullly 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
Directory entry for that Page Table will hold the same
physical address. The loop below searches the entire UMB
- range of addresses for such an occurence. */
+ range of addresses for such an occurrence. */
unsigned long addr, pte_idx;
for (addr = 0xb0000, pte_idx = 0xb0;
{
if ((entry & 1) != 0)
{
- printf_filtered ("Base=0x%05lx000", entry >> 12);
+ gdb_printf ("Base=0x%05lx000", entry >> 12);
if ((entry & 0x100) && !is_dir)
- puts_filtered (" Global");
+ gdb_puts (" Global");
if ((entry & 0x40) && !is_dir)
- puts_filtered (" Dirty");
- printf_filtered (" %sAcc.", (entry & 0x20) ? "" : "Not-");
- printf_filtered (" %sCached", (entry & 0x10) ? "" : "Not-");
- printf_filtered (" Write-%s", (entry & 8) ? "Thru" : "Back");
- printf_filtered (" %s", (entry & 4) ? "Usr" : "Sup");
- printf_filtered (" Read-%s", (entry & 2) ? "Write" : "Only");
+ gdb_puts (" Dirty");
+ gdb_printf (" %sAcc.", (entry & 0x20) ? "" : "Not-");
+ gdb_printf (" %sCached", (entry & 0x10) ? "" : "Not-");
+ gdb_printf (" Write-%s", (entry & 8) ? "Thru" : "Back");
+ gdb_printf (" %s", (entry & 4) ? "Usr" : "Sup");
+ gdb_printf (" Read-%s", (entry & 2) ? "Write" : "Only");
if (off)
- printf_filtered (" +0x%x", off);
- puts_filtered ("\n");
+ gdb_printf (" +0x%x", off);
+ gdb_puts ("\n");
}
else if (force)
- printf_filtered ("Page%s not present or not supported; value=0x%lx.\n",
- is_dir ? " Table" : "", entry >> 1);
+ gdb_printf ("Page%s not present or not supported; value=0x%lx.\n",
+ is_dir ? " Table" : "", entry >> 1);
}
static void
-go32_pde (char *arg, int from_tty)
+go32_pde (const char *arg, int from_tty)
{
long pde_idx = -1, i;
pdbr = get_cr3 ();
if (!pdbr)
- puts_filtered ("Access to Page Directories is "
- "not supported on this system.\n");
+ gdb_puts ("Access to Page Directories is "
+ "not supported on this system.\n");
else if (pde_idx >= 0)
display_ptable_entry (get_pde (pde_idx), 1, 1, 0);
else
{
int i;
- printf_filtered ("Page Table pointed to by "
- "Page Directory entry 0x%lx:\n", n);
+ gdb_printf ("Page Table pointed to by "
+ "Page Directory entry 0x%lx:\n", n);
for (i = 0; i < 1024; i++)
display_ptable_entry (get_pte (pde, i), 0, 0, 0);
- puts_filtered ("\n");
+ gdb_puts ("\n");
}
else if (force)
- printf_filtered ("Page Table not present; value=0x%lx.\n", pde >> 1);
+ gdb_printf ("Page Table not present; value=0x%lx.\n", pde >> 1);
}
static void
-go32_pte (char *arg, int from_tty)
+go32_pte (const char *arg, int from_tty)
{
long pde_idx = -1L, i;
pdbr = get_cr3 ();
if (!pdbr)
- puts_filtered ("Access to Page Tables is not supported on this system.\n");
+ gdb_puts ("Access to Page Tables is not supported on this system.\n");
else if (pde_idx >= 0)
display_page_table (pde_idx, 1);
else
}
static void
-go32_pte_for_address (char *arg, int from_tty)
+go32_pte_for_address (const char *arg, int from_tty)
{
CORE_ADDR addr = 0, i;
pdbr = get_cr3 ();
if (!pdbr)
- puts_filtered ("Access to Page Tables is not supported on this system.\n");
+ gdb_puts ("Access to Page Tables is not supported on this system.\n");
else
{
int pde_idx = (addr >> 22) & 0x3ff;
int pte_idx = (addr >> 12) & 0x3ff;
unsigned offs = addr & 0xfff;
- printf_filtered ("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);
}
}
static struct cmd_list_element *info_dos_cmdlist = NULL;
-static void
-go32_info_dos_command (char *args, int from_tty)
-{
- help_list (info_dos_cmdlist, "info dos ", class_info, gdb_stdout);
-}
-
-/* -Wmissing-prototypes */
-extern initialize_file_ftype _initialize_go32_nat;
-
+void _initialize_go32_nat ();
void
-_initialize_go32_nat (void)
+_initialize_go32_nat ()
{
- struct target_ops *t = go32_target ();
-
x86_dr_low.set_control = go32_set_dr7;
x86_dr_low.set_addr = go32_set_dr;
x86_dr_low.get_status = go32_get_dr6;
x86_dr_low.get_addr = go32_get_dr;
x86_set_debug_register_length (4);
- x86_use_watchpoints (t);
- add_target (t);
+ add_inf_child_target (&the_go32_nat_target);
/* Initialize child's cwd as empty to be initialized when starting
the child. */
/* Initialize child's command line storage. */
if (redir_debug_init (&child_cmd) == -1)
- internal_error (__FILE__, __LINE__,
- _("Cannot allocate redirection storage: "
+ internal_error (_("Cannot allocate redirection storage: "
"not enough memory.\n"));
/* We are always processing GCC-compiled programs. */
processing_gcc_compilation = 2;
- add_prefix_cmd ("dos", class_info, go32_info_dos_command, _("\
+ add_basic_prefix_cmd ("dos", class_info, _("\
Print information specific to DJGPP (aka MS-DOS) debugging."),
- &info_dos_cmdlist, "info dos ", 0, &infolist);
+ &info_dos_cmdlist, 0, &infolist);
add_cmd ("sysinfo", class_info, go32_sysinfo, _("\
Display information about the target system, including CPU, OS, DPMI, etc."),