Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Andrew Burgess <aburgess@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: return raw frame_info pointer from create_sentinel_frame
Date: Thu, 18 Jun 2026 13:25:40 -0400	[thread overview]
Message-ID: <3c585153-c89e-422b-9236-daaeb9615f8a@simark.ca> (raw)
In-Reply-To: <f250af3c43a034f843afcb96488afa5df5cc75ad.1781802041.git.aburgess@redhat.com>



On 2026-06-18 13:00, Andrew Burgess wrote:
> The create_sentinel_frame function is static within frame.c and
> currently returns a frame_info_ptr.  The frame_info_ptr is created at
> the last moment, as part of the 'return' statement.
> 
> Every user of create_sentinel_frame immediately pulls the raw
> frame_info pointer out of the frame_info_ptr and then discards the
> frame_info_ptr object.
> 
> Creating a frame_info_ptr isn't zero work.  Not that I'm trying to
> sell this as a performance improvement, the work saved here is
> negligible, but it's so obviously redundant in this case that I figure
> we can just remove the frame_info_ptr and pass back a raw frame_info
> pointer instead.
> 
> This patch changes create_sentinel_frame to return a raw frame_info
> pointer, which is what the callers actually want, and avoids the
> unnecessary creation and destruction of a frame_info_ptr object.
> 
> There should be no user visible changes after this commit.

Your patch looks obviously correct to me, so:

Approved-By: Simon Marchi <simon.marchi@efficios.com>

I was wondering if you instead considered making the sentinel_frame
global a frame_info_ptr itself.  I think there would be a concern in
construction ordering, because the frame_info_ptr constructor uses the
frame_info_ptr::frame_list list, and that one is defined later in the
file, but that would be easy to fix.  There are two spots where we do

  frame_info_ptr (sentinel_frame))

that would be simplified a little bit.  But other than that, I don't
think it would provide any tangible benefit.

Another random thing I noticed while reading the code, do you know why
we have this in frame_find_by_id?

  /* Check for the sentinel frame.  */
  if (id == frame_id_build_sentinel (0, 0))
    return frame_info_ptr (sentinel_frame);

Given that sentinel frames are put in the frame stash (see
create_sentinel_frame), I don't see why this special case is needed.
Moreover, this would only match the sentinel frames constructed with
stack and code addresses 0, which I don't think is the typical case.
Hmm, it's probably because sentinel frames were not put in the frame
cache before my commit here...

  https://gitlab.com/gnutools/binutils-gdb/-/commit/19f988359a62889b00d67fb59ef8c7d6d759fc98

There is probably something to clean up here.

Simon

  reply	other threads:[~2026-06-18 17:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18 17:00 Andrew Burgess
2026-06-18 17:25 ` Simon Marchi [this message]
2026-06-18 17:27 ` Tom Tromey
2026-06-22 21:33 ` [PATCHv2 0/2] Some sentinel frame related cleanup in frame.c Andrew Burgess
2026-06-22 21:33   ` [PATCHv2 1/2] gdb: remove sentinel frame check in frame_find_by_id Andrew Burgess
2026-06-23  2:18     ` Simon Marchi
2026-06-23 10:52       ` Andrew Burgess
2026-06-22 21:33   ` [PATCHv2 2/2] gdb: convert sentinel_frame to a frame_info_ptr Andrew Burgess
2026-06-23  2:23     ` Simon Marchi
2026-06-23 10:55       ` Andrew Burgess

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=3c585153-c89e-422b-9236-daaeb9615f8a@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