gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods
[deliverable/binutils-gdb.git] / gdbserver / linux-arm-low.cc
index e7cc119685740017b2e4ee8d76b77ad7f1b20e80..7b9ef8999f605fc22d961b585137290fc89518e9 100644 (file)
 #define PTRACE_SETHBPREGS 30
 #endif
 
+/* Linux target op definitions for the ARM architecture.  */
+
+class arm_target : public linux_process_target
+{
+public:
+
+  const regs_info *get_regs_info () 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_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 arm_target the_arm_target;
+
+bool
+arm_target::low_supports_breakpoints ()
+{
+  return true;
+}
+
+CORE_ADDR
+arm_target::low_get_pc (regcache *regcache)
+{
+  return linux_get_pc_32bit (regcache);
+}
+
+void
+arm_target::low_set_pc (regcache *regcache, CORE_ADDR pc)
+{
+  linux_set_pc_32bit (regcache, pc);
+}
+
 /* Information describing the hardware breakpoint capabilities.  */
 static struct
 {
@@ -149,14 +194,14 @@ static struct arm_get_next_pcs_ops get_next_pcs_ops = {
   arm_linux_get_next_pcs_fixup,
 };
 
-static int
-arm_cannot_store_register (int regno)
+bool
+arm_target::low_cannot_store_register (int regno)
 {
   return (regno >= arm_num_regs);
 }
 
-static int
-arm_cannot_fetch_register (int regno)
+bool
+arm_target::low_cannot_fetch_register (int regno)
 {
   return (regno >= arm_num_regs);
 }
@@ -779,15 +824,15 @@ arm_sigreturn_next_pc (struct regcache *regcache, int svc_number,
   gdb_assert (svc_number == __NR_sigreturn || svc_number == __NR_rt_sigreturn);
 
   collect_register_by_name (regcache, "sp", &sp);
-  the_target->pt->read_memory (sp, (unsigned char *) &sp_data, 4);
+  the_target->read_memory (sp, (unsigned char *) &sp_data, 4);
 
   pc_offset = arm_linux_sigreturn_next_pc_offset
     (sp, sp_data, svc_number, __NR_sigreturn == svc_number ? 1 : 0);
 
-  the_target->pt->read_memory (sp + pc_offset, (unsigned char *) &next_pc, 4);
+  the_target->read_memory (sp + pc_offset, (unsigned char *) &next_pc, 4);
 
   /* Set IS_THUMB according the CPSR saved on the stack.  */
-  the_target->pt->read_memory (sp + pc_offset + 4, (unsigned char *) &cpsr, 4);
+  the_target->read_memory (sp + pc_offset + 4, (unsigned char *) &cpsr, 4);
   *is_thumb = ((cpsr & CPSR_T) != 0);
 
   return next_pc;
@@ -877,8 +922,8 @@ arm_read_description (void)
   return arm_linux_read_description (ARM_FP_TYPE_NONE);
 }
 
-static void
-arm_arch_setup (void)
+void
+arm_target::low_arch_setup ()
 {
   int tid = lwpid_of (current_thread);
   int gpregs[18];
@@ -939,7 +984,7 @@ arm_get_syscall_trapinfo (struct regcache *regcache, int *sysno)
 
       collect_register_by_name (regcache, "pc", &pc);
 
-      if (the_target->pt->read_memory (pc - 4, (unsigned char *) &insn, 4))
+      if (the_target->read_memory (pc - 4, (unsigned char *) &insn, 4))
        *sysno = UNKNOWN_SYSCALL;
       else
        {
@@ -992,8 +1037,8 @@ static struct regs_info regs_info_arm =
     &arm_regsets_info
   };
 
-static const struct regs_info *
-arm_regs_info (void)
+const regs_info *
+arm_target::get_regs_info ()
 {
   const struct target_desc *tdesc = current_process ()->tdesc;
 
@@ -1006,13 +1051,6 @@ arm_regs_info (void)
 }
 
 struct linux_target_ops the_low_target = {
-  arm_arch_setup,
-  arm_regs_info,
-  arm_cannot_fetch_register,
-  arm_cannot_store_register,
-  NULL, /* fetch_register */
-  linux_get_pc_32bit,
-  linux_set_pc_32bit,
   arm_breakpoint_kind_from_pc,
   arm_sw_breakpoint_from_kind,
   arm_gdbserver_get_next_pcs,
@@ -1044,6 +1082,10 @@ struct linux_target_ops the_low_target = {
   arm_get_syscall_trapinfo,
 };
 
+/* The linux target ops object.  */
+
+linux_process_target *the_linux_target = &the_arm_target;
+
 void
 initialize_low_arch (void)
 {
This page took 0.025498 seconds and 4 git commands to generate.