Refactor queries for hardware and software single stepping support in GDBServer.
[deliverable/binutils-gdb.git] / gdb / gdbserver / linux-low.c
index b29f54e523d4b40be7ede9f2b9e96c3b50d58936..cfc5987e092ace8af54b243ef93b4f0e391e118e 100644 (file)
@@ -269,13 +269,24 @@ static void complete_ongoing_step_over (void);
    being stepped.  */
 ptid_t step_over_bkpt;
 
-/* True if the low target can hardware single-step.  Such targets
-   don't need a BREAKPOINT_REINSERT_ADDR callback.  */
+/* True if the low target can hardware single-step.  */
 
 static int
 can_hardware_single_step (void)
 {
-  return (the_low_target.breakpoint_reinsert_addr == NULL);
+  if (the_low_target.supports_hardware_single_step != NULL)
+    return the_low_target.supports_hardware_single_step ();
+  else
+    return 0;
+}
+
+/* True if the low target can software single-step.  Such targets
+   implement the BREAKPOINT_REINSERT_ADDR callback.  */
+
+static int
+can_software_single_step (void)
+{
+  return (the_low_target.breakpoint_reinsert_addr != NULL);
 }
 
 /* True if the low target supports memory breakpoints.  If so, we'll
@@ -4509,12 +4520,17 @@ start_step_over (struct lwp_info *lwp)
     {
       step = 1;
     }
-  else
+  else if (can_software_single_step ())
     {
       CORE_ADDR raddr = (*the_low_target.breakpoint_reinsert_addr) ();
       set_reinsert_breakpoint (raddr);
       step = 0;
     }
+  else
+    {
+      internal_error (__FILE__, __LINE__,
+                     "stepping is not implemented on this target");
+    }
 
   current_thread = saved_thread;
 
@@ -5713,6 +5729,12 @@ linux_supports_hardware_single_step (void)
   return can_hardware_single_step ();
 }
 
+static int
+linux_supports_software_single_step (void)
+{
+  return can_software_single_step ();
+}
+
 static int
 linux_stopped_by_watchpoint (void)
 {
@@ -7153,7 +7175,8 @@ static struct target_ops linux_target_ops = {
   linux_breakpoint_kind_from_pc,
   linux_sw_breakpoint_from_kind,
   linux_proc_tid_get_name,
-  linux_breakpoint_kind_from_current_state
+  linux_breakpoint_kind_from_current_state,
+  linux_supports_software_single_step
 };
 
 static void
This page took 0.026714 seconds and 4 git commands to generate.