aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2008-09-08 21:46:21 +0000
committerPedro Alves <palves@redhat.com>2008-09-08 21:46:21 +0000
commit347bddb745acda8fb591511a547e66bbe00d768b (patch)
treee1ae89f31d0e51854b0454eaa75ec215a4c42191 /gdb/breakpoint.c
parent078130d0caa5d5ec686abe6ee5589a644885082a (diff)
downloadgdb-347bddb745acda8fb591511a547e66bbe00d768b.zip
gdb-347bddb745acda8fb591511a547e66bbe00d768b.tar.gz
gdb-347bddb745acda8fb591511a547e66bbe00d768b.tar.bz2
* 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.
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r--gdb/breakpoint.c77
1 files changed, 43 insertions, 34 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 87f2831..8e69131 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