Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] [gdb] Simplify frame_follow_static_link
@ 2026-04-21 12:21 Tom de Vries
  2026-04-23 16:23 ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Tom de Vries @ 2026-04-21 12:21 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-24  7:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-21 12:21 [PATCH] [gdb] Simplify frame_follow_static_link Tom de Vries
2026-04-23 16:23 ` Tom Tromey
2026-04-23 16:35   ` Tom Tromey
2026-04-24  7:22     ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox