Blame SOURCES/gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch

861f93
2007-06-25  Jan Kratochvil  <jan.kratochvil@redhat.com>
861f93
861f93
	* inferior.h (enum resume_step): New definition.
861f93
	(resume): Change STEP parameter type to ENUM RESUME_STEP.
861f93
	* infrun.c (resume): Likewise.  Extend debug printing of the STEP
861f93
	parameter.  Lock the scheduler only for intentional stepping.
861f93
	(proceed): Replace the variable ONESTEP with tristate RESUME_STEP.
861f93
	Set the third RESUME_STEP state according to BPSTAT_SHOULD_STEP.
861f93
	(currently_stepping): Change the return type to ENUM RESUME_STEP.
861f93
	Return RESUME_STEP_NEEDED if it is just due to BPSTAT_SHOULD_STEP.
861f93
	* linux-nat.c (select_singlestep_lwp_callback): Do not focus on
861f93
	the software watchpoint events.
861f93
	* linux-nat.h (struct lwp_info): Redeclare STEP as ENUM RESUME_STEP.
861f93
861f93
2007-10-19  Jan Kratochvil  <jan.kratochvil@redhat.com>
861f93
861f93
	* infrun.c (proceed): RESUME_STEP initialized for non-stepping.
861f93
	RESUME_STEP set according to STEP only at the end of the function.
861f93
861f93
2008-02-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
861f93
861f93
	Port to GDB-6.8pre.
861f93
861f93
Index: gdb-7.5.50.20130215/gdb/inferior.h
861f93
===================================================================
861f93
--- gdb-7.5.50.20130215.orig/gdb/inferior.h	2013-01-16 18:31:38.000000000 +0100
861f93
+++ gdb-7.5.50.20130215/gdb/inferior.h	2013-02-15 22:31:42.993944957 +0100
861f93
@@ -160,7 +160,15 @@ extern void reopen_exec_file (void);
861f93
 /* The `resume' routine should only be called in special circumstances.
861f93
    Normally, use `proceed', which handles a lot of bookkeeping.  */
861f93
 
861f93
-extern void resume (int, enum gdb_signal);
861f93
+enum resume_step
861f93
+  {
861f93
+    /* currently_stepping () should return non-zero for non-continue.  */
861f93
+    RESUME_STEP_CONTINUE = 0,
861f93
+    RESUME_STEP_USER,		/* Stepping is intentional by the user.  */
861f93
+    RESUME_STEP_NEEDED		/* Stepping only for software watchpoints.  */
861f93
+  };
861f93
+
861f93
+extern void resume (enum resume_step, enum gdb_signal);
861f93
 
861f93
 extern ptid_t user_visible_resume_ptid (int step);
861f93
 
861f93
Index: gdb-7.5.50.20130215/gdb/infrun.c
861f93
===================================================================
861f93
--- gdb-7.5.50.20130215.orig/gdb/infrun.c	2013-01-31 20:18:58.000000000 +0100
861f93
+++ gdb-7.5.50.20130215/gdb/infrun.c	2013-02-15 22:34:07.132144519 +0100
861f93
@@ -81,7 +81,7 @@ static int follow_fork (void);
861f93
 static void set_schedlock_func (char *args, int from_tty,
861f93
 				struct cmd_list_element *c);
861f93
 
861f93
-static int currently_stepping (struct thread_info *tp);
861f93
+static enum resume_step currently_stepping (struct thread_info *tp);
861f93
 
861f93
 static int currently_stepping_or_nexting_callback (struct thread_info *tp,
861f93
 						   void *data);
861f93
@@ -1709,7 +1709,8 @@ user_visible_resume_ptid (int step)
861f93
     }
861f93
   else if ((scheduler_mode == schedlock_on)
861f93
 	   || (scheduler_mode == schedlock_step
861f93
-	       && (step || singlestep_breakpoints_inserted_p)))
861f93
+	       && (step == RESUME_STEP_USER
861f93
+		   || singlestep_breakpoints_inserted_p)))
861f93
     {
861f93
       /* User-settable 'scheduler' mode requires solo thread resume.  */
861f93
       resume_ptid = inferior_ptid;
861f93
@@ -1727,7 +1728,7 @@ user_visible_resume_ptid (int step)
861f93
    STEP nonzero if we should step (zero to continue instead).
861f93
    SIG is the signal to give the inferior (zero for none).  */
861f93
 void
861f93
-resume (int step, enum gdb_signal sig)
861f93
+resume (enum resume_step step, enum gdb_signal sig)
861f93
 {
861f93
   int should_resume = 1;
861f93
   struct cleanup *old_cleanups = make_cleanup (resume_cleanups, 0);
861f93
@@ -1760,9 +1761,13 @@ resume (int step, enum gdb_signal sig)
861f93
 
861f93
   if (debug_infrun)
861f93
     fprintf_unfiltered (gdb_stdlog,
861f93
-                        "infrun: resume (step=%d, signal=%d), "
861f93
+                        "infrun: resume (step=%s, signal=%d), "
861f93
 			"trap_expected=%d, current thread [%s] at %s\n",
861f93
- 			step, sig, tp->control.trap_expected,
861f93
+			(step == RESUME_STEP_CONTINUE
861f93
+			 ? "RESUME_STEP_CONTINUE"
861f93
+			 : (step == RESUME_STEP_USER ? "RESUME_STEP_USER"
861f93
+						     : "RESUME_STEP_NEEDED")),
861f93
+ 			sig, tp->control.trap_expected,
861f93
 			target_pid_to_str (inferior_ptid),
861f93
 			paddress (gdbarch, pc));
861f93
 
861f93
@@ -2140,7 +2145,7 @@ proceed (CORE_ADDR addr, enum gdb_signal
861f93
   CORE_ADDR pc;
861f93
   struct address_space *aspace;
861f93
   /* GDB may force the inferior to step due to various reasons.  */
861f93
-  int force_step = 0;
861f93
+  enum resume_step resume_step = RESUME_STEP_CONTINUE;
861f93
 
861f93
   /* If we're stopped at a fork/vfork, follow the branch set by the
861f93
      "set follow-fork-mode" command; otherwise, we'll just proceed
861f93
@@ -2180,13 +2185,13 @@ proceed (CORE_ADDR addr, enum gdb_signal
861f93
 	   actually be executing the breakpoint insn anyway.
861f93
 	   We'll be (un-)executing the previous instruction.  */
861f93
 
861f93
-	force_step = 1;
861f93
+	resume_step = RESUME_STEP_USER;
861f93
       else if (gdbarch_single_step_through_delay_p (gdbarch)
861f93
 	       && gdbarch_single_step_through_delay (gdbarch,
861f93
 						     get_current_frame ()))
861f93
 	/* We stepped onto an instruction that needs to be stepped
861f93
 	   again before re-inserting the breakpoint, do so.  */
861f93
-	force_step = 1;
861f93
+	resume_step = RESUME_STEP_USER;
861f93
     }
861f93
   else
861f93
     {
861f93
@@ -2217,13 +2222,13 @@ proceed (CORE_ADDR addr, enum gdb_signal
861f93
 	 is required it returns TRUE and sets the current thread to
861f93
 	 the old thread.  */
861f93
       if (prepare_to_proceed (step))
861f93
-	force_step = 1;
861f93
+	resume_step = RESUME_STEP_USER;
861f93
     }
861f93
 
861f93
   /* prepare_to_proceed may change the current thread.  */
861f93
   tp = inferior_thread ();
861f93
 
861f93
-  if (force_step)
861f93
+  if (resume_step == RESUME_STEP_USER)
861f93
     {
861f93
       tp->control.trap_expected = 1;
861f93
       /* If displaced stepping is enabled, we can step over the
861f93
@@ -2310,9 +2315,13 @@ proceed (CORE_ADDR addr, enum gdb_signal
861f93
   /* Reset to normal state.  */
861f93
   init_infwait_state ();
861f93
 
861f93
+  if (step)
861f93
+    resume_step = RESUME_STEP_USER;
861f93
+  if (resume_step == RESUME_STEP_CONTINUE && bpstat_should_step ())
861f93
+    resume_step = RESUME_STEP_NEEDED;
861f93
+
861f93
   /* Resume inferior.  */
861f93
-  resume (force_step || step || bpstat_should_step (),
861f93
-	  tp->suspend.stop_signal);
861f93
+  resume (resume_step, tp->suspend.stop_signal);
861f93
 
861f93
   /* Wait for it to stop (if not standalone)
861f93
      and in any case decode why it stopped, and act accordingly.  */
861f93
@@ -5247,13 +5256,18 @@ process_event_stop_test:
861f93
 
861f93
 /* Is thread TP in the middle of single-stepping?  */
861f93
 
861f93
-static int
861f93
+static enum resume_step
861f93
 currently_stepping (struct thread_info *tp)
861f93
 {
861f93
-  return ((tp->control.step_range_end
861f93
-	   && tp->control.step_resume_breakpoint == NULL)
861f93
-	  || tp->control.trap_expected
861f93
-	  || bpstat_should_step ());
861f93
+  if ((tp->control.step_range_end
861f93
+       && tp->control.step_resume_breakpoint == NULL)
861f93
+      || tp->control.trap_expected)
861f93
+    return RESUME_STEP_USER;
861f93
+
861f93
+  if (bpstat_should_step ())
861f93
+    return RESUME_STEP_NEEDED;
861f93
+
861f93
+  return RESUME_STEP_CONTINUE;
861f93
 }
861f93
 
861f93
 /* Returns true if any thread *but* the one passed in "data" is in the
861f93
Index: gdb-7.5.50.20130215/gdb/linux-nat.c
861f93
===================================================================
861f93
--- gdb-7.5.50.20130215.orig/gdb/linux-nat.c	2013-02-13 15:59:49.000000000 +0100
861f93
+++ gdb-7.5.50.20130215/gdb/linux-nat.c	2013-02-15 22:31:42.997944967 +0100
861f93
@@ -2971,7 +2971,11 @@ static int
861f93
 select_singlestep_lwp_callback (struct lwp_info *lp, void *data)
861f93
 {
861f93
   if (lp->last_resume_kind == resume_step
861f93
-      && lp->status != 0)
861f93
+      && lp->status != 0
861f93
+      /* We do not focus on software watchpoints as we would not catch
861f93
+	 STEPPING_PAST_SINGLESTEP_BREAKPOINT breakpoints in some other thread
861f93
+	 as they would remain pending due to `Push back breakpoint for %s'.  */
861f93
+      && lp->step == RESUME_STEP_USER)
861f93
     return 1;
861f93
   else
861f93
     return 0;
861f93
Index: gdb-7.5.50.20130215/gdb/linux-nat.h
861f93
===================================================================
861f93
--- gdb-7.5.50.20130215.orig/gdb/linux-nat.h	2013-02-13 15:59:49.000000000 +0100
861f93
+++ gdb-7.5.50.20130215/gdb/linux-nat.h	2013-02-15 22:31:42.998944969 +0100
861f93
@@ -73,8 +73,8 @@ struct lwp_info
861f93
   /* If non-zero, a pending wait status.  */
861f93
   int status;
861f93
 
861f93
-  /* Non-zero if we were stepping this LWP.  */
861f93
-  int step;
861f93
+  /* The kind of stepping of this LWP.  */
861f93
+  enum resume_step step;
861f93
 
861f93
   /* STOPPED_BY_WATCHPOINT is non-zero if this LWP stopped with a data
861f93
      watchpoint trap.  */