diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2012-06-18 17:28:38 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2012-06-18 17:28:38 +0000 |
commit | e2e4d78b2216962789c8a982d3e889ba6933321a (patch) | |
tree | cd9aa71e52f6bb308e2b82e5b23ec1949d043518 /gdb/dummy-frame.c | |
parent | 09d5912c6f5be8d8935ff45941bf957209bd42a6 (diff) | |
download | gdb-e2e4d78b2216962789c8a982d3e889ba6933321a.zip gdb-e2e4d78b2216962789c8a982d3e889ba6933321a.tar.gz gdb-e2e4d78b2216962789c8a982d3e889ba6933321a.tar.bz2 |
gdb/
Remove stale dummy frames.
* breakpoint.c: Include dummy-frame.h.
(longjmp_breakpoint_ops): New variable.
(update_breakpoints_after_exec, breakpoint_init_inferior): Delete also
bp_longjmp_call_dummy.
(bpstat_what, bptype_string, print_one_breakpoint_location)
(init_bp_location): Support bp_longjmp_call_dummy.
(set_longjmp_breakpoint): Use longjmp_breakpoint_ops. Comment why.
(set_longjmp_breakpoint_for_call_dummy)
(check_longjmp_breakpoint_for_call_dummy, longjmp_bkpt_dtor): New
functions.
(initialize_breakpoint_ops): Initialize longjmp_breakpoint_ops.
* breakpoint.h (enum bptype): New item bp_longjmp_call_dummy. Delete
FIXME comment and extend the other comment for bp_call_dummy.
(set_longjmp_breakpoint_for_call_dummy)
(check_longjmp_breakpoint_for_call_dummy): New declarations.
* dummy-frame.c: Include gdbthread.h.
(pop_dummy_frame_bpt): New function.
(pop_dummy_frame): Call pop_dummy_frame_bpt.
(dummy_frame_discard): New function.
(cleanup_dummy_frames): Update the comment about longjmps.
* dummy-frame.h (dummy_frame_discard): New declaration.
* gdbthread.h (struct thread_info): Extend initiating_frame comment.
* infcall.c (call_function_by_hand): New variable longjmp_b. Call
set_longjmp_breakpoint_for_call_dummy. Chain its breakpoints with BPT.
* infrun.c (handle_inferior_event) <BPSTAT_WHAT_CLEAR_LONGJMP_RESUME>:
Add case 4 comment. Call check_longjmp_breakpoint_for_call_dummy and
keep_going if IS_LONGJMP and there is no other reason to stop.
gdb/testsuite/
Remove stale dummy frames.
* gdb.base/call-signal-resume.exp (maintenance print dummy-frames)
(maintenance info breakpoints): New tests.
* gdb.base/stale-infcall.c: New file.
* gdb.base/stale-infcall.exp: New file.
Diffstat (limited to 'gdb/dummy-frame.c')
-rw-r--r-- | gdb/dummy-frame.c | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/gdb/dummy-frame.c b/gdb/dummy-frame.c index 4a42a76..b8a8c86 100644 --- a/gdb/dummy-frame.c +++ b/gdb/dummy-frame.c @@ -29,6 +29,7 @@ #include "gdbcmd.h" #include "gdb_string.h" #include "observer.h" +#include "gdbthread.h" /* Dummy frame. This saves the processor state just prior to setting up the inferior function call. Older targets save the registers @@ -108,19 +109,44 @@ remove_dummy_frame (struct dummy_frame **dummy_ptr) xfree (dummy); } +/* Delete any breakpoint B which is a momentary breakpoint for return from + inferior call matching DUMMY_VOIDP. */ + +static int +pop_dummy_frame_bpt (struct breakpoint *b, void *dummy_voidp) +{ + struct dummy_frame *dummy = dummy_voidp; + + if (b->thread == pid_to_thread_id (inferior_ptid) + && b->disposition == disp_del && frame_id_eq (b->frame_id, dummy->id)) + { + while (b->related_breakpoint != b) + delete_breakpoint (b->related_breakpoint); + + delete_breakpoint (b); + + /* Stop the traversal. */ + return 1; + } + + /* Continue the traversal. */ + return 0; +} + /* Pop *DUMMY_PTR, restoring program state to that before the frame was created. */ static void pop_dummy_frame (struct dummy_frame **dummy_ptr) { - struct dummy_frame *dummy; + struct dummy_frame *dummy = *dummy_ptr; + + restore_infcall_suspend_state (dummy->caller_state); - restore_infcall_suspend_state ((*dummy_ptr)->caller_state); + iterate_over_breakpoints (pop_dummy_frame_bpt, dummy); /* restore_infcall_control_state frees inf_state, all that remains is to pop *dummy_ptr. */ - dummy = *dummy_ptr; *dummy_ptr = dummy->next; xfree (dummy); @@ -166,9 +192,22 @@ dummy_frame_pop (struct frame_id dummy_id) pop_dummy_frame (dp); } -/* There may be stale dummy frames, perhaps left over from when a longjump took - us out of a function that was called by the debugger. Clean them up at - least once whenever we start a new inferior. */ +/* Drop dummy frame DUMMY_ID. Do nothing if it is not found. Do not restore + its state into inferior, just free its memory. */ + +void +dummy_frame_discard (struct frame_id dummy_id) +{ + struct dummy_frame **dp; + + dp = lookup_dummy_frame (dummy_id); + if (dp) + remove_dummy_frame (dp); +} + +/* There may be stale dummy frames, perhaps left over from when an uncaught + longjmp took us out of a function that was called by the debugger. Clean + them up at least once whenever we start a new inferior. */ static void cleanup_dummy_frames (struct target_ops *target, int from_tty) |