gdbserver/linux-low: turn 'siginfo_fixup' into a method
[deliverable/binutils-gdb.git] / gdbserver / linux-arm-low.cc
index 1bbf0e6977f251d1b6a7d259a0a017165876547d..267899f99ef786fa7b52d922e5b8a170d4c26052 100644 (file)
@@ -62,6 +62,16 @@ public:
 
   const regs_info *get_regs_info () override;
 
+  int breakpoint_kind_from_pc (CORE_ADDR *pcptr) override;
+
+  int breakpoint_kind_from_current_state (CORE_ADDR *pcptr) override;
+
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
+  bool supports_software_single_step () override;
+
+  bool supports_z_point_type (char z_type) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -69,12 +79,74 @@ protected:
   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;
+
+  std::vector<CORE_ADDR> low_get_next_pcs (regcache *regcache) override;
+
+  bool low_breakpoint_at (CORE_ADDR pc) override;
+
+  int low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
+                       int size, raw_breakpoint *bp) override;
+
+  int low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
+                       int size, raw_breakpoint *bp) override;
+
+  bool low_stopped_by_watchpoint () override;
+
+  CORE_ADDR low_stopped_data_address () 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);
+}
+
+int
+arm_target::breakpoint_kind_from_pc (CORE_ADDR *pcptr)
+{
+  return arm_breakpoint_kind_from_pc (pcptr);
+}
+
+int
+arm_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
+{
+  return arm_breakpoint_kind_from_current_state (pcptr);
+}
+
+const gdb_byte *
+arm_target::sw_breakpoint_from_kind (int kind, int *size)
+{
+  return arm_sw_breakpoint_from_kind (kind, size);
+}
+
+bool
+arm_target::low_breakpoint_at (CORE_ADDR pc)
+{
+  return arm_breakpoint_at (pc);
+}
+
 /* Information describing the hardware breakpoint capabilities.  */
 static struct
 {
@@ -496,8 +568,8 @@ update_registers_callback (thread_info *thread, int watch, int i)
     linux_stop_lwp (lwp);
 }
 
-static int
-arm_supports_z_point_type (char z_type)
+bool
+arm_target::supports_z_point_type (char z_type)
 {
   switch (z_type)
     {
@@ -506,17 +578,17 @@ arm_supports_z_point_type (char z_type)
     case Z_PACKET_WRITE_WP:
     case Z_PACKET_READ_WP:
     case Z_PACKET_ACCESS_WP:
-      return 1;
+      return true;
     default:
       /* Leave the handling of sw breakpoints with the gdb client.  */
-      return 0;
+      return false;
     }
 }
 
 /* Insert hardware break-/watchpoint.  */
-static int
-arm_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
-                 int len, struct raw_breakpoint *bp)
+int
+arm_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
+                             int len, raw_breakpoint *bp)
 {
   struct process_info *proc = current_process ();
   struct arm_linux_hw_breakpoint p, *pts;
@@ -559,9 +631,9 @@ arm_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
 }
 
 /* Remove hardware break-/watchpoint.  */
-static int
-arm_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
-                 int len, struct raw_breakpoint *bp)
+int
+arm_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
+                             int len, raw_breakpoint *bp)
 {
   struct process_info *proc = current_process ();
   struct arm_linux_hw_breakpoint p, *pts;
@@ -604,43 +676,43 @@ arm_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
 }
 
 /* Return whether current thread is stopped due to a watchpoint.  */
-static int
-arm_stopped_by_watchpoint (void)
+bool
+arm_target::low_stopped_by_watchpoint ()
 {
   struct lwp_info *lwp = get_thread_lwp (current_thread);
   siginfo_t siginfo;
 
   /* We must be able to set hardware watchpoints.  */
   if (arm_linux_get_hw_watchpoint_count () == 0)
-    return 0;
+    return false;
 
   /* Retrieve siginfo.  */
   errno = 0;
   ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread), 0, &siginfo);
   if (errno != 0)
-    return 0;
+    return false;
 
   /* This must be a hardware breakpoint.  */
   if (siginfo.si_signo != SIGTRAP
       || (siginfo.si_code & 0xffff) != 0x0004 /* TRAP_HWBKPT */)
-    return 0;
+    return false;
 
   /* If we are in a positive slot then we're looking at a breakpoint and not
      a watchpoint.  */
   if (siginfo.si_errno >= 0)
-    return 0;
+    return false;
 
   /* Cache stopped data address for use by arm_stopped_data_address.  */
   lwp->arch_private->stopped_data_address
     = (CORE_ADDR) (uintptr_t) siginfo.si_addr;
 
-  return 1;
+  return true;
 }
 
 /* Return data address that triggered watchpoint.  Called only if
-   arm_stopped_by_watchpoint returned true.  */
-static CORE_ADDR
-arm_stopped_data_address (void)
+   low_stopped_by_watchpoint returned true.  */
+CORE_ADDR
+arm_target::low_stopped_data_address ()
 {
   struct lwp_info *lwp = get_thread_lwp (current_thread);
   return lwp->arch_private->stopped_data_address;
@@ -920,10 +992,16 @@ arm_target::low_arch_setup ()
     have_ptrace_getregset = 0;
 }
 
+bool
+arm_target::supports_software_single_step ()
+{
+  return true;
+}
+
 /* Fetch the next possible PCs after the current instruction executes.  */
 
-static std::vector<CORE_ADDR>
-arm_gdbserver_get_next_pcs (struct regcache *regcache)
+std::vector<CORE_ADDR>
+arm_target::low_get_next_pcs (regcache *regcache)
 {
   struct arm_get_next_pcs next_pcs_ctx;
 
@@ -1027,21 +1105,6 @@ arm_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  linux_get_pc_32bit,
-  linux_set_pc_32bit,
-  arm_breakpoint_kind_from_pc,
-  arm_sw_breakpoint_from_kind,
-  arm_gdbserver_get_next_pcs,
-  0,
-  arm_breakpoint_at,
-  arm_supports_z_point_type,
-  arm_insert_point,
-  arm_remove_point,
-  arm_stopped_by_watchpoint,
-  arm_stopped_data_address,
-  NULL, /* collect_ptrace_register */
-  NULL, /* supply_ptrace_register */
-  NULL, /* siginfo_fixup */
   arm_new_process,
   arm_delete_process,
   arm_new_thread,
@@ -1055,7 +1118,6 @@ struct linux_target_ops the_low_target = {
   NULL, /* emit_ops */
   NULL, /* get_min_fast_tracepoint_insn_len */
   NULL, /* supports_range_stepping */
-  arm_breakpoint_kind_from_current_state,
   arm_supports_hardware_single_step,
   arm_get_syscall_trapinfo,
 };
This page took 0.026577 seconds and 4 git commands to generate.