aboutsummaryrefslogtreecommitdiff
path: root/gdb/infcmd.c
diff options
context:
space:
mode:
authorCarl Love <cel@us.ibm.com>2022-12-19 12:48:54 -0500
committerCarl Love <cel@us.ibm.com>2023-01-17 11:39:32 -0500
commitb22548ddb30bfb167708e82d3bb932461c1b703a (patch)
treea3f90f828ef7a01e547c6f10e94e33bf9990dc6c /gdb/infcmd.c
parent4e2a80ba606fdb48018d06b510ff7873a10e43ae (diff)
downloadgdb-b22548ddb30bfb167708e82d3bb932461c1b703a.zip
gdb-b22548ddb30bfb167708e82d3bb932461c1b703a.tar.gz
gdb-b22548ddb30bfb167708e82d3bb932461c1b703a.tar.bz2
X86: reverse-finish fix
PR record/29927 - reverse-finish requires two reverse next instructions to reach previous source line Currently on X86, when executing the finish command in reverse, gdb does a single step from the first instruction in the callee to get back to the caller. GDB stops on the last instruction in the source code line where the call was made. When stopped at the last instruction of the source code line, a reverse next or step command will stop at the first instruction of the same source code line thus requiring two step/next commands to reach the previous source code line. It should only require one step/next command to reach the previous source code line. By contrast, a reverse next or step command from the first line in a function stops at the first instruction in the source code line where the call was made. This patch fixes the reverse finish command so it will stop at the first instruction of the source line where the function call was made. The behavior on X86 for the reverse-finish command now matches doing a reverse-next from the beginning of the function. The proceed_to_finish flag in struct thread_control_state is no longer used. This patch removes the declaration, initialization and setting of the flag. This patch requires a number of regression tests to be updated. Test gdb.mi/mi-reverse.exp no longer needs to execute two steps to get to the previous line. The gdb output for tests gdb.reverse/until-precsave.exp and gdb.reverse/until-reverse.exp changed slightly. The expected result in tests gdb.reverse/amd64-failcall-reverse.exp and gdb.reverse/singlejmp-reverse.exp are updated to the correct expected result. This patch adds a new test gdb.reverse/finish-reverse-next.exp to test the reverse-finish command when returning from the entry point and from the body of the function. The step_until proceedure in test gdb.reverse/step-indirect-call-thunk.exp was moved to lib/gdb.exp and renamed cmd_until. The patch has been tested on X86 and PowerPC to verify no additional regression failures occured. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29927
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r--gdb/infcmd.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 7d5ec77..5fcd2ab 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1719,19 +1719,10 @@ finish_backward (struct finish_command_fsm *sm)
sal = find_pc_line (func_addr, 0);
- tp->control.proceed_to_finish = 1;
- /* Special case: if we're sitting at the function entry point,
- then all we need to do is take a reverse singlestep. We
- don't need to set a breakpoint, and indeed it would do us
- no good to do so.
-
- Note that this can only happen at frame #0, since there's
- no way that a function up the stack can have a return address
- that's equal to its entry point. */
+ frame_info_ptr frame = get_selected_frame (nullptr);
if (sal.pc != pc)
{
- frame_info_ptr frame = get_selected_frame (nullptr);
struct gdbarch *gdbarch = get_frame_arch (frame);
/* Set a step-resume at the function's entry point. Once that's
@@ -1741,16 +1732,22 @@ finish_backward (struct finish_command_fsm *sm)
sr_sal.pspace = get_frame_program_space (frame);
insert_step_resume_breakpoint_at_sal (gdbarch,
sr_sal, null_frame_id);
-
- proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
}
else
{
- /* We're almost there -- we just need to back up by one more
- single-step. */
- tp->control.step_range_start = tp->control.step_range_end = 1;
- proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
+ /* We are exactly at the function entry point. Note that this
+ can only happen at frame #0.
+
+ When setting a step range, need to call set_step_info
+ to setup the current_line/symtab fields as well. */
+ set_step_info (tp, frame, find_pc_line (pc, 0));
+
+ /* Return using a step range so we will keep stepping back
+ to the first instruction in the source code line. */
+ tp->control.step_range_start = sal.pc;
+ tp->control.step_range_end = sal.pc;
}
+ proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
}
/* finish_forward -- helper function for finish_command. FRAME is the
@@ -1776,9 +1773,6 @@ finish_forward (struct finish_command_fsm *sm, frame_info_ptr frame)
set_longjmp_breakpoint (tp, frame_id);
- /* We want to print return value, please... */
- tp->control.proceed_to_finish = 1;
-
proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
}