+2011-05-26 Pedro Alves <pedro@codesourcery.com>
+
+ * breakpoint.h (enum bptype) <bp_hp_step_resume>: New.
+ (enum bpstat_what_main_action): Move BPSTAT_WHAT_STEP_RESUME
+ before BPSTAT_WHAT_STOP_SILENT. Add BPSTAT_WHAT_HP_STEP_RESUME
+ at the end.
+ * breakpoint.c (update_breakpoints_after_exec): Also delete hp
+ step-resume breakpoints.
+ (print_it_typical): Handle bp_hp_step_resume.
+ (bpstat_what): Ditto.
+ (bptype_string): Ditto.
+ (print_one_breakpoint_location): Ditto.
+ (allocate_bp_location): Ditto.
+ (mention): Ditto.
+ (breakpoint_re_set_one): Ditto.
+ * infrun.c (handle_inferior_event): Adjust. Split
+ BPSTAT_WHAT_STEP_RESUME handling in BPSTAT_WHAT_STEP_RESUME and
+ BPSTAT_WHAT_HP_STEP_RESUME.
+ (insert_step_resume_breakpoint_at_sal): Rename to ...
+ (insert_step_resume_breakpoint_at_sal_1): ... this. Add bptype
+ parameter. Handle it.
+ (insert_step_resume_breakpoint_at_sal): Reimplement on top of
+ insert_step_resume_breakpoint_at_sal_1.
+ (insert_step_resume_breakpoint_at_frame): Rename to ...
+ (insert_hp_step_resume_breakpoint_at_frame): ... this. Adjust to
+ set a high-priority step-resume breakpoint.
+ (insert_step_resume_breakpoint_at_frame): Adjust comment.
+ (insert_step_resume_breakpoint_at_caller): Ditto.
+
2011-05-26 Pedro Alves <pedro@codesourcery.com>
* breakpoint.c (iterate_over_related_breakpoints): New.
}
/* Step-resume breakpoints are meaningless after an exec(). */
- if (b->type == bp_step_resume)
+ if (b->type == bp_step_resume || b->type == bp_hp_step_resume)
{
delete_breakpoint (b);
continue;
case bp_exception:
case bp_exception_resume:
case bp_step_resume:
+ case bp_hp_step_resume:
case bp_watchpoint_scope:
case bp_call_dummy:
case bp_std_terminate:
this_action = BPSTAT_WHAT_SINGLE;
}
break;
+ case bp_hp_step_resume:
+ if (bs->stop)
+ this_action = BPSTAT_WHAT_HP_STEP_RESUME;
+ else
+ {
+ /* It is for the wrong frame. */
+ this_action = BPSTAT_WHAT_SINGLE;
+ }
+ break;
case bp_watchpoint_scope:
case bp_thread_event:
case bp_overlay_event:
{bp_exception, "exception"},
{bp_exception_resume, "exception resume"},
{bp_step_resume, "step resume"},
+ {bp_hp_step_resume, "high-priority step resume"},
{bp_watchpoint_scope, "watchpoint scope"},
{bp_call_dummy, "call dummy"},
{bp_std_terminate, "std::terminate"},
case bp_exception:
case bp_exception_resume:
case bp_step_resume:
+ case bp_hp_step_resume:
case bp_watchpoint_scope:
case bp_call_dummy:
case bp_std_terminate:
case bp_exception:
case bp_exception_resume:
case bp_step_resume:
+ case bp_hp_step_resume:
case bp_watchpoint_scope:
case bp_call_dummy:
case bp_std_terminate:
case bp_exception:
case bp_exception_resume:
case bp_step_resume:
+ case bp_hp_step_resume:
case bp_call_dummy:
case bp_std_terminate:
case bp_watchpoint_scope:
case bp_call_dummy:
case bp_std_terminate:
case bp_step_resume:
+ case bp_hp_step_resume:
case bp_longjmp:
case bp_longjmp_resume:
case bp_exception:
bp_exception_resume,
/* Used by wait_for_inferior for stepping over subroutine calls,
- for stepping over signal handlers, and for skipping
- prologues. */
+ and for skipping prologues. */
bp_step_resume,
+ /* Used by wait_for_inferior for stepping over signal
+ handlers. */
+ bp_hp_step_resume,
+
/* Used to detect when a watchpoint expression has gone out of
scope. These breakpoints are usually not visible to the user.
BPSTAT_WHAT_KEEP_CHECKING. */
BPSTAT_WHAT_CLEAR_LONGJMP_RESUME,
+ /* Clear step resume breakpoint, and keep checking. */
+ BPSTAT_WHAT_STEP_RESUME,
+
/* Rather than distinguish between noisy and silent stops here, it
might be cleaner to have bpstat_print make that decision (also
taking into account stop_print_frame and source_only). But the
/* Stop and print. */
BPSTAT_WHAT_STOP_NOISY,
- /* Clear step resume breakpoint, and keep checking. */
- BPSTAT_WHAT_STEP_RESUME,
+ /* Clear step resume breakpoint, and keep checking. High-priority
+ step-resume breakpoints are used when even if there's a user
+ breakpoint at the current PC when we set the step-resume
+ breakpoint, we don't want to re-handle any breakpoint other
+ than the step-resume when it's hit; instead we want to move
+ past the breakpoint. This is used in the case of skipping
+ signal handlers. */
+ BPSTAT_WHAT_HP_STEP_RESUME,
};
/* An enum indicating the kind of "stack dummy" stop. This is a bit
void nullify_last_target_wait_ptid (void);
-static void insert_step_resume_breakpoint_at_frame (struct frame_info *);
+static void insert_hp_step_resume_breakpoint_at_frame (struct frame_info *);
static void insert_step_resume_breakpoint_at_caller (struct frame_info *);
original breakpoint is hit. */
if (tp->control.step_resume_breakpoint == NULL)
{
- insert_step_resume_breakpoint_at_frame (get_current_frame ());
+ insert_hp_step_resume_breakpoint_at_frame (get_current_frame ());
tp->step_after_step_resume_breakpoint = 1;
}
"infrun: signal arrived while stepping over "
"breakpoint\n");
- insert_step_resume_breakpoint_at_frame (frame);
+ insert_hp_step_resume_breakpoint_at_frame (frame);
ecs->event_thread->step_after_step_resume_breakpoint = 1;
/* Reset trap_expected to ensure breakpoints are re-inserted. */
ecs->event_thread->control.trap_expected = 0;
"infrun: signal may take us out of "
"single-step range\n");
- insert_step_resume_breakpoint_at_frame (frame);
+ insert_hp_step_resume_breakpoint_at_frame (frame);
/* Reset trap_expected to ensure breakpoints are re-inserted. */
ecs->event_thread->control.trap_expected = 0;
keep_going (ecs);
where we are stepping and step out of the right range. */
break;
+ case BPSTAT_WHAT_STEP_RESUME:
+ if (debug_infrun)
+ fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_STEP_RESUME\n");
+
+ delete_step_resume_breakpoint (ecs->event_thread);
+ if (stop_pc == ecs->stop_func_start
+ && execution_direction == EXEC_REVERSE)
+ {
+ /* We are stepping over a function call in reverse, and
+ just hit the step-resume breakpoint at the start
+ address of the function. Go back to single-stepping,
+ which should take us back to the function call. */
+ ecs->event_thread->stepping_over_breakpoint = 1;
+ keep_going (ecs);
+ return;
+ }
+ break;
+
case BPSTAT_WHAT_STOP_NOISY:
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_STOP_NOISY\n");
stop_stepping (ecs);
return;
- case BPSTAT_WHAT_STEP_RESUME:
+ case BPSTAT_WHAT_HP_STEP_RESUME:
if (debug_infrun)
- fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_STEP_RESUME\n");
+ fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_HP_STEP_RESUME\n");
delete_step_resume_breakpoint (ecs->event_thread);
if (ecs->event_thread->step_after_step_resume_breakpoint)
keep_going (ecs);
return;
}
- if (stop_pc == ecs->stop_func_start
- && execution_direction == EXEC_REVERSE)
- {
- /* We are stepping over a function call in reverse, and
- just hit the step-resume breakpoint at the start
- address of the function. Go back to single-stepping,
- which should take us back to the function call. */
- ecs->event_thread->stepping_over_breakpoint = 1;
- keep_going (ecs);
- return;
- }
break;
case BPSTAT_WHAT_KEEP_CHECKING:
This is used to both functions and to skip over code. */
static void
-insert_step_resume_breakpoint_at_sal (struct gdbarch *gdbarch,
- struct symtab_and_line sr_sal,
- struct frame_id sr_id)
+insert_step_resume_breakpoint_at_sal_1 (struct gdbarch *gdbarch,
+ struct symtab_and_line sr_sal,
+ struct frame_id sr_id,
+ enum bptype sr_type)
{
/* There should never be more than one step-resume or longjmp-resume
breakpoint per thread, so we should never be setting a new
step_resume_breakpoint when one is already active. */
gdb_assert (inferior_thread ()->control.step_resume_breakpoint == NULL);
+ gdb_assert (sr_type == bp_step_resume || sr_type == bp_hp_step_resume);
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog,
paddress (gdbarch, sr_sal.pc));
inferior_thread ()->control.step_resume_breakpoint
- = set_momentary_breakpoint (gdbarch, sr_sal, sr_id, bp_step_resume);
+ = set_momentary_breakpoint (gdbarch, sr_sal, sr_id, sr_type);
+}
+
+static void
+insert_step_resume_breakpoint_at_sal (struct gdbarch *gdbarch,
+ struct symtab_and_line sr_sal,
+ struct frame_id sr_id)
+{
+ insert_step_resume_breakpoint_at_sal_1 (gdbarch,
+ sr_sal, sr_id,
+ bp_step_resume);
}
-/* Insert a "step-resume breakpoint" at RETURN_FRAME.pc. This is used
- to skip a potential signal handler.
+/* Insert a "high-priority step-resume breakpoint" at RETURN_FRAME.pc.
+ This is used to skip a potential signal handler.
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)
+insert_hp_step_resume_breakpoint_at_frame (struct frame_info *return_frame)
{
struct symtab_and_line sr_sal;
struct gdbarch *gdbarch;
sr_sal.section = find_pc_overlay (sr_sal.pc);
sr_sal.pspace = get_frame_program_space (return_frame);
- insert_step_resume_breakpoint_at_sal (gdbarch, sr_sal,
- get_stack_frame_id (return_frame));
+ insert_step_resume_breakpoint_at_sal_1 (gdbarch, sr_sal,
+ get_stack_frame_id (return_frame),
+ bp_hp_step_resume);
}
-/* 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).
+/* Insert a "step-resume 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
resume address.
This is a separate function rather than reusing
- insert_step_resume_breakpoint_at_frame in order to avoid
+ insert_hp_step_resume_breakpoint_at_frame in order to avoid
get_prev_frame, which may stop prematurely (see the implementation
of frame_unwind_caller_id for an example). */
+2011-05-26 Pedro Alves <pedro@codesourcery.com>
+
+ * gdb.reverse/next-reverse-bkpt-over-sr.exp: New test.
+
2011-05-24 Keith Seitz <keiths@redhat.com>
PR breakpoint/12803
--- /dev/null
+# Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+# This file is part of the GDB testsuite. It tests reverse stepping.
+# Lots of code borrowed from "step-test.exp".
+
+#
+# reverse-next over a function call sets a step-resume breakpoint at
+# callee's entry point, runs to it, and then does an extra single-step
+# to get at the callee's caller. Test that a user breakpoint set at
+# the same location as the step-resume breakpoint isn't ignored.
+#
+
+if ![target_info exists gdb,can_reverse] {
+ return
+}
+
+set testfile "next-reverse-bkpt-over-sr"
+set srcfile step-reverse.c
+
+if { [prepare_for_testing $testfile.exp $testfile $srcfile] } {
+ return -1
+}
+
+if ![runto_main] then {
+ fail "Can't run to main"
+ return 0
+}
+
+if [target_info exists gdb,use_precord] {
+ # Activate process record/replay
+ gdb_test_no_output "record" "Turn on process record"
+}
+
+set lineno [gdb_get_line_number "STEP INTO THIS CALL"]
+gdb_test "advance $lineno" ".*STEP INTO THIS CALL.*" "get past callee call"
+
+gdb_test "b \*callee" "" "set breakpoint at callee's entry"
+
+gdb_test "reverse-next" \
+ "Breakpoint.*, callee.*ENTER CALLEE.*" \
+ "reverse-next over call trips user breakpoint at function entry"
+
+gdb_test "up" \
+ ".*NEXT OVER THIS CALL.*" \
+ "stopped at the right callee call"