Convert symbol_set_demangled_name to a method
authorTom Tromey <tom@tromey.com>
Fri, 24 Apr 2020 21:35:01 +0000 (15:35 -0600)
committerTom Tromey <tromey@adacore.com>
Fri, 24 Apr 2020 21:35:02 +0000 (15:35 -0600)
This changes symbol_set_demangled_name to be a method on
general_symbol_info, and updates the users.

gdb/ChangeLog
2020-04-24  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
gdb/dwarf2/read.c
gdb/minsyms.c
gdb/symtab.c
gdb/symtab.h

index 8911ff5dfdbabdd09b7301f59f63d60676b5be37..e2312778821bc90eaf67a80158444b802d8f8dca 100644 (file)
@@ -1,3 +1,15 @@
+2020-04-24  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.
+
 2020-04-24  Tom Tromey  <tromey@adacore.com>
 
        PR python/23662:
index 14d53a20e8b6f124f36fe09bed966b08938307b3..86d3a7b7fdbaf35c734f595cbd8c4d3967e59155 100644 (file)
@@ -20569,9 +20569,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.  */
index 2c1262b0dd6c26a20f2ed9a5e7328db79b1cd0ad..47c6f0bc0cd895f19b61e8cdd51dec4b2bc31427 100644 (file)
@@ -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
index 4e9f91056b8889383b38aca8807fccc4e6ed6706..c9c75e94182242c32e1c71afecf6628e6cd65f6a 100644 (file)
@@ -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.  */
index 77f60e6c24ac6497a3eac5bb9905a2f9675e9a99..ee570f922858fc05c1676838a03a52a3b63bf350 100644 (file)
@@ -454,6 +454,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; }
 
@@ -537,10 +542,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 *);