From: Pedro Alves Date: Mon, 8 Sep 2008 21:46:21 +0000 (+0000) Subject: * inferior.h (stop_bpstat): Delete. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=347bddb745acda8fb591511a547e66bbe00d768b;p=binutils-gdb.git * 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. Make static. 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/python.c (execute_gdb_command): Ditto. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f35f93b0ce3..1b767aacc34 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,45 @@ +2008-09-08 Pedro Alves + + * 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. Make static. 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/python.c (execute_gdb_command): Ditto. + 2008-09-08 Pedro Alves * inferior.h (step_over_calls): Delete. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 87f283153e8..8e691312525 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -2138,31 +2138,27 @@ cleanup_executing_breakpoints (void *ignore) /* 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 responsibility 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; @@ -2202,30 +2198,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. */ @@ -7241,9 +7253,6 @@ delete_breakpoint (struct breakpoint *bpt) 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 diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index ef536bc7971..8bafc93aa03 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -604,10 +604,11 @@ extern enum print_stop_action bpstat_print (bpstat); 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); diff --git a/gdb/event-top.c b/gdb/event-top.c index 61c431dabf2..df01a1f8987 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -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 - } } } diff --git a/gdb/exceptions.c b/gdb/exceptions.c index 304c8c6c27e..f917c94ea16 100644 --- a/gdb/exceptions.c +++ b/gdb/exceptions.c @@ -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); diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 953a1d2c1ae..82f12587df5 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -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 ptid, 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 ptid, 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); diff --git a/gdb/inf-loop.c b/gdb/inf-loop.c index 725b57cf901..17fbd929999 100644 --- a/gdb/inf-loop.c +++ b/gdb/inf-loop.c @@ -115,7 +115,7 @@ inferior_event_handler (enum inferior_event_type event_type, 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) diff --git a/gdb/infcall.c b/gdb/infcall.c index 559b4a2e7b9..ec8f732376e 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -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 *function, struct type **retval_type) } /* 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 *function, int nargs, struct value **args) /* 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... */ diff --git a/gdb/infcmd.c b/gdb/infcmd.c index d6b9d02ff5f..e1974675dbc 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -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. */ @@ -673,9 +669,23 @@ Can't resume all threads and specify proceed count simultaneously.")); 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) @@ -1319,7 +1329,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; @@ -1339,7 +1356,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); } @@ -1436,9 +1453,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) { @@ -1446,6 +1464,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)); diff --git a/gdb/inferior.h b/gdb/inferior.h index 05f7ae62d06..f39cc2c1797 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -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. */ diff --git a/gdb/infrun.c b/gdb/infrun.c index 1f89921f34b..560722fd7f8 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1105,6 +1105,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; @@ -1117,9 +1120,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. */ @@ -1717,8 +1717,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, @@ -1726,8 +1725,7 @@ context_switch (ptid_t ptid) &proceed_to_finish, &stop_step, &step_multi, - &stop_signal, - &stop_bpstat); + &stop_signal); } switch_to_thread (ptid); @@ -2065,9 +2063,9 @@ handle_inferior_event (struct execution_control_state *ecs) 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) @@ -2101,9 +2099,9 @@ handle_inferior_event (struct execution_control_state *ecs) 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; } @@ -2499,7 +2497,7 @@ targets should add new threads to the thread list themselves in non-stop mode.") 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; @@ -2612,7 +2610,7 @@ targets should add new threads to the thread list themselves in non-stop mode.") } /* 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. */ @@ -2640,13 +2638,13 @@ targets should add new threads to the thread list themselves in non-stop mode.") 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; } @@ -2760,7 +2758,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) { @@ -2929,7 +2927,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); 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); @@ -2984,8 +2982,9 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n"); /* 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); @@ -3831,8 +3830,9 @@ Further execution is probably impossible.\n")); 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: @@ -3852,7 +3852,7 @@ Further execution is probably impossible.\n")); (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 */ @@ -3931,15 +3931,20 @@ Further execution is probably impossible.\n")); 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 @@ -4378,8 +4383,8 @@ save_inferior_status (int restore_stack_info) 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; @@ -4428,8 +4433,8 @@ restore_inferior_status (struct inferior_status *inf_status) 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; diff --git a/gdb/python/python.c b/gdb/python/python.c index 71869143285..8bc24c275ef 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -241,27 +241,18 @@ execute_gdb_command (PyObject *self, PyObject *args) 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; } diff --git a/gdb/thread.c b/gdb/thread.c index 875c55f6103..fdd7d66680e 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -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; } } diff --git a/gdb/top.c b/gdb/top.c index 52d1a0ef523..593da2d2293 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -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)