[binutils-gdb] [gdb] Simplify frame_follow_static_link
Tom de Vries via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=08610a4004a2906a2ae1b4676601a72e3b93c16a commit 08610a4004a2906a2ae1b4676601a72e3b93c16a Author: Tom de Vries <[email protected]> Date: Fri Apr 24 09:19:44 2026 +0200 [gdb] Simplify frame_follow_static_link 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. Approved-By: Tom Tromey <[email protected]> Tested on aarch64-linux. Diff: --- 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 {};