public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Convert block_containing_function to method
@ 2023-02-19 23:37 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2023-02-19 23:37 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=99f3dfd0f94144d295885e79f4ff5a5f8119fb04

commit 99f3dfd0f94144d295885e79f4ff5a5f8119fb04
Author: Tom Tromey <tom@tromey.com>
Date:   Mon Jan 16 17:48:19 2023 -0700

    Convert block_containing_function to method
    
    This converts block_containing_function to be a method.  This was
    mostly written by script.

Diff:
---
 gdb/block.c      | 9 ++++-----
 gdb/block.h      | 9 +++++++--
 gdb/blockframe.c | 2 +-
 gdb/linespec.c   | 2 +-
 4 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/gdb/block.c b/gdb/block.c
index dca6ff36f3b..31916ce48dc 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -100,14 +100,13 @@ block::linkage_function () const
   return bl->function ();
 }
 
-/* Return the symbol for the function which contains a specified
-   block, described by a struct block BL.  The return value will be
-   the closest enclosing function, which might be an inline
-   function.  */
+/* See block.h.  */
 
 struct symbol *
-block_containing_function (const struct block *bl)
+block::containing_function () const
 {
+  const block *bl = this;
+
   while (bl->function () == NULL && bl->superblock () != NULL)
     bl = bl->superblock ();
 
diff --git a/gdb/block.h b/gdb/block.h
index d1f4409d863..9f1ba935abb 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -238,6 +238,13 @@ struct block
 
   struct symbol *linkage_function () const;
 
+  /* Return the symbol for the function which contains a specified
+     block, described by a struct block.  The return value will be the
+     closest enclosing function, which might be an inline
+     function.  */
+
+  struct symbol *containing_function () const;
+
   /* Addresses in the executable code that are in this block.  */
 
   CORE_ADDR m_start;
@@ -371,8 +378,6 @@ private:
   struct block *m_blocks[1];
 };
 
-extern struct symbol *block_containing_function (const struct block *);
-
 /* Return true if block A is lexically nested within block B, or if a
    and b have the same pc range.  Return false otherwise.  If
    ALLOW_NESTED is true, then block A is considered to be in block B
diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index 65183b1946b..7c9faf487a7 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -162,7 +162,7 @@ find_pc_sect_containing_function (CORE_ADDR pc, struct obj_section *section)
   if (bl == nullptr)
     return nullptr;
 
-  return block_containing_function (bl);
+  return bl->containing_function ();
 }
 
 /* These variables are used to cache the most recent result of
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 7761feff8d4..7edfee22ea7 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -2128,7 +2128,7 @@ create_sals_line_offset (struct linespec_state *self,
 	if (filter[i])
 	  {
 	    struct symbol *sym = (blocks[i]
-				  ? block_containing_function (blocks[i])
+				  ? blocks[i]->containing_function ()
 				  : NULL);
 
 	    if (self->funfirstline)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-19 23:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-19 23:37 [binutils-gdb] Convert block_containing_function to method Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).