]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Convert block_containing_function to method
authorTom Tromey <tom@tromey.com>
Tue, 17 Jan 2023 00:48:19 +0000 (17:48 -0700)
committerTom Tromey <tom@tromey.com>
Sun, 19 Feb 2023 19:51:06 +0000 (12:51 -0700)
This converts block_containing_function to be a method.  This was
mostly written by script.

gdb/block.c
gdb/block.h
gdb/blockframe.c
gdb/linespec.c

index dca6ff36f3b1d3edb39a8a2d27941196fb4cf64c..31916ce48dc75bd597e251cab8a07b9115d551ac 100644 (file)
@@ -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 ();
 
index d1f4409d86320d0a520a0aea0b7b89334ebfff0b..9f1ba935abb2bba077d0f2bd9dacb2ab5273b54e 100644 (file)
@@ -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
index 65183b1946bc6b9a2e2e066d0d3a140c4c5e2734..7c9faf487a7a0692978e3dba95936654a406fdc1 100644 (file)
@@ -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
index 7761feff8d4a87ce287f4183438d94ca972642c1..7edfee22ea7350aa1da01483ec4ce220b546bc71 100644 (file)
@@ -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)