[01/10] Convert symbol_set_demangled_name to a method

Message ID 20200325200715.12947-2-tom@tromey.com
State New
Headers show
Series
  • Fix two name-related bugs in DWARF reader
Related show

Commit Message

Tom Tromey March 25, 2020, 8:07 p.m.
This changes symbol_set_demangled_name to be a method on
general_symbol_info, and updates the users.

gdb/ChangeLog
2020-03-25  Tom Tromey  <tom@tromey.com>

	* symtab.h (struct general_symbol_info) <set_demangled_name>: New
	method.
	(symbol_set_demangled_name): Don't declare.
	* symtab.c (general_symbol_info::set_demangled_name): Rename from
	symbol_set_demangled_name.
	(general_symbol_info::set_language)
	(general_symbol_info::compute_and_set_names): Update.
	* minsyms.c (minimal_symbol_reader::install): Update.
	* dwarf2/read.c (new_symbol): Update.
---
 gdb/ChangeLog     | 12 ++++++++++++
 gdb/dwarf2/read.c |  4 +---
 gdb/minsyms.c     |  5 ++---
 gdb/symtab.c      | 27 ++++++++++++---------------
 gdb/symtab.h      |  9 +++++----
 5 files changed, 32 insertions(+), 25 deletions(-)

-- 
2.17.2

Patch

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 0e879e08a0c..69ad352b6a7 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -20573,9 +20573,7 @@  new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	 between gfortran, iFort etc.  */
       if (cu->language == language_fortran
           && symbol_get_demangled_name (sym) == NULL)
-	symbol_set_demangled_name (sym,
-				   dwarf2_full_name (name, die, cu),
-	                           NULL);
+	sym->set_demangled_name (dwarf2_full_name (name, die, cu), NULL);
 
       /* Default assumptions.
          Use the passed type or decode it from the die.  */
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index e238355dc11..0bccf44f8ee 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1418,9 +1418,8 @@  minimal_symbol_reader::install ()
 		   /* This will be freed later, by compute_and_set_names.  */
 		   char *demangled_name
 		     = symbol_find_demangled_name (msym, msym->linkage_name ());
-		   symbol_set_demangled_name
-		     (msym, demangled_name,
-		      &m_objfile->per_bfd->storage_obstack);
+		   msym->set_demangled_name
+		     (demangled_name, &m_objfile->per_bfd->storage_obstack);
 		   msym->name_set = 1;
 		 }
 	       /* This mangled_name_hash computation has to be outside of
diff --git a/gdb/symtab.c b/gdb/symtab.c
index f300d759e03..84ad17ee50e 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -667,29 +667,27 @@  gdb_mangle_name (struct type *type, int method_id, int signature_id)
   return (mangled_name);
 }
 
-/* Set the demangled name of GSYMBOL to NAME.  NAME must be already
-   correctly allocated.  */
+/* See symtab.h.  */
 
 void
-symbol_set_demangled_name (struct general_symbol_info *gsymbol,
-                           const char *name,
-                           struct obstack *obstack)
+general_symbol_info::set_demangled_name (const char *name,
+					 struct obstack *obstack)
 {
-  if (gsymbol->language () == language_ada)
+  if (language () == language_ada)
     {
       if (name == NULL)
 	{
-	  gsymbol->ada_mangled = 0;
-	  gsymbol->language_specific.obstack = obstack;
+	  ada_mangled = 0;
+	  language_specific.obstack = obstack;
 	}
       else
 	{
-	  gsymbol->ada_mangled = 1;
-	  gsymbol->language_specific.demangled_name = name;
+	  ada_mangled = 1;
+	  language_specific.demangled_name = name;
 	}
     }
   else
-    gsymbol->language_specific.demangled_name = name;
+    language_specific.demangled_name = name;
 }
 
 /* Return the demangled name of GSYMBOL.  */
@@ -722,7 +720,7 @@  general_symbol_info::set_language (enum language language,
       || language == language_objc
       || language == language_fortran)
     {
-      symbol_set_demangled_name (this, NULL, obstack);
+      set_demangled_name (NULL, obstack);
     }
   else if (language == language_ada)
     {
@@ -872,7 +870,7 @@  general_symbol_info::compute_and_set_names (gdb::string_view linkage_name,
 	m_name = obstack_strndup (&per_bfd->storage_obstack,
 				  linkage_name.data (),
 				  linkage_name.length ());
-      symbol_set_demangled_name (this, NULL, &per_bfd->storage_obstack);
+      set_demangled_name (NULL, &per_bfd->storage_obstack);
 
       return;
     }
@@ -962,8 +960,7 @@  general_symbol_info::compute_and_set_names (gdb::string_view linkage_name,
     m_language = (*slot)->language;
 
   m_name = (*slot)->mangled.data ();
-  symbol_set_demangled_name (this, (*slot)->demangled.get (),
-			     &per_bfd->storage_obstack);
+  set_demangled_name ((*slot)->demangled.get (), &per_bfd->storage_obstack);
 }
 
 /* See symtab.h.  */
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 18be5d51b85..83938d064fe 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -425,6 +425,11 @@  struct general_symbol_info
   void set_linkage_name (const char *linkage_name)
   { m_name = linkage_name; }
 
+  /* Set the demangled name of this symbol to NAME.  NAME must be
+     already correctly allocated.  If the symbol's language is Ada,
+     then the name is ignored and the obstack is set.  */
+  void set_demangled_name (const char *name, struct obstack *obstack);
+
   enum language language () const
   { return m_language; }
 
@@ -508,10 +513,6 @@  struct general_symbol_info
   short section;
 };
 
-extern void symbol_set_demangled_name (struct general_symbol_info *,
-				       const char *,
-                                       struct obstack *);
-
 extern const char *symbol_get_demangled_name
   (const struct general_symbol_info *);