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: 4/9] Make proceed_to_finish per-thread in all-stop, and don't context-switch it


This patch removes the global proceed_to_finish, in favour of accessing
the equivalent member in thread_info.  This variable was per-thread in
non-stop, but global in all-stop.  After the patch, it is always per-thread.

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

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

	* infcall.c (call_function_by_hand): Adjust.
	* infcmd.c (finish_command): Adjust.
	* infrun.c (proceed_to_finish): Delete.
	(clear_proceed_status): Adjust.
	(context_switch): Don't context-switch proceed_to_finish.
	(normal_stop, save_inferior_status, restore_inferior_status):
	Adjust.
---
 gdb/gdbthread.h |    6 ++++--
 gdb/infcall.c   |    3 ++-
 gdb/infcmd.c    |    5 ++++-
 gdb/infrun.c    |   21 ++++++++++-----------
 gdb/thread.c    |    4 ----
 5 files changed, 20 insertions(+), 19 deletions(-)

Index: src/gdb/gdbthread.h
===================================================================
--- src.orig/gdb/gdbthread.h	2008-08-16 03:37:01.000000000 +0100
+++ src/gdb/gdbthread.h	2008-08-16 03:37:04.000000000 +0100
@@ -140,7 +140,11 @@ struct thread_info
   /* Per-thread command support.  */
   struct continuation *continuations;
   struct continuation *intermediate_continuations;
+
+  /* Nonzero if the thread is being proceeded for a "finish" command
+     or a similar situation when stop_registers should be saved.  */
   int proceed_to_finish;
+
   enum step_over_calls_kind step_over_calls;
   int stop_step;
   int step_multi;
@@ -219,7 +223,6 @@ extern int thread_count (void);
 extern void save_infrun_state (ptid_t ptid,
 			       struct continuation *continuations,
 			       struct continuation *intermediate_continuations,
-			       int proceed_to_finish,
 			       int stop_step,
 			       int step_multi,
 			       enum target_signal stop_signal);
@@ -229,7 +232,6 @@ extern void save_infrun_state (ptid_t pt
 extern void load_infrun_state (ptid_t ptid,
 			       struct continuation **continuations,
 			       struct continuation **intermediate_continuations,
-			       int *proceed_to_finish,
 			       int *stop_step,
 			       int *step_multi,
 			       enum target_signal *stop_signal);
Index: src/gdb/thread.c
===================================================================
--- src.orig/gdb/thread.c	2008-08-16 03:37:01.000000000 +0100
+++ src/gdb/thread.c	2008-08-16 03:37:04.000000000 +0100
@@ -445,7 +445,6 @@ void
 load_infrun_state (ptid_t ptid,
 		   struct continuation **continuations,
 		   struct continuation **intermediate_continuations,
-		   int *proceed_to_finish,
 		   int *stop_step,
 		   int *step_multi,
 		   enum target_signal *stop_signal)
@@ -466,7 +465,6 @@ load_infrun_state (ptid_t ptid,
       tp->continuations = NULL;
       *intermediate_continuations = tp->intermediate_continuations;
       tp->intermediate_continuations = NULL;
-      *proceed_to_finish = tp->proceed_to_finish;
       *stop_step = tp->stop_step;
       *step_multi = tp->step_multi;
       *stop_signal = tp->stop_signal;
@@ -479,7 +477,6 @@ void
 save_infrun_state (ptid_t ptid,
 		   struct continuation *continuations,
 		   struct continuation *intermediate_continuations,
-		   int proceed_to_finish,
 		   int stop_step,
 		   int step_multi,
 		   enum target_signal stop_signal)
@@ -498,7 +495,6 @@ save_infrun_state (ptid_t ptid,
     {
       tp->continuations = continuations;
       tp->intermediate_continuations = intermediate_continuations;
-      tp->proceed_to_finish = proceed_to_finish;
       tp->stop_step = stop_step;
       tp->step_multi = step_multi;
       tp->stop_signal = stop_signal;
Index: src/gdb/infcall.c
===================================================================
--- src.orig/gdb/infcall.c	2008-08-16 03:37:01.000000000 +0100
+++ src/gdb/infcall.c	2008-08-16 03:37:04.000000000 +0100
@@ -710,6 +710,7 @@ call_function_by_hand (struct value *fun
     struct cleanup *old_cleanups = make_cleanup (null_cleanup, 0);
     struct cleanup *old_cleanups2;
     int saved_async = 0;
+    struct thread_info *tp = inferior_thread ();
 
     /* If all error()s out of proceed ended up calling normal_stop
        (and perhaps they should; it already does in the special case
@@ -717,7 +718,7 @@ call_function_by_hand (struct value *fun
     make_cleanup (breakpoint_auto_delete_contents, NULL);
 
     disable_watchpoints_before_interactive_call_start ();
-    proceed_to_finish = 1;	/* We want stop_registers, please... */
+    tp->proceed_to_finish = 1;	/* We want stop_registers, please... */
 
     if (target_can_async_p ())
       saved_async = target_async_mask (0);
Index: src/gdb/infcmd.c
===================================================================
--- src.orig/gdb/infcmd.c	2008-08-16 03:37:01.000000000 +0100
+++ src/gdb/infcmd.c	2008-08-16 03:37:04.000000000 +0100
@@ -1405,6 +1405,7 @@ finish_command (char *arg, int from_tty)
   struct breakpoint *breakpoint;
   struct cleanup *old_chain;
   struct finish_command_continuation_args *cargs;
+  struct thread_info *tp;
 
   int async_exec = 0;
 
@@ -1434,6 +1435,8 @@ finish_command (char *arg, int from_tty)
   if (frame == 0)
     error (_("\"finish\" not meaningful in the outermost frame."));
 
+  tp = inferior_thread ();
+
   clear_proceed_status ();
 
   sal = find_pc_line (get_frame_pc (frame), 0);
@@ -1455,7 +1458,7 @@ finish_command (char *arg, int from_tty)
       print_stack_frame (get_selected_frame (NULL), 1, LOCATION);
     }
 
-  proceed_to_finish = 1;	/* We want stop_registers, please...  */
+  tp->proceed_to_finish = 1;	/* We want stop_registers, please...  */
   make_cleanup_restore_integer (&suppress_stop_observer);
   suppress_stop_observer = 1;
   proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
Index: src/gdb/infrun.c
===================================================================
--- src.orig/gdb/infrun.c	2008-08-16 03:37:01.000000000 +0100
+++ src/gdb/infrun.c	2008-08-16 03:37:04.000000000 +0100
@@ -237,11 +237,6 @@ int stop_after_trap;
 
 enum stop_kind stop_soon;
 
-/* Nonzero if proceed is being used for a "finish" command or a similar
-   situation when stop_registers should be saved.  */
-
-int proceed_to_finish;
-
 /* Save register contents here when about to pop a stack dummy frame,
    if-and-only-if proceed_to_finish is set.
    Thus this contains the return value from the called function (assuming
@@ -1101,6 +1096,9 @@ clear_proceed_status (void)
       tp->step_range_end = 0;
       tp->step_frame_id = null_frame_id;
       tp->step_over_calls = STEP_OVER_UNDEBUGGABLE;
+
+      tp->proceed_to_finish = 0;
+
       /* Discard any remaining commands or status from previous
 	 stop.  */
       bpstat_clear (&tp->stop_bpstat);
@@ -1108,7 +1106,6 @@ clear_proceed_status (void)
 
   stop_after_trap = 0;
   stop_soon = NO_STOP_QUIETLY;
-  proceed_to_finish = 0;
   breakpoint_proceeded = 1;	/* We're about to proceed... */
 
   if (stop_registers)
@@ -1703,7 +1700,6 @@ context_switch (ptid_t ptid)
       /* Save infrun state for the old thread.  */
       save_infrun_state (inferior_ptid,
 			 cmd_continuation, intermediate_continuation,
-			 proceed_to_finish,
 			 stop_step,
 			 step_multi,
 			 stop_signal);
@@ -1711,7 +1707,6 @@ context_switch (ptid_t ptid)
       /* Load infrun state for the new thread.  */
       load_infrun_state (ptid,
 			 &cmd_continuation, &intermediate_continuation,
-			 &proceed_to_finish,
 			 &stop_step,
 			 &step_multi,
 			 &stop_signal);
@@ -3821,6 +3816,10 @@ Further execution is probably impossible
       goto done;
     }
 
+  if (last.kind == TARGET_WAITKIND_SIGNALLED
+      || last.kind == TARGET_WAITKIND_EXITED)
+    goto done;
+
   /* Select innermost stack frame - i.e., current frame is frame 0,
      and current location is based on that.
      Don't do this on return from a stack dummy routine,
@@ -3918,7 +3917,7 @@ Further execution is probably impossible
 
   /* Save the function value return registers, if we care.
      We might be about to restore their previous contents.  */
-  if (proceed_to_finish)
+  if (inferior_thread ()->proceed_to_finish)
     {
       /* This should not be necessary.  */
       if (stop_registers)
@@ -4401,7 +4400,7 @@ save_inferior_status (int restore_stack_
   tp->stop_bpstat = bpstat_copy (tp->stop_bpstat);
   inf_status->breakpoint_proceeded = breakpoint_proceeded;
   inf_status->restore_stack_info = restore_stack_info;
-  inf_status->proceed_to_finish = proceed_to_finish;
+  inf_status->proceed_to_finish = tp->proceed_to_finish;
 
   inf_status->registers = regcache_dup (get_current_regcache ());
 
@@ -4450,7 +4449,7 @@ restore_inferior_status (struct inferior
   bpstat_clear (&tp->stop_bpstat);
   tp->stop_bpstat = inf_status->stop_bpstat;
   breakpoint_proceeded = inf_status->breakpoint_proceeded;
-  proceed_to_finish = inf_status->proceed_to_finish;
+  tp->proceed_to_finish = inf_status->proceed_to_finish;
 
   /* The inferior can be gone if the user types "print exit(0)"
      (and perhaps other times).  */

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