From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [RFC v2 2/3] [gdb] Add thread_control_state::step_start_function methods
Date: Tue, 31 Mar 2026 15:23:41 +0200 [thread overview]
Message-ID: <20260331132342.1050954-3-tdevries@suse.de> (raw)
In-Reply-To: <20260331132342.1050954-1-tdevries@suse.de>
Factor out all uses of thread_control_state::step_start_function into
methods, and make the field private.
Also add a shorthand thread_info::in_step_start_function, to avoid long lines:
...
-ecs->event_thread->control.in_step_start_function (ecs->event_thread->stop_pc ())
+ecs->event_thread->in_step_start_function ()
...
Tested on x86_64-linux.
---
gdb/gdbthread.h | 41 +++++++++++++++++++++++++++++++++++++++--
gdb/infcmd.c | 2 +-
gdb/infrun.c | 12 +++++-------
3 files changed, 45 insertions(+), 10 deletions(-)
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index 68d7aebbbf7..c0a828409a4 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -126,8 +126,35 @@ struct thread_control_state
CORE_ADDR step_range_start = 0; /* Inclusive */
CORE_ADDR step_range_end = 0; /* Exclusive */
- /* Function the thread was in as of last it started stepping. */
- struct symbol *step_start_function = nullptr;
+ /* Set step_start_function according to PC. */
+ void set_step_start_function (CORE_ADDR pc)
+ {
+ m_step_start_function = find_symbol_for_pc (pc);
+ }
+
+ /* Reset step_start_function. */
+ void reset_step_start_function ()
+ {
+ m_step_start_function = nullptr;
+ }
+
+ /* Return true if PC is in step_start_function. */
+ bool in_step_start_function (CORE_ADDR pc)
+ {
+ return m_step_start_function == find_symbol_for_pc (pc);
+ }
+
+ /* Return true if step_start_function is set. */
+ bool step_start_function_p ()
+ {
+ return m_step_start_function != nullptr;
+ }
+
+ /* Return step_start_function. */
+ struct symbol *step_start_function ()
+ {
+ return m_step_start_function;
+ }
/* If GDB issues a target step request, and this is nonzero, the
target should single-step this thread once, and then continue
@@ -176,6 +203,10 @@ struct thread_control_state
/* True if the thread is evaluating a BP condition. */
bool in_cond_eval = false;
+
+private:
+ /* Function the thread was in as of last it started stepping. */
+ struct symbol *m_step_start_function = nullptr;
};
/* Inferior thread specific part of `struct infcall_suspend_state'. */
@@ -348,6 +379,12 @@ class thread_info : public intrusive_list_node<thread_info>,
See `struct thread_control_state'. */
thread_control_state control;
+ /* Return true if stopped in step_start_function. */
+ bool in_step_start_function ()
+ {
+ return stop_pc_p () && control.in_step_start_function (stop_pc ());
+ }
+
/* Save M_SUSPEND to SUSPEND. */
void save_suspend_to (thread_suspend_state &suspend) const
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 2e1a4d592c1..91fde405d7a 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -899,7 +899,7 @@ set_step_frame (thread_info *tp)
set_step_info (tp, frame, sal);
CORE_ADDR pc = get_frame_pc (frame);
- tp->control.step_start_function = find_symbol_for_pc (pc);
+ tp->control.set_step_start_function (pc);
}
/* Step until outside of current statement. */
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 9864b5bbdec..d0378d9f7bc 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3086,7 +3086,7 @@ clear_proceed_status_thread (struct thread_info *tp)
tp->control.step_frame_id = null_frame_id;
tp->control.step_stack_frame_id = null_frame_id;
tp->control.step_over_calls = STEP_OVER_UNDEBUGGABLE;
- tp->control.step_start_function = nullptr;
+ tp->control.reset_step_start_function ();
tp->stop_requested = false;
tp->control.stop_step = 0;
@@ -7738,9 +7738,9 @@ process_event_stop_test (struct execution_control_state *ecs)
if (execution_direction != EXEC_REVERSE
&& ecs->event_thread->control.step_over_calls == STEP_OVER_UNDEBUGGABLE
&& in_solib_dynsym_resolve_code (ecs->event_thread->stop_pc ())
- && (ecs->event_thread->control.step_start_function == nullptr
+ && (!ecs->event_thread->control.step_start_function_p ()
|| !in_solib_dynsym_resolve_code (
- ecs->event_thread->control.step_start_function->value_block ()
+ ecs->event_thread->control.step_start_function ()->value_block ()
->entry_pc ())))
{
CORE_ADDR pc_after_resolver =
@@ -7864,8 +7864,7 @@ process_event_stop_test (struct execution_control_state *ecs)
== ecs->event_thread->control.step_stack_frame_id)
&& ((ecs->event_thread->control.step_stack_frame_id
!= outer_frame_id)
- || (ecs->event_thread->control.step_start_function
- != find_symbol_for_pc (ecs->event_thread->stop_pc ())))))
+ || !ecs->event_thread->in_step_start_function ())))
{
CORE_ADDR stop_pc = ecs->event_thread->stop_pc ();
CORE_ADDR real_stop_pc;
@@ -9352,8 +9351,7 @@ print_stop_location (const target_waitstatus &ws)
if (tp->control.stop_step
&& (tp->control.step_frame_id
== get_frame_id (get_current_frame ()))
- && (tp->control.step_start_function
- == find_symbol_for_pc (tp->stop_pc ())))
+ && (tp->in_step_start_function ()))
{
symtab_and_line sal = find_frame_sal (get_selected_frame (nullptr));
if (sal.symtab != tp->current_symtab)
--
2.51.0
next prev parent reply other threads:[~2026-03-31 13:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 13:23 [RFC v2 0/3] [gdb] Fix missing print frame when stepping out of function Tom de Vries
2026-03-31 13:23 ` [RFC v2 1/3] [gdb/symtab] Add find_symbol_for_pc_maybe_inline Tom de Vries
2026-03-31 13:23 ` Tom de Vries [this message]
2026-03-31 13:23 ` [RFC v2 3/3] [gdb] Fix missing print frame when stepping out of function Tom de Vries
2026-04-05 10:12 ` [PATCH 0/2] " Andrew Burgess
2026-04-05 10:12 ` [PATCH 1/2] gdb: use get_current_frame consistently in print_stop_location Andrew Burgess
2026-04-09 6:42 ` Tom de Vries
2026-04-09 8:54 ` Andrew Burgess
2026-04-09 13:43 ` Tom de Vries
2026-04-10 8:57 ` Andrew Burgess
2026-04-10 10:17 ` Tom de Vries
2026-04-05 10:12 ` [PATCH 2/2] gdb: fix missing print frame when stepping out of function Andrew Burgess
2026-04-10 10:29 ` Tom de Vries
2026-04-10 10:48 ` [PATCH 0/2] Fix " 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=20260331132342.1050954-3-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