diff options
Diffstat (limited to 'gdb/infrun.c')
-rw-r--r-- | gdb/infrun.c | 203 |
1 files changed, 107 insertions, 96 deletions
diff --git a/gdb/infrun.c b/gdb/infrun.c index f65af35..9503b10 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -42,6 +42,8 @@ #include "inf-loop.h" #include "regcache.h" #include "value.h" +#include "observer.h" +#include "language.h" /* Prototypes for local functions */ @@ -106,21 +108,6 @@ static ptid_t previous_inferior_ptid; static int may_follow_exec = MAY_FOLLOW_EXEC; -/* Dynamic function trampolines are similar to solib trampolines in that they - are between the caller and the callee. The difference is that when you - enter a dynamic trampoline, you can't determine the callee's address. Some - (usually complex) code needs to run in the dynamic trampoline to figure out - the callee's address. This macro is usually called twice. First, when we - enter the trampoline (looks like a normal function call at that point). It - should return the PC of a point within the trampoline where the callee's - address is known. Second, when we hit the breakpoint, this routine returns - the callee's address. At that point, things proceed as per a step resume - breakpoint. */ - -#ifndef DYNAMIC_TRAMPOLINE_NEXTPC -#define DYNAMIC_TRAMPOLINE_NEXTPC(pc) 0 -#endif - /* If the program uses ELF-style shared libraries, then calls to functions in shared libraries go through stubs, which live in a table called the PLT (Procedure Linkage Table). The first time the @@ -299,7 +286,7 @@ int stop_after_trap; when running in the shell before the child program has been exec'd; and when running some kinds of remote stuff (FIXME?). */ -int stop_soon_quietly; +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. */ @@ -672,7 +659,7 @@ clear_proceed_status (void) step_frame_id = null_frame_id; step_over_calls = STEP_OVER_UNDEBUGGABLE; stop_after_trap = 0; - stop_soon_quietly = 0; + stop_soon = NO_STOP_QUIETLY; proceed_to_finish = 0; breakpoint_proceeded = 1; /* We're about to proceed... */ @@ -804,7 +791,6 @@ proceed (CORE_ADDR addr, enum target_signal siggnal, int step) to be preserved over calls to it and cleared when the inferior is started. */ static CORE_ADDR prev_pc; -static CORE_ADDR prev_func_start; static char *prev_func_name; @@ -815,7 +801,7 @@ start_remote (void) { init_thread_list (); init_wait_for_inferior (); - stop_soon_quietly = 1; + stop_soon = STOP_QUIETLY; trap_expected = 0; /* Always go on waiting for the target, regardless of the mode. */ @@ -843,7 +829,6 @@ init_wait_for_inferior (void) { /* These are meaningless until the first time through wait_for_inferior. */ prev_pc = 0; - prev_func_start = 0; prev_func_name = NULL; #ifdef HP_OS_BUG @@ -1131,8 +1116,7 @@ context_switch (struct execution_control_state *ecs) if (in_thread_list (inferior_ptid) && in_thread_list (ecs->ptid)) { /* Perform infrun state context switch: */ /* Save infrun state for the old thread. */ - save_infrun_state (inferior_ptid, prev_pc, - prev_func_start, prev_func_name, + save_infrun_state (inferior_ptid, prev_pc, prev_func_name, trap_expected, step_resume_breakpoint, through_sigtramp_breakpoint, step_range_start, step_range_end, &step_frame_id, @@ -1143,8 +1127,7 @@ context_switch (struct execution_control_state *ecs) ecs->current_line, ecs->current_symtab, step_sp); /* Load infrun state for the new thread. */ - load_infrun_state (ecs->ptid, &prev_pc, - &prev_func_start, &prev_func_name, + load_infrun_state (ecs->ptid, &prev_pc, &prev_func_name, &trap_expected, &step_resume_breakpoint, &through_sigtramp_breakpoint, &step_range_start, &step_range_end, &step_frame_id, @@ -1166,6 +1149,11 @@ void handle_inferior_event (struct execution_control_state *ecs) { CORE_ADDR real_stop_pc; + /* NOTE: cagney/2003-03-28: If you're looking at this code and + thinking that the variable stepped_after_stopped_by_watchpoint + isn't used, then you're wrong! The macro STOPPED_BY_WATCHPOINT, + defined in the file "config/pa/nm-hppah.h", accesses the variable + indirectly. Mutter something rude about the HP merge. */ int stepped_after_stopped_by_watchpoint; int sw_single_step_trap_p = 0; @@ -1178,7 +1166,15 @@ handle_inferior_event (struct execution_control_state *ecs) case infwait_thread_hop_state: /* Cancel the waiton_ptid. */ ecs->waiton_ptid = pid_to_ptid (-1); - /* Fall thru to the normal_state case. */ + /* See comments where a TARGET_WAITKIND_SYSCALL_RETURN event + is serviced in this loop, below. */ + if (ecs->enable_hw_watchpoints_after_wait) + { + TARGET_ENABLE_HW_WATCHPOINTS (PIDGET (inferior_ptid)); + ecs->enable_hw_watchpoints_after_wait = 0; + } + stepped_after_stopped_by_watchpoint = 0; + break; case infwait_normal_state: /* See comments where a TARGET_WAITKIND_SYSCALL_RETURN event @@ -1192,6 +1188,7 @@ handle_inferior_event (struct execution_control_state *ecs) break; case infwait_nullified_state: + stepped_after_stopped_by_watchpoint = 0; break; case infwait_nonstep_watch_state: @@ -1202,6 +1199,9 @@ handle_inferior_event (struct execution_control_state *ecs) in combination correctly? */ stepped_after_stopped_by_watchpoint = 1; break; + + default: + internal_error (__FILE__, __LINE__, "bad switch"); } ecs->infwait_state = infwait_normal_state; @@ -1254,7 +1254,7 @@ handle_inferior_event (struct execution_control_state *ecs) might be the shell which has just loaded some objects, otherwise add the symbols for the newly loaded objects. */ #ifdef SOLIB_ADD - if (!stop_soon_quietly) + if (stop_soon == NO_STOP_QUIETLY) { /* Remove breakpoints, SOLIB_ADD might adjust breakpoint addresses via breakpoint_re_set. */ @@ -1753,7 +1753,9 @@ handle_inferior_event (struct execution_control_state *ecs) if (stop_signal == TARGET_SIGNAL_TRAP || (breakpoints_inserted && (stop_signal == TARGET_SIGNAL_ILL - || stop_signal == TARGET_SIGNAL_EMT)) || stop_soon_quietly) + || stop_signal == TARGET_SIGNAL_EMT)) + || stop_soon == STOP_QUIETLY + || stop_soon == STOP_QUIETLY_NO_SIGSTOP) { if (stop_signal == TARGET_SIGNAL_TRAP && stop_after_trap) { @@ -1761,12 +1763,27 @@ handle_inferior_event (struct execution_control_state *ecs) stop_stepping (ecs); return; } - if (stop_soon_quietly) + + /* This is originated from start_remote(), start_inferior() and + shared libraries hook functions. */ + if (stop_soon == STOP_QUIETLY) { stop_stepping (ecs); return; } + /* This originates from attach_command(). We need to overwrite + the stop_signal here, because some kernels don't ignore a + SIGSTOP in a subsequent ptrace(PTRACE_SONT,SOGSTOP) call. + See more comments in inferior.h. */ + if (stop_soon == STOP_QUIETLY_NO_SIGSTOP) + { + stop_stepping (ecs); + if (stop_signal == TARGET_SIGNAL_STOP) + stop_signal = TARGET_SIGNAL_0; + return; + } + /* Don't even think about breakpoints if just proceeded over a breakpoint. @@ -1808,26 +1825,30 @@ handle_inferior_event (struct execution_control_state *ecs) stop_print_frame = 1; } + /* NOTE: cagney/2003-03-29: These two checks for a random signal + at one stage in the past included checks for an inferior + function call's call dummy's return breakpoint. The original + comment, that went with the test, read: + + ``End of a stack dummy. Some systems (e.g. Sony news) give + another signal besides SIGTRAP, so check here as well as + above.'' + + If someone ever tries to get get call dummys on a + non-executable stack to work (where the target would stop + with something like a SIGSEG), then those tests might need to + be re-instated. Given, however, that the tests were only + enabled when momentary breakpoints were not being used, I + suspect that it won't be the case. */ + if (stop_signal == TARGET_SIGNAL_TRAP) ecs->random_signal = !(bpstat_explains_signal (stop_bpstat) || trap_expected - || (!CALL_DUMMY_BREAKPOINT_OFFSET_P - && DEPRECATED_PC_IN_CALL_DUMMY (stop_pc, read_sp (), - get_frame_base (get_current_frame ()))) || (step_range_end && step_resume_breakpoint == NULL)); - else { - ecs->random_signal = !(bpstat_explains_signal (stop_bpstat) - /* End of a stack dummy. Some systems (e.g. Sony - news) give another signal besides SIGTRAP, so - check here as well as above. */ - || (!CALL_DUMMY_BREAKPOINT_OFFSET_P - && DEPRECATED_PC_IN_CALL_DUMMY (stop_pc, read_sp (), - get_frame_base - (get_current_frame - ())))); + ecs->random_signal = !bpstat_explains_signal (stop_bpstat); if (!ecs->random_signal) stop_signal = TARGET_SIGNAL_TRAP; } @@ -2169,31 +2190,6 @@ process_event_stop_test: return; } - if (!CALL_DUMMY_BREAKPOINT_OFFSET_P) - { - /* This is the old way of detecting the end of the stack dummy. - An architecture which defines CALL_DUMMY_BREAKPOINT_OFFSET gets - handled above. As soon as we can test it on all of them, all - architectures should define it. */ - - /* If this is the breakpoint at the end of a stack dummy, - just stop silently, unless the user was doing an si/ni, in which - case she'd better know what she's doing. */ - - if (CALL_DUMMY_HAS_COMPLETED (stop_pc, read_sp (), - get_frame_base (get_current_frame ())) - && !step_range_end) - { - stop_print_frame = 0; - stop_stack_dummy = 1; -#ifdef HP_OS_BUG - trap_expected_after_continue = 1; -#endif - stop_stepping (ecs); - return; - } - } - if (step_resume_breakpoint) { /* Having a step-resume breakpoint overrides anything @@ -2400,28 +2396,11 @@ process_event_stop_test: function. That's what tells us (a) whether we want to step into it at all, and (b) what prologue we want to run to the end of, if we do step into it. */ - real_stop_pc = SKIP_TRAMPOLINE_CODE (stop_pc); + real_stop_pc = skip_language_trampoline (stop_pc); + if (real_stop_pc == 0) + real_stop_pc = SKIP_TRAMPOLINE_CODE (stop_pc); if (real_stop_pc != 0) ecs->stop_func_start = real_stop_pc; - else - { - real_stop_pc = DYNAMIC_TRAMPOLINE_NEXTPC (stop_pc); - if (real_stop_pc) - { - struct symtab_and_line xxx; - /* Why isn't this s_a_l called "sr_sal", like all of the - other s_a_l's where this code is duplicated? */ - init_sal (&xxx); /* initialize to zeroes */ - xxx.pc = real_stop_pc; - xxx.section = find_pc_overlay (xxx.pc); - check_for_old_step_resume_breakpoint (); - step_resume_breakpoint = - set_momentary_breakpoint (xxx, null_frame_id, bp_step_resume); - insert_breakpoints (); - keep_going (ecs); - return; - } - } /* If we have line number information for the function we are thinking of stepping into, step into it. @@ -2692,7 +2671,44 @@ step_over_function (struct execution_control_state *ecs) struct symtab_and_line sr_sal; init_sal (&sr_sal); /* initialize to zeros */ - sr_sal.pc = ADDR_BITS_REMOVE (SAVED_PC_AFTER_CALL (get_current_frame ())); + + /* NOTE: cagney/2003-04-06: + + At this point the equality get_frame_pc() == get_frame_func() + should hold. This may make it possible for this code to tell the + frame where it's function is, instead of the reverse. This would + avoid the need to search for the frame's function, which can get + very messy when there is no debug info available (look at the + heuristic find pc start code found in targets like the MIPS). */ + + /* NOTE: cagney/2003-04-06: + + The intent of DEPRECATED_SAVED_PC_AFTER_CALL was to: + + - provide a very light weight equivalent to frame_unwind_pc() + (nee FRAME_SAVED_PC) that avoids the prologue analyzer + + - avoid handling the case where the PC hasn't been saved in the + prologue analyzer + + Unfortunatly, not five lines further down, is a call to + get_frame_id() and that is guarenteed to trigger the prologue + analyzer. + + The `correct fix' is for the prologe analyzer to handle the case + where the prologue is incomplete (PC in prologue) and, + consequently, the return pc has not yet been saved. It should be + noted that the prologue analyzer needs to handle this case + anyway: frameless leaf functions that don't save the return PC; + single stepping through a prologue. + + The d10v handles all this by bailing out of the prologue analsis + when it reaches the current instruction. */ + + if (DEPRECATED_SAVED_PC_AFTER_CALL_P ()) + sr_sal.pc = ADDR_BITS_REMOVE (DEPRECATED_SAVED_PC_AFTER_CALL (get_current_frame ())); + else + sr_sal.pc = ADDR_BITS_REMOVE (frame_pc_unwind (get_current_frame ())); sr_sal.section = find_pc_overlay (sr_sal.pc); check_for_old_step_resume_breakpoint (); @@ -2717,7 +2733,6 @@ stop_stepping (struct execution_control_state *ecs) time, just like we did above if we didn't break out of the loop. */ prev_pc = read_pc (); - prev_func_start = ecs->stop_func_start; prev_func_name = ecs->stop_func_name; } @@ -2734,11 +2749,6 @@ keep_going (struct execution_control_state *ecs) { /* Save the pc before execution, to compare with pc after stop. */ prev_pc = read_pc (); /* Might have been DECR_AFTER_BREAK */ - prev_func_start = ecs->stop_func_start; /* Ok, since if DECR_PC_AFTER - BREAK is defined, the - original pc would not have - been at the start of a - function. */ prev_func_name = ecs->stop_func_name; if (ecs->update_step_sp) @@ -3113,6 +3123,7 @@ normal_stop (void) done: annotate_stopped (); + observer_notify_normal_stop (); } static int @@ -3493,7 +3504,7 @@ struct inferior_status enum step_over_calls_kind step_over_calls; CORE_ADDR step_resume_break_address; int stop_after_trap; - int stop_soon_quietly; + int stop_soon; struct regcache *stop_registers; /* These are here because if call_function_by_hand has written some @@ -3539,7 +3550,7 @@ save_inferior_status (int restore_stack_info) inf_status->step_frame_id = step_frame_id; inf_status->step_over_calls = step_over_calls; inf_status->stop_after_trap = stop_after_trap; - inf_status->stop_soon_quietly = stop_soon_quietly; + inf_status->stop_soon = stop_soon; /* Save original bpstat chain here; replace it with copy of chain. 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 @@ -3593,7 +3604,7 @@ restore_inferior_status (struct inferior_status *inf_status) step_frame_id = inf_status->step_frame_id; step_over_calls = inf_status->step_over_calls; stop_after_trap = inf_status->stop_after_trap; - stop_soon_quietly = inf_status->stop_soon_quietly; + stop_soon = inf_status->stop_soon; bpstat_clear (&stop_bpstat); stop_bpstat = inf_status->stop_bpstat; breakpoint_proceeded = inf_status->breakpoint_proceeded; |