Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH] gdb: return raw frame_info pointer from create_sentinel_frame
Date: Thu, 18 Jun 2026 18:00:55 +0100	[thread overview]
Message-ID: <f250af3c43a034f843afcb96488afa5df5cc75ad.1781802041.git.aburgess@redhat.com> (raw)

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.
---
 gdb/frame.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/gdb/frame.c b/gdb/frame.c
index f64f5554f8c..e581e396c13 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1661,9 +1661,13 @@ put_frame_register_bytes (const frame_info_ptr &next_frame, int regnum,
 /* Create a sentinel frame.
 
    See frame_id_build_sentinel for the description of STACK_ADDR and
-   CODE_ADDR.  */
+   CODE_ADDR.
 
-static frame_info_ptr
+   This returns a raw frame_info pointer rather than a frame_info_ptr as
+   every caller only needs the frame_info and would discard any
+   frame_info_ptr.  */
+
+static frame_info *
 create_sentinel_frame (program_space *pspace, address_space *aspace,
 		       regcache *regcache, CORE_ADDR stack_addr,
 		       CORE_ADDR code_addr)
@@ -1691,7 +1695,7 @@ create_sentinel_frame (program_space *pspace, address_space *aspace,
 
   frame_debug_printf ("  -> %s", frame->to_string ().c_str ());
 
-  return frame_info_ptr (frame);
+  return frame;
 }
 
 /* Cache for frame addresses already read by gdb.  Valid only while
@@ -1736,7 +1740,7 @@ get_current_frame (void)
       create_sentinel_frame (current_program_space,
 			     current_inferior ()->aspace.get (),
 			     get_thread_regcache (inferior_thread ()),
-			     0, 0).get ();
+			     0, 0);
 
   /* Set the current frame before computing the frame id, to avoid
      recursion inside compute_frame_id, in case the frame's
@@ -2091,7 +2095,7 @@ create_new_frame (frame_id id)
   fi->next = create_sentinel_frame (current_program_space,
 				    current_inferior ()->aspace.get (),
 				    get_thread_regcache (inferior_thread ()),
-				    id.stack_addr, id.code_addr).get ();
+				    id.stack_addr, id.code_addr);
 
   /* Set/update this frame's cached PC value, found in the next frame.
      Do this before looking for this frame's unwinder.  A sniffer is

base-commit: 60466ce68ac1a2d93c7f39b2638e24f48125fbf9
-- 
2.25.4


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

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18 17:00 Andrew Burgess [this message]
2026-06-18 17:25 ` Simon Marchi
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=f250af3c43a034f843afcb96488afa5df5cc75ad.1781802041.git.aburgess@redhat.com \
    --to=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