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

* Re: [PATCH] [gdb] Simplify frame_follow_static_link
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2026-04-23 16:23 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> diff --git a/gdb/frame.c b/gdb/frame.c
Tom> index 7a83f5e61c0..61d37316c6a 100644
Tom> --- a/gdb/frame.c
Tom> +++ b/gdb/frame.c
Tom> @@ -3241,8 +3241,6 @@ frame_follow_static_link (const frame_info_ptr &initial_frame)
Tom>    if (frame_block == nullptr)
Tom>      return {};
 
Tom> -  frame_block = frame_block->function_block ();
Tom> -
Tom>    const struct dynamic_prop *static_link = frame_block->static_link ();
Tom>    if (static_link == nullptr)
Tom>      return {};

There's nothing wrong with this patch, but I have a patch in development
that extends frame_follow_static_link and that will need the function
block at this point.

Lowering this call into the block method will end up making things
slightly less efficient.  So I'd prefer this not go in, as I'll end up
at least having to essentially undo this hunk.

Maybe a different approach would be to change block::static_link to
document that this is only valid for function-having blocks and add an
assert to that effect in the implementation.

thanks,
Tom

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

* Re: [PATCH] [gdb] Simplify frame_follow_static_link
  2026-04-23 16:23 ` Tom Tromey
@ 2026-04-23 16:35   ` Tom Tromey
  2026-04-24  7:22     ` Tom de Vries
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2026-04-23 16:35 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Tom de Vries, gdb-patches

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> There's nothing wrong with this patch, but I have a patch in development
Tom> that extends frame_follow_static_link and that will need the function
Tom> block at this point.

I looked again and I think my patch won't conflict with this one at all.
So IMO your original patch is ok.

Approved-By: Tom Tromey <tom@tromey.com>

Tom

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

* Re: [PATCH] [gdb] Simplify frame_follow_static_link
  2026-04-23 16:35   ` Tom Tromey
@ 2026-04-24  7:22     ` Tom de Vries
  0 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2026-04-24  7:22 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 4/23/26 6:35 PM, Tom Tromey wrote:
>>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
> 
> Tom> There's nothing wrong with this patch, but I have a patch in development
> Tom> that extends frame_follow_static_link and that will need the function
> Tom> block at this point.
> 
> I looked again and I think my patch won't conflict with this one at all.
> So IMO your original patch is ok.
> 

Hi Tom,

thanks for the review, pushed.

In any case, if this turns out to be in the way, feel free to just 
revert it.

Thanks,
- Tom

> Approved-By: Tom Tromey <tom@tromey.com>
> 
> Tom


^ 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