c78c51c
2007-06-25  Jan Kratochvil  <jan.kratochvil@redhat.com>
c78c51c
c78c51c
	* inferior.h (enum resume_step): New definition.
c78c51c
	(resume): Change STEP parameter type to ENUM RESUME_STEP.
c78c51c
	* infrun.c (resume): Likewise.  Extend debug printing of the STEP
c78c51c
	parameter.  Lock the scheduler only for intentional stepping.
c78c51c
	(proceed): Replace the variable ONESTEP with tristate RESUME_STEP.
c78c51c
	Set the third RESUME_STEP state according to BPSTAT_SHOULD_STEP.
c78c51c
	(currently_stepping): Change the return type to ENUM RESUME_STEP.
c78c51c
	Return RESUME_STEP_NEEDED if it is just due to BPSTAT_SHOULD_STEP.
c78c51c
	* linux-nat.c (select_singlestep_lwp_callback): Do not focus on
c78c51c
	the software watchpoint events.
c78c51c
	* linux-nat.h (struct lwp_info): Redeclare STEP as ENUM RESUME_STEP.
c78c51c
cc17157
2007-10-19  Jan Kratochvil  <jan.kratochvil@redhat.com>
cc17157
cc17157
	* infrun.c (proceed): RESUME_STEP initialized for non-stepping.
cc17157
	RESUME_STEP set according to STEP only at the end of the function.
cc17157
25ff8a1
2008-02-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
25ff8a1
25ff8a1
	Port to GDB-6.8pre.
25ff8a1
Jan Kratochvil 2c55a54
Index: gdb-7.6.90.20140127/gdb/inferior.h
25ff8a1
===================================================================
Jan Kratochvil 2c55a54
--- gdb-7.6.90.20140127.orig/gdb/inferior.h	2014-01-27 22:05:28.801895347 +0100
Jan Kratochvil 2c55a54
+++ gdb-7.6.90.20140127/gdb/inferior.h	2014-01-27 22:33:45.230157813 +0100
Jan Kratochvil 2c55a54
@@ -155,7 +155,15 @@ extern void reopen_exec_file (void);
5a72cda
 /* The `resume' routine should only be called in special circumstances.
5a72cda
    Normally, use `proceed', which handles a lot of bookkeeping.  */
5a72cda
 
Jan Kratochvil f8eee05
-extern void resume (int, enum gdb_signal);
5a72cda
+enum resume_step
5a72cda
+  {
5a72cda
+    /* currently_stepping () should return non-zero for non-continue.  */
5a72cda
+    RESUME_STEP_CONTINUE = 0,
5a72cda
+    RESUME_STEP_USER,		/* Stepping is intentional by the user.  */
5a72cda
+    RESUME_STEP_NEEDED		/* Stepping only for software watchpoints.  */
5a72cda
+  };
5a72cda
+
Jan Kratochvil f8eee05
+extern void resume (enum resume_step, enum gdb_signal);
5a72cda
 
Jan Kratochvil 3b55f78
 extern ptid_t user_visible_resume_ptid (int step);
5a72cda
 
Jan Kratochvil 2c55a54
Index: gdb-7.6.90.20140127/gdb/infrun.c
25ff8a1
===================================================================
Jan Kratochvil 2c55a54
--- gdb-7.6.90.20140127.orig/gdb/infrun.c	2014-01-27 22:05:28.804895349 +0100
Jan Kratochvil 2c55a54
+++ gdb-7.6.90.20140127/gdb/infrun.c	2014-01-27 22:35:12.781224279 +0100
Jan Kratochvil 2c55a54
@@ -83,7 +83,7 @@ static int follow_fork (void);
407ebe9
 static void set_schedlock_func (char *args, int from_tty,
407ebe9
 				struct cmd_list_element *c);
5a72cda
 
407ebe9
-static int currently_stepping (struct thread_info *tp);
407ebe9
+static enum resume_step currently_stepping (struct thread_info *tp);
5a72cda
 
e5611bf
 static int currently_stepping_or_nexting_callback (struct thread_info *tp,
e5611bf
 						   void *data);
Jan Kratochvil 2c55a54
@@ -1699,7 +1699,8 @@ user_visible_resume_ptid (int step)
Jan Kratochvil 3b55f78
     }
Jan Kratochvil 3b55f78
   else if ((scheduler_mode == schedlock_on)
Jan Kratochvil 3b55f78
 	   || (scheduler_mode == schedlock_step
Jan Kratochvil 3b55f78
-	       && (step || singlestep_breakpoints_inserted_p)))
Jan Kratochvil 3b55f78
+	       && (step == RESUME_STEP_USER
Jan Kratochvil 3b55f78
+		   || singlestep_breakpoints_inserted_p)))
Jan Kratochvil 3b55f78
     {
Jan Kratochvil 3b55f78
       /* User-settable 'scheduler' mode requires solo thread resume.  */
Jan Kratochvil 3b55f78
       resume_ptid = inferior_ptid;
Jan Kratochvil 2c55a54
@@ -1717,7 +1718,7 @@ user_visible_resume_ptid (int step)
5a72cda
    STEP nonzero if we should step (zero to continue instead).
5a72cda
    SIG is the signal to give the inferior (zero for none).  */
5a72cda
 void
Jan Kratochvil f8eee05
-resume (int step, enum gdb_signal sig)
Jan Kratochvil f8eee05
+resume (enum resume_step step, enum gdb_signal sig)
5a72cda
 {
5a72cda
   int should_resume = 1;
5a72cda
   struct cleanup *old_cleanups = make_cleanup (resume_cleanups, 0);
Jan Kratochvil 2c55a54
@@ -1750,9 +1751,13 @@ resume (int step, enum gdb_signal sig)
5a72cda
 
5a72cda
   if (debug_infrun)
Jan Kratochvil 3b55f78
     fprintf_unfiltered (gdb_stdlog,
Jan Kratochvil 2c55a54
-			"infrun: resume (step=%d, signal=%s), "
Jan Kratochvil 2c55a54
+			"infrun: resume (step=%s, signal=%s), "
Jan Kratochvil 3b55f78
 			"trap_expected=%d, current thread [%s] at %s\n",
Jan Kratochvil 2c55a54
-			step, gdb_signal_to_symbol_string (sig),
Jan Kratochvil 3b55f78
+			(step == RESUME_STEP_CONTINUE
Jan Kratochvil 3b55f78
+			 ? "RESUME_STEP_CONTINUE"
Jan Kratochvil 3b55f78
+			 : (step == RESUME_STEP_USER ? "RESUME_STEP_USER"
Jan Kratochvil 3b55f78
+						     : "RESUME_STEP_NEEDED")),
Jan Kratochvil 2c55a54
+			gdb_signal_to_symbol_string (sig),
Jan Kratochvil 2c55a54
 			tp->control.trap_expected,
Jan Kratochvil 3b55f78
 			target_pid_to_str (inferior_ptid),
Jan Kratochvil 3b55f78
 			paddress (gdbarch, pc));
Jan Kratochvil 2c55a54
@@ -2147,7 +2152,7 @@ proceed (CORE_ADDR addr, enum gdb_signal
e5611bf
   CORE_ADDR pc;
8c4c91e
   struct address_space *aspace;
Jan Kratochvil ab333d9
   /* GDB may force the inferior to step due to various reasons.  */
Jan Kratochvil ab333d9
-  int force_step = 0;
cc17157
+  enum resume_step resume_step = RESUME_STEP_CONTINUE;
5a72cda
 
e5611bf
   /* If we're stopped at a fork/vfork, follow the branch set by the
e5611bf
      "set follow-fork-mode" command; otherwise, we'll just proceed
Jan Kratochvil 2c55a54
@@ -2187,13 +2192,13 @@ proceed (CORE_ADDR addr, enum gdb_signal
407ebe9
 	   actually be executing the breakpoint insn anyway.
407ebe9
 	   We'll be (un-)executing the previous instruction.  */
407ebe9
 
Jan Kratochvil ab333d9
-	force_step = 1;
5a72cda
+	resume_step = RESUME_STEP_USER;
407ebe9
       else if (gdbarch_single_step_through_delay_p (gdbarch)
407ebe9
 	       && gdbarch_single_step_through_delay (gdbarch,
407ebe9
 						     get_current_frame ()))
5a72cda
 	/* We stepped onto an instruction that needs to be stepped
5a72cda
 	   again before re-inserting the breakpoint, do so.  */
Jan Kratochvil ab333d9
-	force_step = 1;
5a72cda
+	resume_step = RESUME_STEP_USER;
5a72cda
     }
5a72cda
   else
5a72cda
     {
Jan Kratochvil 2c55a54
@@ -2225,13 +2230,13 @@ proceed (CORE_ADDR addr, enum gdb_signal
407ebe9
 	 is required it returns TRUE and sets the current thread to
Jan Kratochvil b0e03f5
 	 the old thread.  */
407ebe9
       if (prepare_to_proceed (step))
Jan Kratochvil ab333d9
-	force_step = 1;
407ebe9
+	resume_step = RESUME_STEP_USER;
407ebe9
     }
407ebe9
 
407ebe9
   /* prepare_to_proceed may change the current thread.  */
407ebe9
   tp = inferior_thread ();
5a72cda
 
Jan Kratochvil ab333d9
-  if (force_step)
5a72cda
+  if (resume_step == RESUME_STEP_USER)
407ebe9
     {
Jan Kratochvil 6fa2f55
       tp->control.trap_expected = 1;
407ebe9
       /* If displaced stepping is enabled, we can step over the
Jan Kratochvil 2c55a54
@@ -2318,9 +2323,13 @@ proceed (CORE_ADDR addr, enum gdb_signal
407ebe9
   /* Reset to normal state.  */
407ebe9
   init_infwait_state ();
5a72cda
 
cc17157
+  if (step)
cc17157
+    resume_step = RESUME_STEP_USER;
5a72cda
+  if (resume_step == RESUME_STEP_CONTINUE && bpstat_should_step ())
5a72cda
+    resume_step = RESUME_STEP_NEEDED;
5a72cda
+
5a72cda
   /* Resume inferior.  */
Jan Kratochvil ab333d9
-  resume (force_step || step || bpstat_should_step (),
Jan Kratochvil ab333d9
-	  tp->suspend.stop_signal);
Jan Kratochvil 6fa2f55
+  resume (resume_step, tp->suspend.stop_signal);
5a72cda
 
5a72cda
   /* Wait for it to stop (if not standalone)
5a72cda
      and in any case decode why it stopped, and act accordingly.  */
Jan Kratochvil 2c55a54
@@ -5332,13 +5341,18 @@ switch_back_to_stepped_thread (struct ex
e5611bf
 
e5611bf
 /* Is thread TP in the middle of single-stepping?  */
5a72cda
 
5a72cda
-static int
5a72cda
+static enum resume_step
407ebe9
 currently_stepping (struct thread_info *tp)
5a72cda
 {
Jan Kratochvil 6fa2f55
-  return ((tp->control.step_range_end
Jan Kratochvil 6fa2f55
-	   && tp->control.step_resume_breakpoint == NULL)
Jan Kratochvil 6fa2f55
-	  || tp->control.trap_expected
Jan Kratochvil 6fa2f55
-	  || bpstat_should_step ());
Jan Kratochvil 6fa2f55
+  if ((tp->control.step_range_end
Jan Kratochvil 6fa2f55
+       && tp->control.step_resume_breakpoint == NULL)
Jan Kratochvil 254f0e9
+      || tp->control.trap_expected)
5a72cda
+    return RESUME_STEP_USER;
5a72cda
+
5a72cda
+  if (bpstat_should_step ())
5a72cda
+    return RESUME_STEP_NEEDED;
5a72cda
+
5a72cda
+  return RESUME_STEP_CONTINUE;
5a72cda
 }
5a72cda
 
e5611bf
 /* Returns true if any thread *but* the one passed in "data" is in the
Jan Kratochvil 2c55a54
Index: gdb-7.6.90.20140127/gdb/linux-nat.c
25ff8a1
===================================================================
Jan Kratochvil 2c55a54
--- gdb-7.6.90.20140127.orig/gdb/linux-nat.c	2014-01-27 22:05:28.806895350 +0100
Jan Kratochvil 2c55a54
+++ gdb-7.6.90.20140127/gdb/linux-nat.c	2014-01-27 22:33:45.330157889 +0100
Jan Kratochvil 2c55a54
@@ -2697,7 +2697,11 @@ static int
c78c51c
 select_singlestep_lwp_callback (struct lwp_info *lp, void *data)
c78c51c
 {
Jan Kratochvil 254f0e9
   if (lp->last_resume_kind == resume_step
Jan Kratochvil 254f0e9
-      && lp->status != 0)
Jan Kratochvil 254f0e9
+      && lp->status != 0
Jan Kratochvil 254f0e9
+      /* We do not focus on software watchpoints as we would not catch
Jan Kratochvil 254f0e9
+	 STEPPING_PAST_SINGLESTEP_BREAKPOINT breakpoints in some other thread
Jan Kratochvil 254f0e9
+	 as they would remain pending due to `Push back breakpoint for %s'.  */
Jan Kratochvil 254f0e9
+      && lp->step == RESUME_STEP_USER)
c78c51c
     return 1;
c78c51c
   else
c78c51c
     return 0;
Jan Kratochvil 2c55a54
Index: gdb-7.6.90.20140127/gdb/linux-nat.h
25ff8a1
===================================================================
Jan Kratochvil 2c55a54
--- gdb-7.6.90.20140127.orig/gdb/linux-nat.h	2014-01-27 22:05:28.807895351 +0100
Jan Kratochvil 2c55a54
+++ gdb-7.6.90.20140127/gdb/linux-nat.h	2014-01-27 22:33:45.334157892 +0100
Jan Kratochvil 2c55a54
@@ -59,8 +59,8 @@ struct lwp_info
c78c51c
   /* If non-zero, a pending wait status.  */
c78c51c
   int status;
c78c51c
 
c78c51c
-  /* Non-zero if we were stepping this LWP.  */
c78c51c
-  int step;
c78c51c
+  /* The kind of stepping of this LWP.  */
c78c51c
+  enum resume_step step;
c78c51c
 
Jan Kratochvil 8aabf36
   /* STOPPED_BY_WATCHPOINT is non-zero if this LWP stopped with a data
Jan Kratochvil 8aabf36
      watchpoint trap.  */