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


This patch removes the global stop_bpstat, in favour of accessing
the equivalent member in thread_info.  stop_bpstat is currently
per-thread in non-stop, and global in all-stop.  This patches makes
it per-thread in all-stop too.

Noteworty:

 - bpstat_do_actions had an implicit assumption that its
   caller passed the address of the global stop_bpstat.
   There's an internal goto loop inside it, that loops
   whenever a breakpoint had an attached command that
   proceeded the inferior.

   Since we're making stop_bpstat a per-thread property, the
   assumption above breaks.  Instead, I've renamed bpstat_do_actions
   to bpstat_do_actions_1, and made a new function bpstat_do_actions
   that calls the old one in a loop, passing the stop_bpstat of the
   current thread.

 - Given that stop_bpstat was global in all-stop, continuing with an
   ignore count in all-stop sets the ignore count on any breakpoint
   the inferior last stopped at, independently of the user switching
   threads.  That is, the below sets the ignore count on breakpoint 1

   <stop in thread 2, breakpoint 1>
   thread 3
   continue 10

   I'm preserving that behaviour.

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

	* inferior.h (stop_bpstat): Delete.

	* breakpoint.h (bpstat_do_actions): Remove bpstat* argument.
	* breakpoint.c (bpstat_do_actions): Rename to ...
	(bpstat_do_actions_1): ... this.  Change return type to int.
	Return true if a breakpoint proceeded.
	(bpstat_do_actions): New, as wrapper around bpstat_do_actions_1.
	(delete_breakpoint): Don't reference the global stop_bpstat; it's
	gone.

	* gdbthread.h (struct thread_info): Add stop_bpstat.
	(save_infrun_state, load_infrun_state): Remove stop_bpstat
	argument.
	* thread.c (load_infrun_state, save_infrun_state): Remove
	stop_bpstat argument, and the code referencing it.

	* infcall.c: Include "gdbthread.h".
	(call_function_by_hand): Adjust.
	* exceptions.c: Include "gdbthread.h".
	(throw_exception): Adjust.
	* infcmd.c (stop_bpstat): Delete.
	(continue_command): In all-stop, set the ignore count on the
	thread that reported the stop.  In non-stop, set it on the current
	thread.
	(finish_command_continuation): Adjust.
	(program_info): Adjust.
	* infrun.c (clear_proceed_status): Adjust.
	(context_switch): Don't context-switch stop_bpstat.
	(handle_inferior_event): Adjust.
	(normal_stop): Adjust.
	(save_inferior_status, restore_inferior_status): Adjust.

	* inf-loop.c (inferior_event_handler): Remove parameter to
	bpstat_do_actions call.
	* top.c (command_loop): Remove parameter to bpstat_do_actions
	call.  Call it unconditionally.
	* event-top.c (command_handler): Ditto.
	* python.c (execute_gdb_command): Ditto.

---
 gdb/breakpoint.c    |   77 +++++++++++++++++++++++++++++-----------------------
 gdb/breakpoint.h    |    9 +++---
 gdb/event-top.c     |   44 ++++++++++++-----------------
 gdb/exceptions.c    |    9 +++++-
 gdb/gdbthread.h     |   11 +++----
 gdb/inf-loop.c      |    2 -
 gdb/infcall.c       |    8 +++--
 gdb/infcmd.c        |   55 ++++++++++++++++++++++++++++++-------
 gdb/inferior.h      |    4 --
 gdb/infrun.c        |   65 +++++++++++++++++++++++--------------------
 gdb/python/python.c |   13 +-------
 gdb/thread.c        |   12 +-------
 gdb/top.c           |    6 ++--
 13 files changed, 173 insertions(+), 142 deletions(-)

Index: src/gdb/inferior.h
===================================================================
--- src.orig/gdb/inferior.h	2008-08-16 03:36:58.000000000 +0100
+++ src/gdb/inferior.h	2008-08-16 03:37:01.000000000 +0100
@@ -287,10 +287,6 @@ extern enum target_signal stop_signal;
 
 extern CORE_ADDR stop_pc;
 
-/* Chain containing status of breakpoint(s) that we have stopped at.  */
-
-extern bpstat stop_bpstat;
-
 /* Flag indicating that a command has proceeded the inferior past the
    current breakpoint.  */
 
Index: src/gdb/breakpoint.h
===================================================================
--- src.orig/gdb/breakpoint.h	2008-08-16 03:31:04.000000000 +0100
+++ src/gdb/breakpoint.h	2008-08-16 03:37:01.000000000 +0100
@@ -604,10 +604,11 @@ extern enum print_stop_action bpstat_pri
    Return 1 otherwise.  */
 extern int bpstat_num (bpstat *, int *);
 
-/* Perform actions associated with having stopped at *BSP.  Actually, we just
-   use this for breakpoint commands.  Perhaps other actions will go here
-   later, but this is executed at a late time (from the command loop).  */
-extern void bpstat_do_actions (bpstat *);
+/* Perform actions associated with the stopped inferior.  Actually, we
+   just use this for breakpoint commands.  Perhaps other actions will
+   go here later, but this is executed at a late time (from the
+   command loop).  */
+extern void bpstat_do_actions (void);
 
 /* Modify BS so that the actions will not be performed.  */
 extern void bpstat_clear_actions (bpstat);
Index: src/gdb/breakpoint.c
===================================================================
--- src.orig/gdb/breakpoint.c	2008-08-16 03:31:03.000000000 +0100
+++ src/gdb/breakpoint.c	2008-08-16 03:37:01.000000000 +0100
@@ -2130,31 +2130,27 @@ cleanup_executing_breakpoints (void *ign
 /* Execute all the commands associated with all the breakpoints at this
    location.  Any of these commands could cause the process to proceed
    beyond this point, etc.  We look out for such changes by checking
-   the global "breakpoint_proceeded" after each command.  */
+   the global "breakpoint_proceeded" after each command.
 
-void
-bpstat_do_actions (bpstat *bsp)
+   Returns true if a breakpoint command resumed the inferior.  In that
+   case, it is the caller's responsability to recall it again with the
+   bpstat of the current thread.  */
+
+static int
+bpstat_do_actions_1 (bpstat *bsp)
 {
   bpstat bs;
   struct cleanup *old_chain;
+  int again = 0;
 
   /* Avoid endless recursion if a `source' command is contained
      in bs->commands.  */
   if (executing_breakpoint_commands)
-    return;
+    return 0;
 
   executing_breakpoint_commands = 1;
   old_chain = make_cleanup (cleanup_executing_breakpoints, 0);
 
-top:
-  /* Note that (as of this writing), our callers all appear to
-     be passing us the address of global stop_bpstat.  And, if
-     our calls to execute_control_command cause the inferior to
-     proceed, that global (and hence, *bsp) will change.
-
-     We must be careful to not touch *bsp unless the inferior
-     has not proceeded. */
-
   /* This pointer will iterate over the list of bpstat's. */
   bs = *bsp;
 
@@ -2194,30 +2190,46 @@ top:
       if (breakpoint_proceeded)
 	{
 	  if (target_can_async_p ())
-	  /* If we are in async mode, then the target might
-	     be still running, not stopped at any breakpoint,
-	     so nothing for us to do here -- just return to
-	     the event loop.  */
-	    break;
+	    /* If we are in async mode, then the target might be still
+	       running, not stopped at any breakpoint, so nothing for
+	       us to do here -- just return to the event loop.  */
+	    ;
 	  else
 	    /* In sync mode, when execute_control_command returns
 	       we're already standing on the next breakpoint.
-	       Breakpoint commands for that stop were not run,
-	       since execute_command does not run breakpoint
-	       commands -- only command_line_handler does, but
-	       that one is not involved in execution of breakpoint
-	       commands.  So, we can now execute breakpoint commands.
-	       There's an implicit assumption that we're called with
-	       stop_bpstat, so our parameter is the new bpstat to
-	       handle.  
-	       It should be noted that making execute_command do
-	       bpstat actions is not an option -- in this case we'll
-	       have recursive invocation of bpstat for each breakpoint
-	       with a command, and can easily blow up GDB stack.  */
-	    goto top;
+	       Breakpoint commands for that stop were not run, since
+	       execute_command does not run breakpoint commands --
+	       only command_line_handler does, but that one is not
+	       involved in execution of breakpoint commands.  So, we
+	       can now execute breakpoint commands.  It should be
+	       noted that making execute_command do bpstat actions is
+	       not an option -- in this case we'll have recursive
+	       invocation of bpstat for each breakpoint with a
+	       command, and can easily blow up GDB stack.  Instead, we
+	       return true, which will trigger the caller to recall us
+	       with the new stop_bpstat.  */
+	    again = 1;
+	  break;
 	}
     }
   do_cleanups (old_chain);
+  return again;
+}
+
+void
+bpstat_do_actions (void)
+{
+  /* Do any commands attached to breakpoint we are stopped at.  */
+  while (!ptid_equal (inferior_ptid, null_ptid)
+	 && target_has_execution
+	 && !is_exited (inferior_ptid)
+	 && !is_executing (inferior_ptid))
+    /* Since in sync mode, bpstat_do_actions may resume the inferior,
+       and only return when it is stopped at the next breakpoint, we
+       keep doing breakpoint actions until it returns false to
+       indicate the inferior was not resumed.  */
+    if (!bpstat_do_actions_1 (&inferior_thread ()->stop_bpstat))
+      break;
 }
 
 /* Print out the (old or new) value associated with a watchpoint.  */
@@ -7272,9 +7284,6 @@ delete_breakpoint (struct breakpoint *bp
      in event-top.c won't do anything, and temporary breakpoints
      with commands won't work.  */
 
-  /* Clear the current context.  */
-  bpstat_remove_breakpoint (stop_bpstat, bpt);
-  /* And from all threads.  */
   iterate_over_threads (bpstat_remove_breakpoint_callback, bpt);
 
   /* Now that breakpoint is removed from breakpoint
Index: src/gdb/gdbthread.h
===================================================================
--- src.orig/gdb/gdbthread.h	2008-08-16 03:36:58.000000000 +0100
+++ src/gdb/gdbthread.h	2008-08-16 03:37:01.000000000 +0100
@@ -146,8 +146,9 @@ struct thread_info
   int step_multi;
 
   enum target_signal stop_signal;
-  /* Used in continue_command to set the proceed count of the
-     breakpoint the thread stopped at.  */
+
+  /* Chain containing status of breakpoint(s) the thread stopped
+     at.  */
   bpstat stop_bpstat;
 
   /* Private data used by the target vector implementation.  */
@@ -221,8 +222,7 @@ extern void save_infrun_state (ptid_t pt
 			       int proceed_to_finish,
 			       int stop_step,
 			       int step_multi,
-			       enum target_signal stop_signal,
-			       bpstat stop_bpstat);
+			       enum target_signal stop_signal);
 
 /* infrun context switch: load the debugger state previously saved
    for the given thread.  */
@@ -232,8 +232,7 @@ extern void load_infrun_state (ptid_t pt
 			       int *proceed_to_finish,
 			       int *stop_step,
 			       int *step_multi,
-			       enum target_signal *stop_signal,
-			       bpstat *stop_bpstat);
+			       enum target_signal *stop_signal);
 
 /* 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 03:36:58.000000000 +0100
+++ src/gdb/thread.c	2008-08-16 03:37:01.000000000 +0100
@@ -448,8 +448,7 @@ load_infrun_state (ptid_t ptid,
 		   int *proceed_to_finish,
 		   int *stop_step,
 		   int *step_multi,
-		   enum target_signal *stop_signal,
-		   bpstat *stop_bpstat)
+		   enum target_signal *stop_signal)
 {
   struct thread_info *tp;
 
@@ -471,11 +470,6 @@ load_infrun_state (ptid_t ptid,
       *stop_step = tp->stop_step;
       *step_multi = tp->step_multi;
       *stop_signal = tp->stop_signal;
-
-      /* Swap instead of copy, so we only have to update one of
-	 them.  */
-      *stop_bpstat = tp->stop_bpstat;
-      tp->stop_bpstat = 0;
     }
 }
 
@@ -488,8 +482,7 @@ save_infrun_state (ptid_t ptid,
 		   int proceed_to_finish,
 		   int stop_step,
 		   int step_multi,
-		   enum target_signal stop_signal,
-		   bpstat stop_bpstat)
+		   enum target_signal stop_signal)
 {
   struct thread_info *tp;
 
@@ -509,7 +502,6 @@ save_infrun_state (ptid_t ptid,
       tp->stop_step = stop_step;
       tp->step_multi = step_multi;
       tp->stop_signal = stop_signal;
-      tp->stop_bpstat = stop_bpstat;
     }
 }
 
Index: src/gdb/infcall.c
===================================================================
--- src.orig/gdb/infcall.c	2008-08-16 03:31:03.000000000 +0100
+++ src/gdb/infcall.c	2008-08-16 03:37:01.000000000 +0100
@@ -35,6 +35,7 @@
 #include "infcall.h"
 #include "dummy-frame.h"
 #include "ada-lang.h"
+#include "gdbthread.h"
 
 /* NOTE: cagney/2003-04-16: What's the future of this code?
 
@@ -263,12 +264,13 @@ find_function_addr (struct value *functi
 }
 
 /* Call breakpoint_auto_delete on the current contents of the bpstat
-   pointed to by arg (which is really a bpstat *).  */
+   of the current thread.  */
 
 static void
 breakpoint_auto_delete_contents (void *arg)
 {
-  breakpoint_auto_delete (*(bpstat *) arg);
+  if (!ptid_equal (inferior_ptid, null_ptid))
+    breakpoint_auto_delete (inferior_thread ()->stop_bpstat);
 }
 
 static CORE_ADDR
@@ -712,7 +714,7 @@ call_function_by_hand (struct value *fun
     /* If all error()s out of proceed ended up calling normal_stop
        (and perhaps they should; it already does in the special case
        of error out of resume()), then we wouldn't need this.  */
-    make_cleanup (breakpoint_auto_delete_contents, &stop_bpstat);
+    make_cleanup (breakpoint_auto_delete_contents, NULL);
 
     disable_watchpoints_before_interactive_call_start ();
     proceed_to_finish = 1;	/* We want stop_registers, please... */
Index: src/gdb/exceptions.c
===================================================================
--- src.orig/gdb/exceptions.c	2008-08-16 03:31:03.000000000 +0100
+++ src/gdb/exceptions.c	2008-08-16 03:37:01.000000000 +0100
@@ -29,6 +29,7 @@
 #include "gdb_assert.h"
 #include "gdb_string.h"
 #include "serial.h"
+#include "gdbthread.h"
 
 const struct gdb_exception exception_none = { 0, GDB_NO_ERROR, NULL };
 
@@ -212,12 +213,18 @@ exceptions_state_mc_action_iter_1 (void)
 NORETURN void
 throw_exception (struct gdb_exception exception)
 {
+  struct thread_info *tp = NULL;
+
   quit_flag = 0;
   immediate_quit = 0;
 
+  if (!ptid_equal (inferior_ptid, null_ptid))
+    tp = find_thread_pid (inferior_ptid);
+
   /* Perhaps it would be cleaner to do this via the cleanup chain (not sure
      I can think of a reason why that is vital, though).  */
-  bpstat_clear_actions (stop_bpstat);	/* Clear queued breakpoint commands */
+  if (tp != NULL)
+    bpstat_clear_actions (tp->stop_bpstat);	/* Clear queued breakpoint commands */
 
   disable_current_display ();
   do_cleanups (ALL_CLEANUPS);
Index: src/gdb/infcmd.c
===================================================================
--- src.orig/gdb/infcmd.c	2008-08-16 03:36:58.000000000 +0100
+++ src/gdb/infcmd.c	2008-08-16 03:37:01.000000000 +0100
@@ -155,10 +155,6 @@ enum target_signal stop_signal;
 
 CORE_ADDR stop_pc;
 
-/* Chain containing status of breakpoint(s) that we have stopped at.  */
-
-bpstat stop_bpstat;
-
 /* Flag indicating that a command has proceeded the inferior past the
    current breakpoint.  */
 
@@ -696,9 +692,23 @@ Can't resume all threads and specify pro
      stopped at.  */
   if (args != NULL)
     {
-      bpstat bs = stop_bpstat;
+      bpstat bs = NULL;
       int num, stat;
       int stopped = 0;
+      struct thread_info *tp;
+
+      if (non_stop)
+	tp = find_thread_pid (inferior_ptid);
+      else
+	{
+	  ptid_t last_ptid;
+	  struct target_waitstatus ws;
+
+	  get_last_target_status (&last_ptid, &ws);
+	  tp = find_thread_pid (last_ptid);
+	}
+      if (tp != NULL)
+	bs = tp->stop_bpstat;
 
       while ((stat = bpstat_num (&bs, &num)) != 0)
 	if (stat > 0)
@@ -1342,7 +1352,14 @@ finish_command_continuation (void *arg)
 {
   struct finish_command_continuation_args *a = arg;
 
-  if (bpstat_find_breakpoint (stop_bpstat, a->breakpoint) != NULL
+  bpstat bs = NULL;
+
+  if (!ptid_equal (inferior_ptid, null_ptid)
+      && target_has_execution
+      && is_stopped (inferior_ptid))
+    bs = inferior_thread ()->stop_bpstat;
+
+  if (bpstat_find_breakpoint (bs, a->breakpoint) != NULL
       && a->function != NULL)
     {
       struct type *value_type;
@@ -1362,7 +1379,7 @@ finish_command_continuation (void *arg)
      next stop will be in the same thread that we started doing a
      finish on.  This suppressing (or some other replacement means)
      should be a thread property.  */
-  observer_notify_normal_stop (stop_bpstat);
+  observer_notify_normal_stop (bs);
   suppress_stop_observer = 0;
   delete_breakpoint (a->breakpoint);
 }
@@ -1459,9 +1476,10 @@ finish_command (char *arg, int from_tty)
 static void
 program_info (char *args, int from_tty)
 {
-  bpstat bs = stop_bpstat;
-  int num;
-  int stat = bpstat_num (&bs, &num);
+  bpstat bs;
+  int num, stat;
+  struct thread_info *tp;
+  ptid_t ptid;
 
   if (!target_has_execution)
     {
@@ -1469,6 +1487,23 @@ program_info (char *args, int from_tty)
       return;
     }
 
+  if (non_stop)
+    ptid = inferior_ptid;
+  else
+    {
+      struct target_waitstatus ws;
+      get_last_target_status (&ptid, &ws);
+    }
+
+  if (ptid_equal (ptid, null_ptid) || is_exited (ptid))
+    error (_("Invalid selected thread."));
+  else if (is_running (ptid))
+    error (_("Selected thread is running."));
+
+  tp = find_thread_pid (ptid);
+  bs = tp->stop_bpstat;
+  stat = bpstat_num (&bs, &num);
+
   target_files_info ();
   printf_filtered (_("Program stopped at %s.\n"),
 		   hex_string ((unsigned long) stop_pc));
Index: src/gdb/infrun.c
===================================================================
--- src.orig/gdb/infrun.c	2008-08-16 03:36:58.000000000 +0100
+++ src/gdb/infrun.c	2008-08-16 03:37:01.000000000 +0100
@@ -1101,6 +1101,9 @@ clear_proceed_status (void)
       tp->step_range_end = 0;
       tp->step_frame_id = null_frame_id;
       tp->step_over_calls = STEP_OVER_UNDEBUGGABLE;
+      /* Discard any remaining commands or status from previous
+	 stop.  */
+      bpstat_clear (&tp->stop_bpstat);
     }
 
   stop_after_trap = 0;
@@ -1113,9 +1116,6 @@ clear_proceed_status (void)
       regcache_xfree (stop_registers);
       stop_registers = NULL;
     }
-
-  /* Discard any remaining commands or status from previous stop.  */
-  bpstat_clear (&stop_bpstat);
 }
 
 /* This should be suitable for any targets that support threads. */
@@ -1706,8 +1706,7 @@ context_switch (ptid_t ptid)
 			 proceed_to_finish,
 			 stop_step,
 			 step_multi,
-			 stop_signal,
-			 stop_bpstat);
+			 stop_signal);
 
       /* Load infrun state for the new thread.  */
       load_infrun_state (ptid,
@@ -1715,8 +1714,7 @@ context_switch (ptid_t ptid)
 			 &proceed_to_finish,
 			 &stop_step,
 			 &step_multi,
-			 &stop_signal,
-			 &stop_bpstat);
+			 &stop_signal);
     }
 
   switch_to_thread (ptid);
@@ -2052,9 +2050,9 @@ handle_inferior_event (struct execution_
 
       stop_pc = read_pc ();
 
-      stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
+      ecs->event_thread->stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
 
-      ecs->random_signal = !bpstat_explains_signal (stop_bpstat);
+      ecs->random_signal = !bpstat_explains_signal (ecs->event_thread->stop_bpstat);
 
       /* If no catchpoint triggered for this, then keep going.  */
       if (ecs->random_signal)
@@ -2088,9 +2086,9 @@ handle_inferior_event (struct execution_
 	ptid_t saved_inferior_ptid = inferior_ptid;
 	inferior_ptid = ecs->ptid;
 
-	stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
+	ecs->event_thread->stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
 
-	ecs->random_signal = !bpstat_explains_signal (stop_bpstat);
+	ecs->random_signal = !bpstat_explains_signal (ecs->event_thread->stop_bpstat);
 	inferior_ptid = saved_inferior_ptid;
       }
 
@@ -2486,7 +2484,7 @@ targets should add new threads to the th
   ecs->stop_func_start
     += gdbarch_deprecated_function_start_offset (current_gdbarch);
   ecs->event_thread->stepping_over_breakpoint = 0;
-  bpstat_clear (&stop_bpstat);
+  bpstat_clear (&ecs->event_thread->stop_bpstat);
   stop_step = 0;
   stop_print_frame = 1;
   ecs->random_signal = 0;
@@ -2599,7 +2597,7 @@ targets should add new threads to the th
 	}
 
       /* See if there is a breakpoint at the current PC.  */
-      stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
+      ecs->event_thread->stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
       
       /* Following in case break condition called a
 	 function.  */
@@ -2627,13 +2625,13 @@ targets should add new threads to the th
 
       if (stop_signal == TARGET_SIGNAL_TRAP)
 	ecs->random_signal
-	  = !(bpstat_explains_signal (stop_bpstat)
+	  = !(bpstat_explains_signal (ecs->event_thread->stop_bpstat)
 	      || ecs->event_thread->trap_expected
 	      || (ecs->event_thread->step_range_end
 		  && ecs->event_thread->step_resume_breakpoint == NULL));
       else
 	{
-	  ecs->random_signal = !bpstat_explains_signal (stop_bpstat);
+	  ecs->random_signal = !bpstat_explains_signal (ecs->event_thread->stop_bpstat);
 	  if (!ecs->random_signal)
 	    stop_signal = TARGET_SIGNAL_TRAP;
 	}
@@ -2747,7 +2745,7 @@ process_event_stop_test:
     CORE_ADDR jmp_buf_pc;
     struct bpstat_what what;
 
-    what = bpstat_what (stop_bpstat);
+    what = bpstat_what (ecs->event_thread->stop_bpstat);
 
     if (what.call_dummy)
       {
@@ -2916,7 +2914,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (
 	         code or stubs in libdld.sl, such as "shl_load" and
 	         friends) until we reach non-dld code.  At that point,
 	         we can stop stepping. */
-	      bpstat_get_triggered_catchpoints (stop_bpstat,
+	      bpstat_get_triggered_catchpoints (ecs->event_thread->stop_bpstat,
 						&ecs->
 						event_thread->
 						stepping_through_solib_catchpoints);
@@ -2971,8 +2969,9 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (
       /* Else, stop and report the catchpoint(s) whose triggering
          caused us to begin stepping. */
       ecs->event_thread->stepping_through_solib_after_catch = 0;
-      bpstat_clear (&stop_bpstat);
-      stop_bpstat = bpstat_copy (ecs->event_thread->stepping_through_solib_catchpoints);
+      bpstat_clear (&ecs->event_thread->stop_bpstat);
+      ecs->event_thread->stop_bpstat
+	= bpstat_copy (ecs->event_thread->stepping_through_solib_catchpoints);
       bpstat_clear (&ecs->event_thread->stepping_through_solib_catchpoints);
       stop_print_frame = 1;
       stop_stepping (ecs);
@@ -3845,8 +3844,9 @@ Further execution is probably impossible
 	  int bpstat_ret;
 	  int source_flag;
 	  int do_frame_printing = 1;
+	  struct thread_info *tp = inferior_thread ();
 
-	  bpstat_ret = bpstat_print (stop_bpstat);
+	  bpstat_ret = bpstat_print (tp->stop_bpstat);
 	  switch (bpstat_ret)
 	    {
 	    case PRINT_UNKNOWN:
@@ -3866,7 +3866,7 @@ Further execution is probably impossible
 	         (or should) carry around the function and does (or
 	         should) use that when doing a frame comparison.  */
 	      if (stop_step
-		  && frame_id_eq (inferior_thread ()->step_frame_id,
+		  && frame_id_eq (tp->step_frame_id,
 				  get_frame_id (get_current_frame ()))
 		  && step_start_function == find_pc_function (stop_pc))
 		source_flag = SRC_LINE;	/* finished step, just print source line */
@@ -3945,15 +3945,20 @@ Further execution is probably impossible
 done:
   annotate_stopped ();
   if (!suppress_stop_observer && !step_multi)
-    observer_notify_normal_stop (stop_bpstat);
-  /* Delete the breakpoint we stopped at, if it wants to be deleted.
-     Delete any breakpoint that is to be deleted at the next stop.  */
-  breakpoint_auto_delete (stop_bpstat);
-
+    {
+      if (!ptid_equal (inferior_ptid, null_ptid))
+	observer_notify_normal_stop (inferior_thread ()->stop_bpstat);
+      else
+	observer_notify_normal_stop (NULL);
+    }
   if (target_has_execution
       && last.kind != TARGET_WAITKIND_SIGNALLED
       && last.kind != TARGET_WAITKIND_EXITED)
     {
+      /* Delete the breakpoint we stopped at, if it wants to be deleted.
+	 Delete any breakpoint that is to be deleted at the next stop.  */
+      breakpoint_auto_delete (inferior_thread ()->stop_bpstat);
+
       if (!non_stop)
 	set_running (pid_to_ptid (-1), 0);
       else
@@ -4392,8 +4397,8 @@ save_inferior_status (int restore_stack_
      If caller's caller is walking the chain, they'll be happier if we
      hand them back the original chain when restore_inferior_status is
      called.  */
-  inf_status->stop_bpstat = stop_bpstat;
-  stop_bpstat = bpstat_copy (stop_bpstat);
+  inf_status->stop_bpstat = tp->stop_bpstat;
+  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;
@@ -4442,8 +4447,8 @@ restore_inferior_status (struct inferior
   tp->step_over_calls = inf_status->step_over_calls;
   stop_after_trap = inf_status->stop_after_trap;
   stop_soon = inf_status->stop_soon;
-  bpstat_clear (&stop_bpstat);
-  stop_bpstat = inf_status->stop_bpstat;
+  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;
 
Index: src/gdb/inf-loop.c
===================================================================
--- src.orig/gdb/inf-loop.c	2008-08-16 03:31:03.000000000 +0100
+++ src/gdb/inf-loop.c	2008-08-16 03:37:01.000000000 +0100
@@ -115,7 +115,7 @@ inferior_event_handler (enum inferior_ev
 	 be informed.  */
       TRY_CATCH (e, RETURN_MASK_ALL)
 	{
-	  bpstat_do_actions (&stop_bpstat);
+	  bpstat_do_actions ();
 	}
 
       if (!was_sync && !is_running (inferior_ptid) && exec_done_display_p)
Index: src/gdb/top.c
===================================================================
--- src.orig/gdb/top.c	2008-08-16 03:36:24.000000000 +0100
+++ src/gdb/top.c	2008-08-16 03:37:01.000000000 +0100
@@ -534,8 +534,10 @@ command_loop (void)
 	}
 
       execute_command (command, instream == stdin);
-      /* Do any commands attached to breakpoint we stopped at.  */
-      bpstat_do_actions (&stop_bpstat);
+
+      /* Do any commands attached to breakpoint we are stopped at.  */
+      bpstat_do_actions ();
+
       do_cleanups (old_chain);
 
       if (display_time)
Index: src/gdb/event-top.c
===================================================================
--- src.orig/gdb/event-top.c	2008-08-16 03:36:04.000000000 +0100
+++ src/gdb/event-top.c	2008-08-16 03:37:01.000000000 +0100
@@ -478,7 +478,6 @@ async_disable_stdin (void)
 static void
 command_handler (char *command)
 {
-  struct cleanup *old_chain;
   int stdin_is_tty = ISATTY (stdin);
   long time_at_cmd_start;
 #ifdef HAVE_SBRK
@@ -490,7 +489,6 @@ command_handler (char *command)
   quit_flag = 0;
   if (instream == stdin && stdin_is_tty)
     reinitialize_more_filter ();
-  old_chain = make_cleanup (null_cleanup, 0);
 
   /* If readline returned a NULL command, it means that the 
      connection with the terminal is gone. This happens at the
@@ -515,35 +513,29 @@ command_handler (char *command)
 
   execute_command (command, instream == stdin);
 
-  /* Do any commands attached to breakpoint we stopped at. Only if we
-     are always running synchronously. Or if we have just executed a
-     command that doesn't start the target. */
-  if (!target_can_async_p () || is_stopped (inferior_ptid))
-    {
-      bpstat_do_actions (&stop_bpstat);
-      do_cleanups (old_chain);
+  /* Do any commands attached to breakpoint we stopped at.  */
+  bpstat_do_actions ();
 
-      if (display_time)
-	{
-	  long cmd_time = get_run_time () - time_at_cmd_start;
+  if (display_time)
+    {
+      long cmd_time = get_run_time () - time_at_cmd_start;
 
-	  printf_unfiltered (_("Command execution time: %ld.%06ld\n"),
-			     cmd_time / 1000000, cmd_time % 1000000);
-	}
+      printf_unfiltered (_("Command execution time: %ld.%06ld\n"),
+			 cmd_time / 1000000, cmd_time % 1000000);
+    }
 
-      if (display_space)
-	{
+  if (display_space)
+    {
 #ifdef HAVE_SBRK
-	  char *lim = (char *) sbrk (0);
-	  long space_now = lim - lim_at_start;
-	  long space_diff = space_now - space_at_cmd_start;
-
-	  printf_unfiltered (_("Space used: %ld (%c%ld for this command)\n"),
-			     space_now,
-			     (space_diff >= 0 ? '+' : '-'),
-			     space_diff);
+      char *lim = (char *) sbrk (0);
+      long space_now = lim - lim_at_start;
+      long space_diff = space_now - space_at_cmd_start;
+
+      printf_unfiltered (_("Space used: %ld (%c%ld for this command)\n"),
+			 space_now,
+			 (space_diff >= 0 ? '+' : '-'),
+			 space_diff);
 #endif
-	}
     }
 }
 
Index: src/gdb/python/python.c
===================================================================
--- src.orig/gdb/python/python.c	2008-08-16 03:31:03.000000000 +0100
+++ src/gdb/python/python.c	2008-08-16 03:37:01.000000000 +0100
@@ -241,27 +241,18 @@ execute_gdb_command (PyObject *self, PyO
   struct cmd_list_element *alias, *prefix, *cmd;
   char *arg, *newarg;
   volatile struct gdb_exception except;
-  struct cleanup *old_chain;
 
   if (! PyArg_ParseTuple (args, "s", &arg))
     return NULL;
 
-  old_chain = make_cleanup (null_cleanup, 0);
-
   TRY_CATCH (except, RETURN_MASK_ALL)
     {
       execute_command (arg, 0);
     }
   GDB_PY_HANDLE_EXCEPTION (except);
 
-  /* Do any commands attached to breakpoint we stopped at. Only if we
-     are always running synchronously. Or if we have just executed a
-     command that doesn't start the target. */
-  if (!target_can_async_p () || !is_running (inferior_ptid))
-    {
-      bpstat_do_actions (&stop_bpstat);
-      do_cleanups (old_chain);
-    }
+  /* Do any commands attached to breakpoint we stopped at.  */
+  bpstat_do_actions ();
 
   Py_RETURN_NONE;
 }

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