[PATCH 1/2] gdb: use get_current_frame consistently in print_stop_location

Andrew Burgess
2026-04-05T10:12:46Z

In print_stop_location, in the PRINT_UNKNOWN case we currently use a
strange mix of get_current_frame and get_selected_frame. This works
fine because at the point print_stop_location is called the selected
frame will always be the current frame, but calling these two
different functions is confusing, at least for me.

As we are stopping, and deciding whether to print information about
the frame, it makes sense, I think, to make the choice based on the
current frame, and so let's call get_current_frame once, and then use
that result throughout the decision making process.

There should be no user visible changes after this commit.
---
gdb/infrun.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index 6ca2a505299..aa1c3553131 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -9362,13 +9362,13 @@ print_stop_location (const target_waitstatus &ws)
/* FIXME: cagney/2002-12-01: Given that a frame ID does (or
should) carry around the function and does (or should) use
that when doing a frame comparison. */
- if (tp->control.stop_step
- && (tp->control.step_frame_id
- == get_frame_id (get_current_frame ()))
+ if (frame_info_ptr frame = get_current_frame ();
+ tp->control.stop_step
+ && (tp->control.step_frame_id == get_frame_id (frame))
&& (tp->control.step_start_function
== find_symbol_for_pc (tp->stop_pc ())))
{
- symtab_and_line sal = find_frame_sal (get_selected_frame (nullptr));
+ symtab_and_line sal = find_frame_sal (frame);
if (sal.symtab != tp->current_symtab)
{
/* Finished step in same frame but into different file, print
--
2.25.4