gdbserver/linux-low: turn the 'decr_pc_after_break' field into a method
[deliverable/binutils-gdb.git] / gdbserver / linux-mips-low.cc
index cb7eb53e3ebf81d258f01f2912f2d20d189d2f6e..82e141f0250528fddb7ac3e06d13ccb4bb8d96f3 100644 (file)
 #include "nat/mips-linux-watch.h"
 #include "gdb_proc_service.h"
 
+/* Linux target op definitions for the MIPS architecture.  */
+
+class mips_target : public linux_process_target
+{
+public:
+
+  const regs_info *get_regs_info () override;
+
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
+protected:
+
+  void low_arch_setup () override;
+
+  bool low_cannot_fetch_register (int regno) override;
+
+  bool low_cannot_store_register (int regno) override;
+
+  bool low_fetch_register (regcache *regcache, int regno) override;
+
+  bool low_supports_breakpoints () override;
+
+  CORE_ADDR low_get_pc (regcache *regcache) override;
+
+  void low_set_pc (regcache *regcache, CORE_ADDR newpc) override;
+};
+
+/* The singleton target ops object.  */
+
+static mips_target the_mips_target;
+
 /* Defined in auto-generated file mips-linux.c.  */
 void init_registers_mips_linux (void);
 extern const struct target_desc *tdesc_mips_linux;
@@ -147,20 +178,12 @@ mips_read_description (void)
   return have_dsp ? tdesc_mips_dsp_linux : tdesc_mips_linux;
 }
 
-static void
-mips_arch_setup (void)
+void
+mips_target::low_arch_setup ()
 {
   current_process ()->tdesc = mips_read_description ();
 }
 
-static struct usrregs_info *
-get_usrregs_info (void)
-{
-  const struct regs_info *regs_info = the_low_target.regs_info ();
-
-  return regs_info->usrregs;
-}
-
 /* Per-process arch-specific data we want to keep.  */
 
 struct arch_process_info
@@ -201,79 +224,85 @@ struct arch_lwp_info
    ZERO_REGNUM, it's always 0.  We also can not set BADVADDR, CAUSE,
    or FCRIR via ptrace().  */
 
-static int
-mips_cannot_fetch_register (int regno)
+bool
+mips_target::low_cannot_fetch_register (int regno)
 {
   const struct target_desc *tdesc;
 
-  if (get_usrregs_info ()->regmap[regno] == -1)
-    return 1;
+  if (get_regs_info ()->usrregs->regmap[regno] == -1)
+    return true;
 
   tdesc = current_process ()->tdesc;
 
   /* On n32 we can't access 64-bit registers via PTRACE_PEEKUSR.  */
   if (register_size (tdesc, regno) > sizeof (PTRACE_XFER_TYPE))
-    return 1;
+    return true;
 
   if (find_regno (tdesc, "r0") == regno)
-    return 1;
+    return true;
 
-  return 0;
+  return false;
 }
 
-static int
-mips_cannot_store_register (int regno)
+bool
+mips_target::low_cannot_store_register (int regno)
 {
   const struct target_desc *tdesc;
 
-  if (get_usrregs_info ()->regmap[regno] == -1)
-    return 1;
+  if (get_regs_info ()->usrregs->regmap[regno] == -1)
+    return true;
 
   tdesc = current_process ()->tdesc;
 
   /* On n32 we can't access 64-bit registers via PTRACE_POKEUSR.  */
   if (register_size (tdesc, regno) > sizeof (PTRACE_XFER_TYPE))
-    return 1;
+    return true;
 
   if (find_regno (tdesc, "r0") == regno)
-    return 1;
+    return true;
 
   if (find_regno (tdesc, "cause") == regno)
-    return 1;
+    return true;
 
   if (find_regno (tdesc, "badvaddr") == regno)
-    return 1;
+    return true;
 
   if (find_regno (tdesc, "fir") == regno)
-    return 1;
+    return true;
 
-  return 0;
+  return false;
 }
 
-static int
-mips_fetch_register (struct regcache *regcache, int regno)
+bool
+mips_target::low_fetch_register (regcache *regcache, int regno)
 {
   const struct target_desc *tdesc = current_process ()->tdesc;
 
   if (find_regno (tdesc, "r0") == regno)
     {
       supply_register_zeroed (regcache, regno);
-      return 1;
+      return true;
     }
 
-  return 0;
+  return false;
 }
 
-static CORE_ADDR
-mips_get_pc (struct regcache *regcache)
+bool
+mips_target::low_supports_breakpoints ()
+{
+  return true;
+}
+
+CORE_ADDR
+mips_target::low_get_pc (regcache *regcache)
 {
   union mips_register pc;
   collect_register_by_name (regcache, "pc", pc.buf);
   return register_size (regcache->tdesc, 0) == 4 ? pc.reg32 : pc.reg64;
 }
 
-static void
-mips_set_pc (struct regcache *regcache, CORE_ADDR pc)
+void
+mips_target::low_set_pc (regcache *regcache, CORE_ADDR pc)
 {
   union mips_register newpc;
   if (register_size (regcache->tdesc, 0) == 4)
@@ -288,10 +317,10 @@ mips_set_pc (struct regcache *regcache, CORE_ADDR pc)
 static const unsigned int mips_breakpoint = 0x0005000d;
 #define mips_breakpoint_len 4
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-mips_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+mips_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = mips_breakpoint_len;
   return (const gdb_byte *) &mips_breakpoint;
@@ -302,7 +331,7 @@ mips_breakpoint_at (CORE_ADDR where)
 {
   unsigned int insn;
 
-  the_target->pt->read_memory (where, (unsigned char *) &insn, 4);
+  the_target->read_memory (where, (unsigned char *) &insn, 4);
   if (insn == mips_breakpoint)
     return 1;
 
@@ -920,34 +949,23 @@ static struct regs_info dsp_regs_info =
     &mips_regsets_info
   };
 
-static struct regs_info regs_info =
+static struct regs_info myregs_info =
   {
     NULL, /* regset_bitmap */
     &mips_usrregs_info,
     &mips_regsets_info
   };
 
-static const struct regs_info *
-mips_regs_info (void)
+const regs_info *
+mips_target::get_regs_info ()
 {
   if (have_dsp)
     return &dsp_regs_info;
   else
-    return &regs_info;
+    return &myregs_info;
 }
 
 struct linux_target_ops the_low_target = {
-  mips_arch_setup,
-  mips_regs_info,
-  mips_cannot_fetch_register,
-  mips_cannot_store_register,
-  mips_fetch_register,
-  mips_get_pc,
-  mips_set_pc,
-  NULL, /* breakpoint_kind_from_pc */
-  mips_sw_breakpoint_from_kind,
-  NULL, /* get_next_pcs */
-  0,
   mips_breakpoint_at,
   mips_supports_z_point_type,
   mips_insert_point,
@@ -965,6 +983,10 @@ struct linux_target_ops the_low_target = {
   mips_linux_prepare_to_resume
 };
 
+/* The linux target ops object.  */
+
+linux_process_target *the_linux_target = &the_mips_target;
+
 void
 initialize_low_arch (void)
 {
This page took 0.026416 seconds and 4 git commands to generate.