From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH v4 4/4] gdb: use get_current_frame consistently in print_stop_location
Date: Fri, 10 Apr 2026 12:12:52 +0200 [thread overview]
Message-ID: <20260410101252.1805303-5-tdevries@suse.de> (raw)
In-Reply-To: <20260410101252.1805303-1-tdevries@suse.de>
From: Andrew Burgess <aburgess@redhat.com>
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.
Since bpstat_print selects the frame to print (which usually is the current
frame, but not always), the correct frame to use is the selected frame after
the bpstat_print call.
Assign the selected frame to a variable print_frame, and use it throughout the
function.
There should be no user visible changes after this commit.
Co-Authored-By: Tom de Vries <tdevries@suse.de>
---
gdb/infrun.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index dea2a2cbd48..19836c4d89e 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -9349,7 +9349,12 @@ print_stop_location (const target_waitstatus &ws)
struct thread_info *tp = inferior_thread ();
bpstat_ret = bpstat_print (tp->control.stop_bpstat, ws.kind ());
- switch (bpstat_ret)
+ /* Function bpstat_print selects the frame to print. Typically, that is the
+ stop frame, in other words get_current_frame (). But bpstat_print may
+ select a different frame, see for instance ada_catchpoint::print_it. */
+ frame_info_ptr print_frame = get_selected_frame (nullptr);
+
+ switch (bpstat_ret)
{
case PRINT_UNKNOWN:
/* FIXME: cagney/2002-12-01: Given that a frame ID does (or
@@ -9357,10 +9362,10 @@ print_stop_location (const target_waitstatus &ws)
that when doing a frame comparison. */
if (tp->control.stop_step
&& (tp->control.step_frame_id
- == get_frame_id (get_current_frame ()))
- && tp->control.in_step_start_function (get_current_frame ()))
+ == get_frame_id (print_frame))
+ && tp->control.in_step_start_function (print_frame))
{
- symtab_and_line sal = find_frame_sal (get_selected_frame (nullptr));
+ symtab_and_line sal = find_frame_sal (print_frame);
if (sal.symtab != tp->current_symtab)
{
/* Finished step in same frame but into different file, print
@@ -9403,7 +9408,7 @@ print_stop_location (const target_waitstatus &ws)
LOCATION: Print only location
SRC_AND_LOC: Print location and source line. */
if (do_frame_printing)
- print_stack_frame (get_selected_frame (nullptr), 0, source_flag, 1);
+ print_stack_frame (print_frame, 0, source_flag, 1);
}
/* See `print_stop_event` in infrun.h. */
--
2.51.0
next prev parent reply other threads:[~2026-04-10 10:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-10 10:12 [PATCH v4 0/4] [gdb] Fix missing print frame when stepping out of function Tom de Vries
2026-04-10 10:12 ` [PATCH v4 1/4] [gdb/testsuite] Extend gdb.opt/inline-cmds.exp Tom de Vries
2026-04-10 10:12 ` [PATCH v4 2/4] [gdb] Add thread_control_state::step_start_function methods Tom de Vries
2026-04-10 10:12 ` [PATCH v4 3/4] gdb: fix missing print frame when stepping out of function Tom de Vries
2026-04-10 10:12 ` Tom de Vries [this message]
2026-04-14 16:32 ` [PATCH v4 0/4] [gdb] Fix " Andrew Burgess
2026-04-14 20:41 ` Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260410101252.1805303-5-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox