This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC: 7/9] Make stop_step per-thread in all-stop, and don't context-switch it


This patch removes the global stop_step, in favour of accessing 
the equivalent member in thread_info.  This property was already
per-thread in non-stop mode, and after the patch, it is per-thread
in all-stop too.

Same consideration as previous patch related to async mode.

Also, note that when we get to normal_stop, which is a user of this
variable, inferior_thread is equal to the last ecs->event_thread
(if this was a thread stop event).

-- 
Pedro Alves
2008-08-16  Pedro Alves  <pedro@codesourcery.com>

	Remove the global stop_step in favour of a per-thread
	stop_step.

	* inferior.h (stop_step): Delete.

	* gdbthread.h (struct thread_info): Add comments to stop_step.
	(save_infrun_state, load_infrun_state): Remove stop_step argument.
	* thread.c (load_infrun_state, save_infrun_state): Remove
	stop_step argument, and references to it.

	* infrun.c (clear_proceed_status): Clear stop_step.
	(fetch_inferior_event): Adjust.
	(context_switch): Don't context-switch stop_step.
	(handle_inferior_event): Adjust.
	(normal_stop): Adjust.
	(save_inferior_status, restore_inferior_status): Adjust.

	* infcmd.c (stop_step): Delete.
	(step_1, step_1_continuation, step_once, until_next_command):
	Adjust.

---
 gdb/gdbthread.h |    8 ++++----
 gdb/infcmd.c    |   11 ++++-------
 gdb/inferior.h  |    4 ----
 gdb/infrun.c    |   39 ++++++++++++++++++++-------------------
 gdb/thread.c    |    8 ++------
 5 files changed, 30 insertions(+), 40 deletions(-)

Index: src/gdb/inferior.h
===================================================================
--- src.orig/gdb/inferior.h	2008-08-16 16:17:09.000000000 +0100
+++ src/gdb/inferior.h	2008-08-16 16:17:13.000000000 +0100
@@ -288,10 +288,6 @@ extern CORE_ADDR stop_pc;
 
 extern int breakpoint_proceeded;
 
-/* Nonzero if stopped due to a step command.  */
-
-extern int stop_step;
-
 /* Nonzero if stopped due to completion of a stack dummy routine.  */
 
 extern int stop_stack_dummy;
Index: src/gdb/gdbthread.h
===================================================================
--- src.orig/gdb/gdbthread.h	2008-08-16 16:17:09.000000000 +0100
+++ src/gdb/gdbthread.h	2008-08-16 16:17:13.000000000 +0100
@@ -146,6 +146,8 @@ struct thread_info
   int proceed_to_finish;
 
   enum step_over_calls_kind step_over_calls;
+
+  /* Nonzero if stopped due to a step command.  */
   int stop_step;
 
   /* If stepping, nonzero means step count is > 1 so don't print frame
@@ -226,15 +228,13 @@ extern int thread_count (void);
 /* infrun context switch: save the debugger state for the given thread.  */
 extern void save_infrun_state (ptid_t ptid,
 			       struct continuation *continuations,
-			       struct continuation *intermediate_continuations,
-			       int stop_step);
+			       struct continuation *intermediate_continuations);
 
 /* infrun context switch: load the debugger state previously saved
    for the given thread.  */
 extern void load_infrun_state (ptid_t ptid,
 			       struct continuation **continuations,
-			       struct continuation **intermediate_continuations,
-			       int *stop_step);
+			       struct continuation **intermediate_continuations);
 
 /* Switch from one thread to another.  */
 extern void switch_to_thread (ptid_t ptid);
Index: src/gdb/thread.c
===================================================================
--- src.orig/gdb/thread.c	2008-08-16 16:17:09.000000000 +0100
+++ src/gdb/thread.c	2008-08-16 16:17:13.000000000 +0100
@@ -444,8 +444,7 @@ gdb_list_thread_ids (struct ui_out *uiou
 void
 load_infrun_state (ptid_t ptid,
 		   struct continuation **continuations,
-		   struct continuation **intermediate_continuations,
-		   int *stop_step)
+		   struct continuation **intermediate_continuations)
 {
   struct thread_info *tp;
 
@@ -463,7 +462,6 @@ load_infrun_state (ptid_t ptid,
       tp->continuations = NULL;
       *intermediate_continuations = tp->intermediate_continuations;
       tp->intermediate_continuations = NULL;
-      *stop_step = tp->stop_step;
     }
 }
 
@@ -472,8 +470,7 @@ load_infrun_state (ptid_t ptid,
 void
 save_infrun_state (ptid_t ptid,
 		   struct continuation *continuations,
-		   struct continuation *intermediate_continuations,
-		   int stop_step)
+		   struct continuation *intermediate_continuations)
 {
   struct thread_info *tp;
 
@@ -489,7 +486,6 @@ save_infrun_state (ptid_t ptid,
     {
       tp->continuations = continuations;
       tp->intermediate_continuations = intermediate_continuations;
-      tp->stop_step = stop_step;
     }
 }
 
Index: src/gdb/infrun.c
===================================================================
--- src.orig/gdb/infrun.c	2008-08-16 16:17:09.000000000 +0100
+++ src/gdb/infrun.c	2008-08-16 16:17:13.000000000 +0100
@@ -1101,6 +1101,8 @@ clear_proceed_status (void)
       tp->step_frame_id = null_frame_id;
       tp->step_over_calls = STEP_OVER_UNDEBUGGABLE;
 
+      tp->stop_step = 0;
+
       tp->proceed_to_finish = 0;
 
       /* Discard any remaining commands or status from previous
@@ -1645,7 +1647,7 @@ fetch_inferior_event (void *client_data)
 	  && ecs->ws.kind != TARGET_WAITKIND_EXITED
 	  && ecs->ws.kind != TARGET_WAITKIND_SIGNALLED
 	  && ecs->event_thread->step_multi
-	  && stop_step)
+	  && ecs->event_thread->stop_step)
 	inferior_event_handler (INF_EXEC_CONTINUE, NULL);
       else
 	inferior_event_handler (INF_EXEC_COMPLETE, NULL);
@@ -1727,13 +1729,11 @@ context_switch (ptid_t ptid)
     {				/* Perform infrun state context switch: */
       /* Save infrun state for the old thread.  */
       save_infrun_state (inferior_ptid,
-			 cmd_continuation, intermediate_continuation,
-			 stop_step);
+			 cmd_continuation, intermediate_continuation);
 
       /* Load infrun state for the new thread.  */
       load_infrun_state (ptid,
-			 &cmd_continuation, &intermediate_continuation,
-			 &stop_step);
+			 &cmd_continuation, &intermediate_continuation);
     }
 
   switch_to_thread (ptid);
@@ -2503,7 +2503,7 @@ targets should add new threads to the th
     += gdbarch_deprecated_function_start_offset (current_gdbarch);
   ecs->event_thread->stepping_over_breakpoint = 0;
   bpstat_clear (&ecs->event_thread->stop_bpstat);
-  stop_step = 0;
+  ecs->event_thread->stop_step = 0;
   stop_print_frame = 1;
   ecs->random_signal = 0;
   stopped_by_random_signal = 0;
@@ -2813,7 +2813,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (
 	gdb_assert (ecs->event_thread->step_resume_breakpoint != NULL);
 	delete_step_resume_breakpoint (ecs->event_thread);
 
-	stop_step = 1;
+	ecs->event_thread->stop_step = 1;
 	print_stop_reason (END_STEPPING_RANGE, 0);
 	stop_stepping (ecs);
 	return;
@@ -3110,7 +3110,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (
 	  /* Also, maybe we just did a "nexti" inside a prolog, so we
 	     thought it was a subroutine call but it was not.  Stop as
 	     well.  FENN */
-	  stop_step = 1;
+	  ecs->event_thread->stop_step = 1;
 	  print_stop_reason (END_STEPPING_RANGE, 0);
 	  stop_stepping (ecs);
 	  return;
@@ -3172,7 +3172,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (
       if (ecs->event_thread->step_over_calls == STEP_OVER_UNDEBUGGABLE
 	  && step_stop_if_no_debug)
 	{
-	  stop_step = 1;
+	  ecs->event_thread->stop_step = 1;
 	  print_stop_reason (END_STEPPING_RANGE, 0);
 	  stop_stepping (ecs);
 	  return;
@@ -3246,7 +3246,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (
 	  /* If we have no line number and the step-stop-if-no-debug
 	     is set, we stop the step so that the user has a chance to
 	     switch in assembly mode.  */
-	  stop_step = 1;
+	  ecs->event_thread->stop_step = 1;
 	  print_stop_reason (END_STEPPING_RANGE, 0);
 	  stop_stepping (ecs);
 	  return;
@@ -3267,7 +3267,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (
          one instruction.  */
       if (debug_infrun)
 	 fprintf_unfiltered (gdb_stdlog, "infrun: stepi/nexti\n");
-      stop_step = 1;
+      ecs->event_thread->stop_step = 1;
       print_stop_reason (END_STEPPING_RANGE, 0);
       stop_stepping (ecs);
       return;
@@ -3281,7 +3281,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (
          or can this happen as a result of a return or longjmp?).  */
       if (debug_infrun)
 	 fprintf_unfiltered (gdb_stdlog, "infrun: no line number info\n");
-      stop_step = 1;
+      ecs->event_thread->stop_step = 1;
       print_stop_reason (END_STEPPING_RANGE, 0);
       stop_stepping (ecs);
       return;
@@ -3297,7 +3297,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (
          better.  */
       if (debug_infrun)
 	 fprintf_unfiltered (gdb_stdlog, "infrun: stepped to a different line\n");
-      stop_step = 1;
+      ecs->event_thread->stop_step = 1;
       print_stop_reason (END_STEPPING_RANGE, 0);
       stop_stepping (ecs);
       return;
@@ -3411,7 +3411,7 @@ step_into_function (struct execution_con
   if (ecs->stop_func_start == stop_pc)
     {
       /* We are already there: stop now.  */
-      stop_step = 1;
+      ecs->event_thread->stop_step = 1;
       print_stop_reason (END_STEPPING_RANGE, 0);
       stop_stepping (ecs);
       return;
@@ -3671,7 +3671,8 @@ print_stop_reason (enum inferior_stop_re
       /* For now print nothing. */
       /* Print a message only if not in the middle of doing a "step n"
          operation for n > 1 */
-      if (!inferior_thread ()->step_multi || !stop_step)
+      if (!inferior_thread ()->step_multi
+	  || !inferior_thread ()->stop_step)
 	if (ui_out_is_mi_like_p (uiout))
 	  ui_out_field_string
 	    (uiout, "reason",
@@ -3824,7 +3825,7 @@ Further execution is probably impossible
       && last.kind != TARGET_WAITKIND_SIGNALLED
       && last.kind != TARGET_WAITKIND_EXITED
       && inferior_thread ()->step_multi
-      && stop_step)
+      && inferior_thread ()->stop_step)
     goto done;
 
   target_terminal_ours ();
@@ -3895,7 +3896,7 @@ Further execution is probably impossible
 	      /* FIXME: cagney/2002-12-01: Given that a frame ID does
 	         (or should) carry around the function and does (or
 	         should) use that when doing a frame comparison.  */
-	      if (stop_step
+	      if (tp->stop_step
 		  && frame_id_eq (tp->step_frame_id,
 				  get_frame_id (get_current_frame ()))
 		  && step_start_function == find_pc_function (stop_pc))
@@ -4417,7 +4418,7 @@ save_inferior_status (int restore_stack_
 
   inf_status->stop_signal = tp->stop_signal;
   inf_status->stop_pc = stop_pc;
-  inf_status->stop_step = stop_step;
+  inf_status->stop_step = tp->stop_step;
   inf_status->stop_stack_dummy = stop_stack_dummy;
   inf_status->stopped_by_random_signal = stopped_by_random_signal;
   inf_status->stepping_over_breakpoint = tp->trap_expected;
@@ -4471,7 +4472,7 @@ restore_inferior_status (struct inferior
 
   tp->stop_signal = inf_status->stop_signal;
   stop_pc = inf_status->stop_pc;
-  stop_step = inf_status->stop_step;
+  tp->stop_step = inf_status->stop_step;
   stop_stack_dummy = inf_status->stop_stack_dummy;
   stopped_by_random_signal = inf_status->stopped_by_random_signal;
   tp->trap_expected = inf_status->stepping_over_breakpoint;
Index: src/gdb/infcmd.c
===================================================================
--- src.orig/gdb/infcmd.c	2008-08-16 16:17:09.000000000 +0100
+++ src/gdb/infcmd.c	2008-08-16 16:17:13.000000000 +0100
@@ -156,10 +156,6 @@ CORE_ADDR stop_pc;
 
 int breakpoint_proceeded;
 
-/* Nonzero if stopped due to a step command.  */
-
-int stop_step;
-
 /* Nonzero if stopped due to completion of a stack dummy routine.  */
 
 int stop_stack_dummy;
@@ -849,7 +845,8 @@ which has no line number information.\n"
 	  tp->step_multi = (count > 1);
 	  proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
 
-	  if (!stop_step)
+	  if (!target_has_execution
+	      || !inferior_thread ()->stop_step)
 	    break;
 	}
 
@@ -892,7 +889,7 @@ step_1_continuation (void *args)
       struct thread_info *tp;
 
       tp = inferior_thread ();
-      if (tp->step_multi && stop_step)
+      if (tp->step_multi && tp->stop_step)
 	{
 	  /* There are more steps to make, and we did stop due to
 	     ending a stepping range.  Do another step.  */
@@ -1509,7 +1506,7 @@ program_info (char *args, int from_tty)
   target_files_info ();
   printf_filtered (_("Program stopped at %s.\n"),
 		   hex_string ((unsigned long) stop_pc));
-  if (stop_step)
+  if (tp->stop_step)
     printf_filtered (_("It stopped after being stepped.\n"));
   else if (stat != 0)
     {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]