From: Simon Marchi <simark@simark.ca>
To: Andrew Burgess <aburgess@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCHv10 5/5] gdb: cache program space entry point information
Date: Fri, 30 Oct 2026 13:19:15 -0400 [thread overview]
Message-ID: <ddcc8278-c89f-40a5-bb72-f0c2de101098@simark.ca> (raw)
In-Reply-To: <2c9ddc321a22311a9848f5482a0f27881aa74e7f.1793268860.git.aburgess@redhat.com>
On 10/29/26 6:20 AM, Andrew Burgess wrote:
> After the previous two patches, there are now two places where we
> check if a frame is an entry point frame, these are in get_prev_frame
> and frame_unwind_caller_frame. Both of these locations call
> inside_entry_func, which then calls program_space::get_entry_point_info.
Slightly outdated now that there is
get_prev_frame_with_entry_frame_check, but the idea remains the same.
> The calls to program_space::get_entry_point_info are not crazy
> expensive, but they are not free either, there are reads from target
> memory to read the auxv vector and the entry address offset, so on
> remote targets this could introduce a small delay.
>
> However, the result from program_space::get_entry_point_info is not
> expected to change from one call to the next. This information should
> be a property of the executable and libraries, so we really only need
> to figure it out once.
>
> This commit caches the entry point information within program_space,
> clearing it whenever an inferior starts or exits, whenever the
> executable is updated, or whenever the inferior execs. After clearing
> GDB will compute, and cache the updated information the next time it
> is needed, which will be whenever GDB needs to unwind a frame.
>
> It will be possible to observe this change by, for example, monitoring
> the remote target packets, but as far as the normal GDB output is
> concerned, there should be no user visible changes after this commit.
> ---
> gdb/progspace.c | 45 ++++++++++++++++++++++++++++++++++++++++++---
> gdb/progspace.h | 11 ++++++++++-
> 2 files changed, 52 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/progspace.c b/gdb/progspace.c
> index 3347eb7dacc..b7282b6fd64 100644
> --- a/gdb/progspace.c
> +++ b/gdb/progspace.c
> @@ -371,9 +371,12 @@ program_space::exec_entry_point_address () const
>
> /* See progspace.h. */
>
> -entry_point_info
> +const entry_point_info &
> program_space::get_entry_point_info () const
> {
> + if (m_entry_point_info.has_value ())
> + return m_entry_point_info.value ();
We typically use:
return *m_entry_point_info;
> +
> std::optional<CORE_ADDR> exec_entry_address
> = this->exec_entry_point_address_if_available ();
>
> @@ -389,8 +392,9 @@ program_space::get_entry_point_info () const
> break;
> }
>
> - return entry_point_info (std::move (inferior_entry_address),
> - std::move (exec_entry_address));
> + m_entry_point_info.emplace (std::move (inferior_entry_address),
> + std::move (exec_entry_address));
> + return m_entry_point_info.value ();
Likewise.
Also, same unnecessary std::moves comment as before.
> }
>
> /* Implement the 'maint info entry-address' command. */
> @@ -628,11 +632,46 @@ program_space::clear_solib_cache ()
> deleted_solibs.clear ();
> }
>
> +/* Clear cached entry point information in the program space of INF. */
> +
> +static void
> +clear_cached_entry_point_info_for_inferior (inferior *inf)
> +{
> + inf->pspace->clear_cached_entry_point_info ();
> +}
> +
> +/* Clear cached entry point information in the program space PSPACE. */
> +
> +static void
> +clear_cached_entry_point_info_for_pspace (program_space *pspace,
> + bool /* reload */)
> +{
> + pspace->clear_cached_entry_point_info ();
> +}
> +
> +/* Clear cached entry point information in the program space of EXEC_INF. */
> +
> +static void
> +clear_cached_entry_point_info_after_exec (inferior *exec_inf,
> + inferior */* follow_inf */)
> +{
> + exec_inf->pspace->clear_cached_entry_point_info ();
> +}
> +
> /* See progspace.h. */
>
> void
> initialize_progspace ()
> {
> + gdb::observers::inferior_created.attach
> + (clear_cached_entry_point_info_for_inferior, "program-space");
> + gdb::observers::inferior_exit.attach
> + (clear_cached_entry_point_info_for_inferior, "program-space");
> + gdb::observers::executable_changed.attach
> + (clear_cached_entry_point_info_for_pspace, "program-space");
> + gdb::observers::inferior_execd.attach
> + (clear_cached_entry_point_info_after_exec, "program-space");
A corner case spotted by Claude: if you use the symbol-file command to
load a new main obfile, or get rid of the existing symbols, it
potentially affects the answer of "what is the executable entry point",
but none of the above observers is fired (executable_changed is only
called when the "exec-file" changes).
This could be fixed by listening to the new_objfile and free_objfile
observers, clearing the cache is we see the objfile with OBJF_MAINLINE
go by.
Otherwise, LGTM.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Simon
prev parent reply other threads:[~2026-10-30 17:19 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 18:14 [PATCH] gdb: allow 'until' to work in outermost frame Andrew Burgess
2026-06-11 19:24 ` Guinevere Larsen
2026-06-11 20:40 ` Andrew Burgess
2026-06-12 12:49 ` Guinevere Larsen
2026-06-11 21:59 ` [PATCHv2 0/3] " Andrew Burgess
2026-06-11 21:59 ` [PATCHv2 1/3] gdb: rename program_space::entry_point_address* functions Andrew Burgess
2026-06-12 15:41 ` Pedro Alves
2026-06-11 21:59 ` [PATCHv2 2/3] gdb: introduce program_space::get_entry_point_info function Andrew Burgess
2026-06-12 6:07 ` Eli Zaretskii
2026-06-15 10:14 ` Andrew Burgess
2026-06-15 12:01 ` Eli Zaretskii
2026-06-12 15:41 ` Pedro Alves
2026-06-15 10:29 ` Andrew Burgess
2026-06-16 18:36 ` Pedro Alves
2026-06-23 9:46 ` Andrew Burgess
2026-06-23 10:20 ` Pedro Alves
2026-06-11 21:59 ` [PATCHv2 3/3] gdb: allow 'until' to work in outermost frame Andrew Burgess
2026-06-12 15:57 ` Pedro Alves
2026-06-16 19:47 ` [PATCHv3 0/4] " Andrew Burgess
2026-06-16 19:47 ` [PATCHv3 1/4] gdb: rename program_space::entry_point_address* functions Andrew Burgess
2026-06-16 19:47 ` [PATCHv3 2/4] gdb: introduce program_space::get_entry_point_info function Andrew Burgess
2026-06-17 11:52 ` Eli Zaretskii
2026-06-16 19:47 ` [PATCHv3 3/4] gdb: allow 'until' to work in outermost frame Andrew Burgess
2026-06-16 19:47 ` [PATCHv3 4/4] gdb: cache program space entry point information Andrew Burgess
2026-06-23 10:47 ` [PATCHv4 0/4] gdb: allow 'until' to work in outermost frame Andrew Burgess
2026-06-23 10:47 ` [PATCHv4 1/4] gdb: rename program_space::entry_point_address* functions Andrew Burgess
2026-06-23 10:47 ` [PATCHv4 2/4] gdb: introduce program_space::get_entry_point_info function Andrew Burgess
2026-06-23 10:47 ` [PATCHv4 3/4] gdb: allow 'until' to work in outermost frame Andrew Burgess
2026-06-23 10:47 ` [PATCHv4 4/4] gdb: cache program space entry point information Andrew Burgess
2026-06-25 15:26 ` [PATCHv5 0/4] gdb: allow 'until' to work in outermost frame Andrew Burgess
2026-06-25 15:26 ` [PATCHv5 1/4] gdb: rename program_space::entry_point_address* functions Andrew Burgess
2026-06-25 15:26 ` [PATCHv5 2/4] gdb: introduce program_space::get_entry_point_info function Andrew Burgess
2026-06-25 15:26 ` [PATCHv5 3/4] gdb: allow 'until' to work in outermost frame Andrew Burgess
2026-06-25 15:26 ` [PATCHv5 4/4] gdb: cache program space entry point information Andrew Burgess
2026-07-10 14:24 ` [PATCHv6 0/4] gdb: allow 'until' to work in outermost frame Andrew Burgess
2026-07-10 14:24 ` [PATCHv6 1/4] gdb: rename program_space::entry_point_address* functions Andrew Burgess
2026-07-10 14:24 ` [PATCHv6 2/4] gdb: introduce program_space::get_entry_point_info function Andrew Burgess
2026-07-10 15:39 ` Simon Marchi
2026-07-10 14:24 ` [PATCHv6 3/4] gdb: allow 'until' to work in outermost frame Andrew Burgess
2026-07-10 17:00 ` Simon Marchi
2026-07-10 17:01 ` Simon Marchi
2026-07-16 15:06 ` Andrew Burgess
2026-07-10 14:24 ` [PATCHv6 4/4] gdb: cache program space entry point information Andrew Burgess
2026-07-10 17:07 ` Simon Marchi
2026-07-18 13:11 ` [PATCHv7 0/4] gdb: allow 'until' to work in outermost frame Andrew Burgess
2026-07-18 13:11 ` [PATCHv7 1/4] gdb: rename program_space::entry_point_address* functions Andrew Burgess
2026-07-18 13:11 ` [PATCHv7 2/4] gdb: introduce program_space::get_entry_point_info function Andrew Burgess
2026-07-18 13:11 ` [PATCHv7 3/4] gdb: allow 'until' to work in outermost frame Andrew Burgess
2026-07-18 13:11 ` [PATCHv7 4/4] gdb: cache program space entry point information Andrew Burgess
2026-07-20 9:52 ` [PATCHv8 0/4] gdb: allow 'until' to work in outermost frame Andrew Burgess
2026-07-20 9:52 ` [PATCHv8 1/4] gdb: rename program_space::entry_point_address* functions Andrew Burgess
2026-07-20 9:52 ` [PATCHv8 2/4] gdb: introduce program_space::get_entry_point_info function Andrew Burgess
2026-08-12 15:44 ` Simon Marchi
2026-07-20 9:52 ` [PATCHv8 3/4] gdb: allow 'until' to work in outermost frame Andrew Burgess
2026-08-12 17:53 ` Simon Marchi
2026-08-20 10:32 ` Andrew Burgess
2026-07-20 9:52 ` [PATCHv8 4/4] gdb: cache program space entry point information Andrew Burgess
2026-08-24 16:22 ` [PATCHv9 0/4] gdb: allow 'until' to work in outermost frame Andrew Burgess
2026-08-24 16:22 ` [PATCHv9 1/4] gdb: rename program_space::entry_point_address* functions Andrew Burgess
2026-08-24 16:22 ` [PATCHv9 2/4] gdb: introduce program_space::get_entry_point_info function Andrew Burgess
2026-08-24 16:22 ` [PATCHv9 3/4] gdb: allow 'until' to work in outermost frame Andrew Burgess
2026-10-27 14:33 ` Simon Marchi
2026-08-24 16:22 ` [PATCHv9 4/4] gdb: cache program space entry point information Andrew Burgess
2026-10-29 10:20 ` [PATCHv10 0/5] gdb: allow 'until' to work in outermost frame Andrew Burgess
2026-10-29 10:20 ` [PATCHv10 1/5] gdb: more 'const' in the multi-so-lib progspace code Andrew Burgess
2026-10-30 15:28 ` Simon Marchi
2026-10-29 10:20 ` [PATCHv10 2/5] gdb: rename program_space::entry_point_address* functions Andrew Burgess
2026-10-30 15:34 ` Simon Marchi
2026-10-29 10:20 ` [PATCHv10 3/5] gdb: introduce program_space::get_entry_point_info function Andrew Burgess
2026-10-30 16:11 ` Simon Marchi
2026-10-29 10:20 ` [PATCHv10 4/5] gdb: allow 'until' to work in outermost frame Andrew Burgess
2026-10-30 16:31 ` Simon Marchi
2026-10-29 10:20 ` [PATCHv10 5/5] gdb: cache program space entry point information Andrew Burgess
2026-10-30 17:19 ` Simon Marchi [this message]
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=ddcc8278-c89f-40a5-bb72-f0c2de101098@simark.ca \
--to=simark@simark.ca \
--cc=aburgess@redhat.com \
--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