From 1f3e37e057e876b37db49dbd8ed5ca22c33f6772 Mon Sep 17 00:00:00 2001 From: Bruno Larsen Date: Wed, 25 May 2022 15:02:47 -0300 Subject: gdb/reverse: Fix stepping over recursive functions Currently, when using GDB to do reverse debugging, if we try to use the command "reverse next" to skip a recursive function, instead of skipping all of the recursive calls and stopping in the previous line, we stop at the second to last recursive call, and need to manually step backwards until we leave the first call. This is well documented in PR gdb/16678. This bug happens because when GDB notices that a reverse step has entered into a function, GDB will add a step_resume_breakpoint at the start of the function, then single step out of the prologue once that breakpoint is hit. The problem was happening because GDB wouldn't give that step_resume_breakpoint a frame-id, so the first time the breakpoint was hit, the inferior would be stopped. This is fixed by giving the current frame-id to the breakpoint. This commit also changes gdb.reverse/step-reverse.c to contain a recursive function and attempt to both, skip it altogether, and to skip the second call from inside the first call, as this setup broke a previous version of the patch. --- gdb/infrun.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gdb/infrun.c') diff --git a/gdb/infrun.c b/gdb/infrun.c index 9a9f42f..fcc4d80 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -7130,7 +7130,7 @@ process_event_stop_test (struct execution_control_state *ecs) sr_sal.pc = ecs->stop_func_start; sr_sal.pspace = get_frame_program_space (frame); insert_step_resume_breakpoint_at_sal (gdbarch, - sr_sal, null_frame_id); + sr_sal, get_stack_frame_id (frame)); } } else -- cgit v1.1