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 02/10] [gdb] Factor out block::containing_function_block
Date: Fri,  1 May 2026 14:44:56 +0200	[thread overview]
Message-ID: <20260501124504.2233495-3-tdevries@suse.de> (raw)
In-Reply-To: <20260501124504.2233495-1-tdevries@suse.de>

Factor out new function block::containing_function_block out of
block::containing_function.
---
 gdb/block.c | 18 ++++++++++++++----
 gdb/block.h |  5 +++++
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/gdb/block.c b/gdb/block.c
index e7424c52aff..7b006617d1a 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -99,15 +99,25 @@ block::linkage_function () const
 
 /* See block.h.  */
 
-struct symbol *
-block::containing_function () const
+const struct block *
+block::containing_function_block () const
 {
   const block *bl = this;
 
-  while (bl->function () == NULL && bl->superblock () != NULL)
+  while (bl->function () == nullptr && bl->superblock () != nullptr)
     bl = bl->superblock ();
 
-  return bl->function ();
+  return bl->function () != nullptr ? bl : nullptr;
+}
+
+/* See block.h.  */
+
+struct symbol *
+block::containing_function () const
+{
+  const block *bl = containing_function_block ();
+
+  return bl != nullptr ? bl->function () : nullptr;
 }
 
 /* See block.h.  */
diff --git a/gdb/block.h b/gdb/block.h
index cd02006f860..b70b27f6509 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -258,6 +258,11 @@ struct block : public allocate_on_obstack<block>
 
   struct symbol *containing_function () const;
 
+  /* Return the block for the closest enclosing function, which might be an
+     inline function.  */
+
+  const struct block *containing_function_block () const;
+
   /* Return the static block associated with this block.  Return NULL
      if block is a global block.  */
 
-- 
2.51.0


  parent reply	other threads:[~2026-05-01 12:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-01 12:44 [PATCH 00/10] [gdb] Add superblocks range loops Tom de Vries
2026-05-01 12:44 ` [PATCH 01/10] [gdb] Use block::containing_function Tom de Vries
2026-05-01 12:44 ` Tom de Vries [this message]
2026-05-01 12:44 ` [PATCH 03/10] [gdb] Use block::containing_function_block Tom de Vries
2026-05-01 12:44 ` [PATCH 04/10] [gdb] Add unit test for next_iterator Tom de Vries
2026-05-01 12:44 ` [PATCH 05/10] [gdbsupport] Use using instead of typedef in next_iterator Tom de Vries
2026-05-01 12:45 ` [PATCH 06/10] [gdbsupport] Factor out base_next_iterator Tom de Vries
2026-05-08 19:17   ` Tom Tromey
2026-05-01 12:45 ` [PATCH 07/10] [gdb] Add block::block_and_superblocks Tom de Vries
2026-05-01 12:45 ` [PATCH 08/10] [gdb] Use block::block_and_superblocks Tom de Vries
2026-05-08 19:41   ` Tom Tromey
2026-05-01 12:45 ` [PATCH 09/10] [gdb] Add block::block_and_superblocks_in_fn Tom de Vries
2026-05-01 12:45 ` [PATCH 10/10] [gdb] Use block::block_and_superblocks_in_fn Tom de Vries
2026-06-09 12:40 ` [PATCH 00/10] [gdb] Add superblocks range loops 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=20260501124504.2233495-3-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