/* Target-struct-independent code to start (run) and stop an inferior
process.
- Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
- 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free
- Software Foundation, Inc.
+ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+ 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+ Free Software Foundation, Inc.
This file is part of GDB.
#define SOLIB_IN_DYNAMIC_LINKER(pid,pc) 0
#endif
-/* We can't step off a permanent breakpoint in the ordinary way, because we
- can't remove it. Instead, we have to advance the PC to the next
- instruction. This macro should expand to a pointer to a function that
- does that, or zero if we have no such function. If we don't have a
- definition for it, we have to report an error. */
-#ifndef SKIP_PERMANENT_BREAKPOINT
-#define SKIP_PERMANENT_BREAKPOINT (default_skip_permanent_breakpoint)
-static void
-default_skip_permanent_breakpoint (void)
-{
- error (_("\
-The program is stopped at a permanent breakpoint, but GDB does not know\n\
-how to step past a permanent breakpoint on this architecture. Try using\n\
-a command like `return' or `jump' to continue execution."));
-}
-#endif
-
/* Convert the #defines into values. This is temporary until wfi control
flow is completely sorted out. */
-#ifndef HAVE_STEPPABLE_WATCHPOINT
-#define HAVE_STEPPABLE_WATCHPOINT 0
-#else
-#undef HAVE_STEPPABLE_WATCHPOINT
-#define HAVE_STEPPABLE_WATCHPOINT 1
-#endif
-
#ifndef CANNOT_STEP_HW_WATCHPOINTS
#define CANNOT_STEP_HW_WATCHPOINTS 0
#else
struct regcache *stop_registers;
-/* Nonzero if program stopped due to error trying to insert breakpoints. */
-
-static int breakpoints_failed;
-
/* Nonzero after stop if current stack frame should be printed. */
static int stop_print_frame;
/* The thread we inserted single-step breakpoints for. */
static ptid_t singlestep_ptid;
+/* PC when we started this single-step. */
+static CORE_ADDR singlestep_pc;
+
/* If another thread hit the singlestep breakpoint, we save the original
thread here so that we can resume single-stepping it later. */
static ptid_t saved_singlestep_ptid;
at a permanent breakpoint; we need to step over it, but permanent
breakpoints can't be removed. So we have to test for it here. */
if (breakpoint_here_p (read_pc ()) == permanent_breakpoint_here)
- SKIP_PERMANENT_BREAKPOINT ();
+ {
+ if (gdbarch_skip_permanent_breakpoint_p (current_gdbarch))
+ gdbarch_skip_permanent_breakpoint (current_gdbarch, current_regcache);
+ else
+ error (_("\
+The program is stopped at a permanent breakpoint, but GDB does not know\n\
+how to step past a permanent breakpoint on this architecture. Try using\n\
+a command like `return' or `jump' to continue execution."));
+ }
if (SOFTWARE_SINGLE_STEP_P () && step)
{
/* Do it the hard way, w/temp breakpoints */
- SOFTWARE_SINGLE_STEP (sig, 1 /*insert-breakpoints */ );
- /* ...and don't ask hardware to do it. */
- step = 0;
- /* and do not pull these breakpoints until after a `wait' in
- `wait_for_inferior' */
- singlestep_breakpoints_inserted_p = 1;
- singlestep_ptid = inferior_ptid;
+ if (SOFTWARE_SINGLE_STEP (current_regcache))
+ {
+ /* ...and don't ask hardware to do it. */
+ step = 0;
+ /* and do not pull these breakpoints until after a `wait' in
+ `wait_for_inferior' */
+ singlestep_breakpoints_inserted_p = 1;
+ singlestep_ptid = inferior_ptid;
+ singlestep_pc = read_pc ();
+ }
}
/* If there were any forks/vforks/execs that were caught and are
resume_ptid = inferior_ptid;
}
- if (CANNOT_STEP_BREAKPOINT)
+ if (gdbarch_cannot_step_breakpoint (current_gdbarch))
{
/* Most targets can step a breakpoint instruction, thus
executing it normally. But if this one cannot, just
/* FIXME: This stuff came from switch_to_thread() in
thread.c (which should probably be a public function). */
- flush_cached_frames ();
+ reinit_frame_cache ();
registers_changed ();
stop_pc = wait_pc;
- select_frame (get_current_frame ());
}
/* We return 1 to indicate that there is a breakpoint here,
/* Start remote-debugging of a machine over a serial link. */
void
-start_remote (void)
+start_remote (int from_tty)
{
init_thread_list ();
init_wait_for_inferior ();
is currently running and GDB state should be set to the same as
for an async run. */
wait_for_inferior ();
+
+ /* Now that the inferior has stopped, do any bookkeeping like
+ loading shared libraries. We want to do this before normal_stop,
+ so that the displayed frame is up to date. */
+ post_create_inferior (¤t_target, from_tty);
+
normal_stop ();
}
to the interface from within handle_inferior_event(). */
enum inferior_stop_reason
{
- /* We don't know why. */
- STOP_UNKNOWN,
/* Step, next, nexti, stepi finished. */
END_STEPPING_RANGE,
- /* Found breakpoint. */
- BREAKPOINT_HIT,
/* Inferior terminated by signal. */
SIGNAL_EXITED,
/* Inferior exited. */
static void step_into_function (struct execution_control_state *ecs);
static void insert_step_resume_breakpoint_at_frame (struct frame_info *step_frame);
+static void insert_step_resume_breakpoint_at_caller (struct frame_info *);
static void insert_step_resume_breakpoint_at_sal (struct symtab_and_line sr_sal,
struct frame_id sr_id);
static void stop_stepping (struct execution_control_state *ecs);
be lost. This may happen as a result of the target module
mishandling thread creation. */
+ if (debug_infrun)
+ {
+ fprintf_unfiltered (gdb_stdlog, "infrun: Switching context from %s ",
+ target_pid_to_str (inferior_ptid));
+ fprintf_unfiltered (gdb_stdlog, "to %s\n",
+ target_pid_to_str (ecs->ptid));
+ }
+
if (in_thread_list (inferior_ptid) && in_thread_list (ecs->ptid))
{ /* Perform infrun state context switch: */
/* Save infrun state for the old thread. */
&ecs->current_line, &ecs->current_symtab);
}
inferior_ptid = ecs->ptid;
+ reinit_frame_cache ();
}
static void
/* If this target does not decrement the PC after breakpoints, then
we have nothing to do. */
- if (DECR_PC_AFTER_BREAK == 0)
+ if (gdbarch_decr_pc_after_break (current_gdbarch) == 0)
return;
/* If we've hit a breakpoint, we'll normally be stopped with SIGTRAP. If
we aren't, just return.
We assume that waitkinds other than TARGET_WAITKIND_STOPPED are not
- affected by DECR_PC_AFTER_BREAK. Other waitkinds which are implemented
- by software breakpoints should be handled through the normal breakpoint
- layer.
+ affected by gdbarch_decr_pc_after_break. Other waitkinds which are
+ implemented by software breakpoints should be handled through the normal
+ breakpoint layer.
NOTE drow/2004-01-31: On some targets, breakpoints may generate
different signals (SIGILL or SIGEMT for instance), but it is less
clear where the PC is pointing afterwards. It may not match
- DECR_PC_AFTER_BREAK. I don't know any specific target that generates
- these signals at breakpoints (the code has been in GDB since at least
- 1992) so I can not guess how to handle them here.
+ gdbarch_decr_pc_after_break. I don't know any specific target that
+ generates these signals at breakpoints (the code has been in GDB since at
+ least 1992) so I can not guess how to handle them here.
- In earlier versions of GDB, a target with HAVE_NONSTEPPABLE_WATCHPOINTS
- would have the PC after hitting a watchpoint affected by
- DECR_PC_AFTER_BREAK. I haven't found any target with both of these set
- in GDB history, and it seems unlikely to be correct, so
- HAVE_NONSTEPPABLE_WATCHPOINTS is not checked here. */
+ In earlier versions of GDB, a target with
+ gdbarch_have_nonsteppable_watchpoint would have the PC after hitting a
+ watchpoint affected by gdbarch_decr_pc_after_break. I haven't found any
+ target with both of these set in GDB history, and it seems unlikely to be
+ correct, so gdbarch_have_nonsteppable_watchpoint is not checked here. */
if (ecs->ws.kind != TARGET_WAITKIND_STOPPED)
return;
/* Find the location where (if we've hit a breakpoint) the
breakpoint would be. */
- breakpoint_pc = read_pc_pid (ecs->ptid) - DECR_PC_AFTER_BREAK;
+ breakpoint_pc = read_pc_pid (ecs->ptid) - gdbarch_decr_pc_after_break
+ (current_gdbarch);
if (SOFTWARE_SINGLE_STEP_P ())
{
}
ecs->infwait_state = infwait_normal_state;
- flush_cached_frames ();
+ reinit_frame_cache ();
/* If it's a new process, add it to the thread database */
(LONGEST) ecs->ws.value.integer));
gdb_flush (gdb_stdout);
target_mourn_inferior ();
- singlestep_breakpoints_inserted_p = 0; /*SOFTWARE_SINGLE_STEP_P() */
+ singlestep_breakpoints_inserted_p = 0; /* SOFTWARE_SINGLE_STEP_P() */
stop_print_frame = 0;
stop_stepping (ecs);
return;
target_mourn_inferior ();
print_stop_reason (SIGNAL_EXITED, stop_signal);
- singlestep_breakpoints_inserted_p = 0; /*SOFTWARE_SINGLE_STEP_P() */
+ singlestep_breakpoints_inserted_p = 0; /* SOFTWARE_SINGLE_STEP_P() */
stop_stepping (ecs);
return;
pending_follow.fork_event.parent_pid = PIDGET (ecs->ptid);
pending_follow.fork_event.child_pid = ecs->ws.value.related_pid;
+ if (!ptid_equal (ecs->ptid, inferior_ptid))
+ {
+ context_switch (ecs);
+ reinit_frame_cache ();
+ }
+
stop_pc = read_pc ();
stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid, 0);
case TARGET_WAITKIND_EXECD:
if (debug_infrun)
- fprintf_unfiltered (gdb_stdlog, "infrun: TARGET_WAITKIND_EXECED\n");
+ fprintf_unfiltered (gdb_stdlog, "infrun: TARGET_WAITKIND_EXECD\n");
stop_signal = TARGET_SIGNAL_TRAP;
/* NOTE drow/2002-12-05: This code should be pushed down into the
if (inferior_ignoring_leading_exec_events)
{
inferior_ignoring_leading_exec_events--;
- if (pending_follow.kind == TARGET_WAITKIND_VFORKED)
- ENSURE_VFORKING_PARENT_REMAINS_STOPPED (pending_follow.fork_event.
- parent_pid);
target_resume (ecs->ptid, 0, TARGET_SIGNAL_0);
prepare_to_wait (ecs);
return;
ecs->random_signal = !bpstat_explains_signal (stop_bpstat);
inferior_ptid = ecs->saved_inferior_ptid;
+ if (!ptid_equal (ecs->ptid, inferior_ptid))
+ {
+ context_switch (ecs);
+ reinit_frame_cache ();
+ }
+
/* If no catchpoint triggered for this, then keep going. */
if (ecs->random_signal)
{
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, "infrun: stepping_past_singlestep_breakpoint\n");
/* Pull the single step breakpoints out of the target. */
- SOFTWARE_SINGLE_STEP (0, 0);
+ remove_single_step_breakpoints ();
singlestep_breakpoints_inserted_p = 0;
ecs->random_signal = 0;
}
else if (SOFTWARE_SINGLE_STEP_P () && singlestep_breakpoints_inserted_p)
{
+ /* We have not context switched yet, so this should be true
+ no matter which thread hit the singlestep breakpoint. */
+ gdb_assert (ptid_equal (inferior_ptid, singlestep_ptid));
+ if (debug_infrun)
+ fprintf_unfiltered (gdb_stdlog, "infrun: software single step "
+ "trap for %s\n",
+ target_pid_to_str (ecs->ptid));
+
ecs->random_signal = 0;
/* The call to in_thread_list is necessary because PTIDs sometimes
change when we go from single-threaded to multi-threaded. If
if (!ptid_equal (singlestep_ptid, ecs->ptid)
&& in_thread_list (singlestep_ptid))
{
- thread_hop_needed = 1;
- stepping_past_singlestep_breakpoint = 1;
- saved_singlestep_ptid = singlestep_ptid;
+ /* If the PC of the thread we were trying to single-step
+ has changed, discard this event (which we were going
+ to ignore anyway), and pretend we saw that thread
+ trap. This prevents us continuously moving the
+ single-step breakpoint forward, one instruction at a
+ time. If the PC has changed, then the thread we were
+ trying to single-step has trapped or been signalled,
+ but the event has not been reported to GDB yet.
+
+ There might be some cases where this loses signal
+ information, if a signal has arrived at exactly the
+ same time that the PC changed, but this is the best
+ we can do with the information available. Perhaps we
+ should arrange to report all events for all threads
+ when they stop, or to re-poll the remote looking for
+ this particular thread (i.e. temporarily enable
+ schedlock). */
+ if (read_pc_pid (singlestep_ptid) != singlestep_pc)
+ {
+ if (debug_infrun)
+ fprintf_unfiltered (gdb_stdlog, "infrun: unexpected thread,"
+ " but expected thread advanced also\n");
+
+ /* The current context still belongs to
+ singlestep_ptid. Don't swap here, since that's
+ the context we want to use. Just fudge our
+ state and continue. */
+ ecs->ptid = singlestep_ptid;
+ stop_pc = read_pc_pid (ecs->ptid);
+ }
+ else
+ {
+ if (debug_infrun)
+ fprintf_unfiltered (gdb_stdlog,
+ "infrun: unexpected thread\n");
+
+ thread_hop_needed = 1;
+ stepping_past_singlestep_breakpoint = 1;
+ saved_singlestep_ptid = singlestep_ptid;
+ }
}
}
if (SOFTWARE_SINGLE_STEP_P () && singlestep_breakpoints_inserted_p)
{
/* Pull the single step breakpoints out of the target. */
- SOFTWARE_SINGLE_STEP (0, 0);
+ remove_single_step_breakpoints ();
singlestep_breakpoints_inserted_p = 0;
}
if (deprecated_context_hook)
deprecated_context_hook (pid_to_thread_id (ecs->ptid));
-
- flush_cached_frames ();
}
if (SOFTWARE_SINGLE_STEP_P () && singlestep_breakpoints_inserted_p)
{
/* Pull the single step breakpoints out of the target. */
- SOFTWARE_SINGLE_STEP (0, 0);
+ remove_single_step_breakpoints ();
singlestep_breakpoints_inserted_p = 0;
}
/* It is far more common to need to disable a watchpoint to step
the inferior over it. FIXME. What else might a debug
register or page protection watchpoint scheme need here? */
- if (HAVE_NONSTEPPABLE_WATCHPOINT && STOPPED_BY_WATCHPOINT (ecs->ws))
+ if (gdbarch_have_nonsteppable_watchpoint (current_gdbarch)
+ && STOPPED_BY_WATCHPOINT (ecs->ws))
{
/* At this point, we are stopped at an instruction which has
attempted to write to a piece of memory under control of
stop_print_frame = 1;
ecs->random_signal = 0;
stopped_by_random_signal = 0;
- breakpoints_failed = 0;
if (stop_signal == TARGET_SIGNAL_TRAP
&& trap_expected
code paths as single-step - set a breakpoint at the
signal return address and then, once hit, step off that
breakpoint. */
+
insert_step_resume_breakpoint_at_frame (get_current_frame ());
ecs->step_after_step_resume_breakpoint = 1;
keep_going (ecs);
duration of this command. Then, install a temporary
breakpoint at the target of the jmp_buf. */
if (debug_infrun)
- fprintf_unfiltered (gdb_stdlog, "infrun: BPSTATE_WHAT_SET_LONGJMP_RESUME\n");
+ fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME\n");
disable_longjmp_breakpoint ();
remove_breakpoints ();
breakpoints_inserted = 0;
- if (!GET_LONGJMP_TARGET_P () || !GET_LONGJMP_TARGET (&jmp_buf_pc))
+ if (!gdbarch_get_longjmp_target_p (current_gdbarch)
+ || !gdbarch_get_longjmp_target (current_gdbarch, &jmp_buf_pc))
{
keep_going (ecs);
return;
case BPSTAT_WHAT_CLEAR_LONGJMP_RESUME:
case BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE:
if (debug_infrun)
- fprintf_unfiltered (gdb_stdlog, "infrun: BPSTATE_WHAT_CLEAR_LONGJMP_RESUME\n");
+ fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_CLEAR_LONGJMP_RESUME\n");
remove_breakpoints ();
breakpoints_inserted = 0;
disable_longjmp_breakpoint ();
case BPSTAT_WHAT_SINGLE:
if (debug_infrun)
- fprintf_unfiltered (gdb_stdlog, "infrun: BPSTATE_WHAT_SINGLE\n");
+ fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_SINGLE\n");
if (breakpoints_inserted)
- {
- remove_breakpoints ();
- }
+ remove_breakpoints ();
breakpoints_inserted = 0;
ecs->another_trap = 1;
/* Still need to check other stuff, at least the case
case BPSTAT_WHAT_STOP_NOISY:
if (debug_infrun)
- fprintf_unfiltered (gdb_stdlog, "infrun: BPSTATE_WHAT_STOP_NOISY\n");
+ fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_STOP_NOISY\n");
stop_print_frame = 1;
/* We are about to nuke the step_resume_breakpointt via the
case BPSTAT_WHAT_STOP_SILENT:
if (debug_infrun)
- fprintf_unfiltered (gdb_stdlog, "infrun: BPSTATE_WHAT_STOP_SILENT\n");
+ fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_STOP_SILENT\n");
stop_print_frame = 0;
/* We are about to nuke the step_resume_breakpoin via the
the one deleted is the one currently stopped at. MVS */
if (debug_infrun)
- fprintf_unfiltered (gdb_stdlog, "infrun: BPSTATE_WHAT_STEP_RESUME\n");
+ fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_STEP_RESUME\n");
if (step_resume_breakpoint == NULL)
{
}
break;
- case BPSTAT_WHAT_THROUGH_SIGTRAMP:
- if (debug_infrun)
- fprintf_unfiltered (gdb_stdlog, "infrun: BPSTATE_WHAT_THROUGH_SIGTRAMP\n");
- /* If were waiting for a trap, hitting the step_resume_break
- doesn't count as getting it. */
- if (trap_expected)
- ecs->another_trap = 1;
- break;
-
case BPSTAT_WHAT_CHECK_SHLIBS:
case BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK:
{
if (debug_infrun)
- fprintf_unfiltered (gdb_stdlog, "infrun: BPSTATE_WHAT_CHECK_SHLIBS\n");
+ fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_CHECK_SHLIBS\n");
/* Remove breakpoints, we eventually want to step over the
shlib event breakpoint, and SOLIB_ADD might adjust
breakpoint addresses via breakpoint_re_set. */
if (step_resume_breakpoint)
{
if (debug_infrun)
- fprintf_unfiltered (gdb_stdlog, "infrun: step-resume breakpoint\n");
+ fprintf_unfiltered (gdb_stdlog,
+ "infrun: step-resume breakpoint is inserted\n");
/* Having a step-resume breakpoint overrides anything
else having to do with stepping commands until
return;
}
- if (frame_id_eq (frame_unwind_id (get_current_frame ()), step_frame_id))
+ /* Check for subroutine calls. The check for the current frame
+ equalling the step ID is not necessary - the check of the
+ previous frame's ID is sufficient - but it is a common case and
+ cheaper than checking the previous frame's ID.
+
+ NOTE: frame_id_eq will never report two invalid frame IDs as
+ being equal, so to get into this block, both the current and
+ previous frame must have valid frame IDs. */
+ if (!frame_id_eq (get_frame_id (get_current_frame ()), step_frame_id)
+ && frame_id_eq (frame_unwind_id (get_current_frame ()), step_frame_id))
{
- /* It's a subroutine call. */
CORE_ADDR real_stop_pc;
if (debug_infrun)
/* We're doing a "next", set a breakpoint at callee's return
address (the address at which the caller will
resume). */
- insert_step_resume_breakpoint_at_frame (get_prev_frame (get_current_frame ()));
+ insert_step_resume_breakpoint_at_caller (get_current_frame ());
keep_going (ecs);
return;
}
/* Set a breakpoint at callee's return address (the address at
which the caller will resume). */
- insert_step_resume_breakpoint_at_frame (get_prev_frame (get_current_frame ()));
+ insert_step_resume_breakpoint_at_caller (get_current_frame ());
keep_going (ecs);
return;
}
and no line number corresponding to the address where the
inferior stopped). Since we want to skip this kind of code,
we keep going until the inferior returns from this
- function. */
- if (step_stop_if_no_debug)
+ function - unless the user has asked us not to (via
+ set step-mode) or we no longer know how to get back
+ to the call site. */
+ if (step_stop_if_no_debug
+ || !frame_id_p (frame_unwind_id (get_current_frame ())))
{
/* If we have no line number and the step-stop-if-no-debug
is set, we stop the step so that the user has a chance to
{
/* Set a breakpoint at callee's return address (the address
at which the caller will resume). */
- insert_step_resume_breakpoint_at_frame (get_prev_frame (get_current_frame ()));
+ insert_step_resume_breakpoint_at_caller (get_current_frame ());
keep_going (ecs);
return;
}
keep_going (ecs);
}
-/* Insert a "step resume breakpoint" at SR_SAL with frame ID SR_ID.
+/* Insert a "step-resume breakpoint" at SR_SAL with frame ID SR_ID.
This is used to both functions and to skip over code. */
static void
thread, so we should never be setting a new
step_resume_breakpoint when one is already active. */
gdb_assert (step_resume_breakpoint == NULL);
+
+ if (debug_infrun)
+ fprintf_unfiltered (gdb_stdlog,
+ "infrun: inserting step-resume breakpoint at 0x%s\n",
+ paddr_nz (sr_sal.pc));
+
step_resume_breakpoint = set_momentary_breakpoint (sr_sal, sr_id,
bp_step_resume);
if (breakpoints_inserted)
insert_breakpoints ();
}
-
-/* Insert a "step resume breakpoint" at RETURN_FRAME.pc. This is used
- to skip a function (next, skip-no-debug) or signal. It's assumed
- that the function/signal handler being skipped eventually returns
- to the breakpoint inserted at RETURN_FRAME.pc.
- For the skip-function case, the function may have been reached by
- either single stepping a call / return / signal-return instruction,
- or by hitting a breakpoint. In all cases, the RETURN_FRAME belongs
- to the skip-function's caller.
+/* Insert a "step-resume breakpoint" at RETURN_FRAME.pc. This is used
+ to skip a potential signal handler.
- For the signals case, this is called with the interrupted
- function's frame. The signal handler, when it returns, will resume
- the interrupted function at RETURN_FRAME.pc. */
+ This is called with the interrupted function's frame. The signal
+ handler, when it returns, will resume the interrupted function at
+ RETURN_FRAME.pc. */
static void
insert_step_resume_breakpoint_at_frame (struct frame_info *return_frame)
init_sal (&sr_sal); /* initialize to zeros */
- sr_sal.pc = ADDR_BITS_REMOVE (get_frame_pc (return_frame));
+ sr_sal.pc = gdbarch_addr_bits_remove
+ (current_gdbarch, get_frame_pc (return_frame));
sr_sal.section = find_pc_overlay (sr_sal.pc);
insert_step_resume_breakpoint_at_sal (sr_sal, get_frame_id (return_frame));
}
+/* Similar to insert_step_resume_breakpoint_at_frame, except
+ but a breakpoint at the previous frame's PC. This is used to
+ skip a function after stepping into it (for "next" or if the called
+ function has no debugging information).
+
+ The current function has almost always been reached by single
+ stepping a call or return instruction. NEXT_FRAME belongs to the
+ current function, and the breakpoint will be set at the caller's
+ resume address.
+
+ This is a separate function rather than reusing
+ insert_step_resume_breakpoint_at_frame in order to avoid
+ get_prev_frame, which may stop prematurely (see the implementation
+ of frame_unwind_id for an example). */
+
+static void
+insert_step_resume_breakpoint_at_caller (struct frame_info *next_frame)
+{
+ struct symtab_and_line sr_sal;
+
+ /* We shouldn't have gotten here if we don't know where the call site
+ is. */
+ gdb_assert (frame_id_p (frame_unwind_id (next_frame)));
+
+ init_sal (&sr_sal); /* initialize to zeros */
+
+ sr_sal.pc = gdbarch_addr_bits_remove
+ (current_gdbarch, frame_pc_unwind (next_frame));
+ sr_sal.section = find_pc_overlay (sr_sal.pc);
+
+ insert_step_resume_breakpoint_at_sal (sr_sal, frame_unwind_id (next_frame));
+}
+
static void
stop_stepping (struct execution_control_state *ecs)
{
if (!breakpoints_inserted && !ecs->another_trap)
{
- breakpoints_failed = insert_breakpoints ();
- if (breakpoints_failed)
+ /* Stop stepping when inserting breakpoints
+ has failed. */
+ if (insert_breakpoints () != 0)
{
stop_stepping (ecs);
return;
{
switch (stop_reason)
{
- case STOP_UNKNOWN:
- /* We don't deal with these cases from handle_inferior_event()
- yet. */
- break;
case END_STEPPING_RANGE:
/* We are done with a step/next/si/ni command. */
/* For now print nothing. */
(uiout, "reason",
async_reason_lookup (EXEC_ASYNC_END_STEPPING_RANGE));
break;
- case BREAKPOINT_HIT:
- /* We found a breakpoint. */
- /* For now print nothing. */
- break;
case SIGNAL_EXITED:
/* The inferior was terminated by a signal. */
annotate_signalled ();
/* NOTE drow/2004-01-17: Is this still necessary? */
/* Make sure that the current_frame's pc is correct. This
is a correction for setting up the frame info before doing
- DECR_PC_AFTER_BREAK */
+ gdbarch_decr_pc_after_break */
if (target_has_execution)
/* FIXME: cagney/2002-12-06: Has the PC changed? Thanks to
- DECR_PC_AFTER_BREAK, the program counter can change. Ask the
+ gdbarch_decr_pc_after_break, the program counter can change. Ask the
frame code to check for this and sort out any resultant mess.
- DECR_PC_AFTER_BREAK needs to just go away. */
+ gdbarch_decr_pc_after_break needs to just go away. */
deprecated_update_frame_pc_hack (get_current_frame (), read_pc ());
if (target_has_execution && breakpoints_inserted)
bpstat_print() contains the logic deciding in detail
what to print, based on the event(s) that just occurred. */
- if (stop_print_frame && deprecated_selected_frame)
+ if (stop_print_frame)
{
int bpstat_ret;
int source_flag;
default:
internal_error (__FILE__, __LINE__, _("Unknown value."));
}
- /* For mi, have the same behavior every time we stop:
- print everything but the source line. */
- if (ui_out_is_mi_like_p (uiout))
- source_flag = LOC_AND_ADDRESS;
if (ui_out_is_mi_like_p (uiout))
ui_out_field_int (uiout, "thread-id",
inf_status->registers = regcache_dup (current_regcache);
- inf_status->selected_frame_id = get_frame_id (deprecated_selected_frame);
+ inf_status->selected_frame_id = get_frame_id (get_selected_frame (NULL));
return inf_status;
}