]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/symtab: Make cooked_index_entry::parent_entry private
authorTom de Vries <tdevries@suse.de>
Wed, 10 Jan 2024 09:06:35 +0000 (10:06 +0100)
committerTom de Vries <tdevries@suse.de>
Wed, 10 Jan 2024 09:06:35 +0000 (10:06 +0100)
Make cooked_index_entry::parent_entry private, and add member functions to
access it.

Tested on x86_64-linux and ppc64le-linux.
Tested-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
gdb/dwarf2/cooked-index.c
gdb/dwarf2/cooked-index.h
gdb/dwarf2/read.c

index c82f49e14626c4f3dbf2ce3fb320b9b51255aa02..a4a400e8eae0a4f0dcdf5dee1980b1c21392d136 100644 (file)
@@ -203,7 +203,7 @@ cooked_index_entry::full_name (struct obstack *storage, bool for_main) const
 {
   const char *local_name = for_main ? name : canonical;
 
-  if ((flags & IS_LINKAGE) != 0 || parent_entry == nullptr)
+  if ((flags & IS_LINKAGE) != 0 || get_parent () == nullptr)
     return local_name;
 
   const char *sep = nullptr;
@@ -224,7 +224,7 @@ cooked_index_entry::full_name (struct obstack *storage, bool for_main) const
       return local_name;
     }
 
-  parent_entry->write_scope (storage, sep, for_main);
+  get_parent ()->write_scope (storage, sep, for_main);
   obstack_grow0 (storage, local_name, strlen (local_name));
   return (const char *) obstack_finish (storage);
 }
@@ -236,8 +236,8 @@ cooked_index_entry::write_scope (struct obstack *storage,
                                 const char *sep,
                                 bool for_main) const
 {
-  if (parent_entry != nullptr)
-    parent_entry->write_scope (storage, sep, for_main);
+  if (get_parent () != nullptr)
+    get_parent ()->write_scope (storage, sep, for_main);
   const char *local_name = for_main ? name : canonical;
   obstack_grow (storage, local_name, strlen (local_name));
   obstack_grow (storage, sep, strlen (sep));
@@ -310,7 +310,7 @@ cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry,
       parent = last;
     }
 
-  entry->parent_entry = parent;
+  entry->set_parent (parent);
   return make_unique_xstrndup (tail.data (), tail.length ());
 }
 
@@ -638,9 +638,9 @@ cooked_index::dump (gdbarch *arch)
       gdb_printf ("    flags:      %s\n", to_string (entry->flags).c_str ());
       gdb_printf ("    DIE offset: %s\n", sect_offset_str (entry->die_offset));
 
-      if (entry->parent_entry != nullptr)
+      if (entry->get_parent () != nullptr)
        gdb_printf ("    parent:     ((cooked_index_entry *) %p) [%s]\n",
-                   entry->parent_entry, entry->parent_entry->name);
+                   entry->get_parent (), entry->get_parent ()->name);
       else
        gdb_printf ("    parent:     ((cooked_index_entry *) 0)\n");
 
index a175f6716f548b0cedbb61f83304ddfe625b86dc..fa0807a2cb0364919e190d32a9684b7cdccfd744 100644 (file)
@@ -94,8 +94,8 @@ struct cooked_index_entry : public allocate_on_obstack
       tag (tag_),
       flags (flags_),
       die_offset (die_offset_),
-      parent_entry (parent_entry_),
-      per_cu (per_cu_)
+      per_cu (per_cu_),
+      m_parent_entry (parent_entry_)
   {
   }
 
@@ -220,6 +220,18 @@ struct cooked_index_entry : public allocate_on_obstack
     return compare (canonical, other.canonical, SORT) < 0;
   }
 
+  /* Set parent entry to PARENT.  */
+  void set_parent (const cooked_index_entry *parent)
+  {
+    m_parent_entry = parent;
+  }
+
+  /* Return parent entry.  */
+  const cooked_index_entry *get_parent () const
+  {
+    return m_parent_entry;
+  }
+
   /* The name as it appears in DWARF.  This always points into one of
      the mapped DWARF sections.  Note that this may be the name or the
      linkage name -- two entries are created for DIEs which have both
@@ -234,10 +246,6 @@ struct cooked_index_entry : public allocate_on_obstack
   cooked_index_flag flags;
   /* The offset of this DIE.  */
   sect_offset die_offset;
-  /* The parent entry.  This is NULL for top-level entries.
-     Otherwise, it points to the parent entry, such as a namespace or
-     class.  */
-  const cooked_index_entry *parent_entry;
   /* The CU from which this entry originates.  */
   dwarf2_per_cu_data *per_cu;
 
@@ -248,6 +256,11 @@ private:
      a parent, its write_scope method is called first.  */
   void write_scope (struct obstack *storage, const char *sep,
                    bool for_name) const;
+
+  /* The parent entry.  This is NULL for top-level entries.
+     Otherwise, it points to the parent entry, such as a namespace or
+     class.  */
+  const cooked_index_entry *m_parent_entry;
 };
 
 class cooked_index;
index ca4dda5aea1a1bea500fc7e96b0201e120462fa0..bfbf094b61c91224cb5d223dcdbdff0165a55956 100644 (file)
@@ -16523,7 +16523,7 @@ cooked_indexer::index_dies (cutu_reader *reader,
       /* The scope of a DW_TAG_entry_point cooked_index_entry is the one of
         its surrounding subroutine.  */
       if (abbrev->tag == DW_TAG_entry_point)
-       this_parent_entry = parent_entry->parent_entry;
+       this_parent_entry = parent_entry->get_parent ();
       info_ptr = scan_attributes (reader->cu->per_cu, reader, info_ptr,
                                  info_ptr, abbrev, &name, &linkage_name,
                                  &flags, &sibling, &this_parent_entry,
@@ -16862,7 +16862,7 @@ cooked_index_functions::expand_symtabs_matching
             matches.  */
          bool found = true;
 
-         const cooked_index_entry *parent = entry->parent_entry;
+         const cooked_index_entry *parent = entry->get_parent ();
          for (int i = name_vec.size () - 1; i > 0; --i)
            {
              /* If we ran out of entries, or if this segment doesn't
@@ -16875,7 +16875,7 @@ cooked_index_functions::expand_symtabs_matching
                  break;
                }
 
-             parent = parent->parent_entry;
+             parent = parent->get_parent ();
            }
 
          if (!found)