Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] [gdb] Simplify frame_follow_static_link
Date: Tue, 21 Apr 2026 14:21:39 +0200	[thread overview]
Message-ID: <20260421122139.243506-1-tdevries@suse.de> (raw)

In frame_follow_static_link, I noticed:
...
  if (frame_block == nullptr)
    return {};

  frame_block = frame_block->function_block ();

  const struct dynamic_prop *static_link = frame_block->static_link ();
...

This is the only use of block::static_link, so simplify
frame_follow_static_link by merging the call to function_block into
block::static_link.

Tested on aarch64-linux.
---
 gdb/block.c | 8 +++++---
 gdb/block.h | 2 +-
 gdb/frame.c | 2 --
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gdb/block.c b/gdb/block.c
index dc00327048f..e7424c52aff 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -357,13 +357,15 @@ struct dynamic_prop *
 block::static_link () const
 {
   struct objfile *objfile = this->objfile ();
+  const struct block *function_block = this->function_block ();
 
-  /* Only objfile-owned blocks that materialize top function scopes can have
+  /* Only objfile-owned blocks that materialize function scopes can have
      static links.  */
-  if (objfile == NULL || function () == NULL)
+  if (objfile == NULL || function_block == NULL)
     return NULL;
 
-  return (struct dynamic_prop *) objfile_lookup_static_link (objfile, this);
+  return (struct dynamic_prop *) objfile_lookup_static_link (objfile,
+							     function_block);
 }
 
 /* See block.h.  */
diff --git a/gdb/block.h b/gdb/block.h
index 091120ae2b8..cd02006f860 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -301,7 +301,7 @@ struct block : public allocate_on_obstack<block>
      DW_AT_static_link attribute) for a function is a way to get the
      frame corresponding to the enclosing function.
 
-     Note that only objfile-owned and function-level blocks can have a
+     Note that only objfile-owned and in-function blocks can have a
      static link.  Return NULL if there is no such property.  */
 
   struct dynamic_prop *static_link () const;
diff --git a/gdb/frame.c b/gdb/frame.c
index 7a83f5e61c0..61d37316c6a 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -3241,8 +3241,6 @@ frame_follow_static_link (const frame_info_ptr &initial_frame)
   if (frame_block == nullptr)
     return {};
 
-  frame_block = frame_block->function_block ();
-
   const struct dynamic_prop *static_link = frame_block->static_link ();
   if (static_link == nullptr)
     return {};

base-commit: c365a263f5dcf95982464cf6d53db00cc6f04c1c
-- 
2.51.0


             reply	other threads:[~2026-04-21 12:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-21 12:21 Tom de Vries [this message]
2026-04-23 16:23 ` Tom Tromey
2026-04-23 16:35   ` Tom Tromey
2026-04-24  7:22     ` 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=20260421122139.243506-1-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