]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Defer minimal symbol name-setting
authorTom Tromey <tom@tromey.com>
Sat, 2 Mar 2019 20:19:44 +0000 (13:19 -0700)
committerTom Tromey <tom@tromey.com>
Sun, 10 Nov 2019 17:44:49 +0000 (10:44 -0700)
Currently the demangled name of a minimal symbol is set when creating
the symbol.  However, there is no intrinsic need to do this.  This
patch instead arranges for the demangling to be done just before the
minsym hash tables are filled.  This will be useful in a later patch.

gdb/ChangeLog
2019-10-19  Tom Tromey  <tom@tromey.com>

* symtab.h (struct minimal_symbol) <name_set>: New member.
* minsyms.c (minimal_symbol_reader::record_full): Copy name.
Don't call symbol_set_names.
(minimal_symbol_reader::install): Call symbol_set_names.

Change-Id: I4fe3993b99fb3a43968067806e294d48e377fd76

gdb/ChangeLog
gdb/minsyms.c
gdb/symtab.h

index 6f377f33473d12b3f53525f866993bd182e47282..b9b90d43d190a8852066e0596601b3f6638e3ddc 100644 (file)
@@ -1,3 +1,10 @@
+2019-10-19  Tom Tromey  <tom@tromey.com>
+
+       * symtab.h (struct minimal_symbol) <name_set>: New member.
+       * minsyms.c (minimal_symbol_reader::record_full): Copy name.
+       Don't call symbol_set_names.
+       (minimal_symbol_reader::install): Call symbol_set_names.
+
 2019-11-10  Tom Tromey  <tom@tromey.com>
 
        * tui/tui-wingeneral.c (tui_unhighlight_win): Use can_box.
index 78cb15b5677358e3aa08649dd262135da964732b..3af6e2e941aa5672fb7a7967ebbb4f7c62cd02dc 100644 (file)
@@ -1127,7 +1127,12 @@ minimal_symbol_reader::record_full (gdb::string_view name,
   msymbol = &m_msym_bunch->contents[m_msym_bunch_index];
   symbol_set_language (msymbol, language_auto,
                       &m_objfile->per_bfd->storage_obstack);
-  symbol_set_names (msymbol, name, copy_name, m_objfile->per_bfd);
+
+  if (copy_name)
+    msymbol->name = obstack_strndup (&m_objfile->per_bfd->storage_obstack,
+                                    name.data (), name.size ());
+  else
+    msymbol->name = name.data ();
 
   SET_MSYMBOL_VALUE_ADDRESS (msymbol, address);
   MSYMBOL_SECTION (msymbol) = section;
@@ -1354,6 +1359,17 @@ minimal_symbol_reader::install ()
       m_objfile->per_bfd->minimal_symbol_count = mcount;
       m_objfile->per_bfd->msymbols = std::move (msym_holder);
 
+      msymbols = m_objfile->per_bfd->msymbols.get ();
+      for (int i = 0; i < mcount; ++i)
+       {
+         if (!msymbols[i].name_set)
+           {
+             symbol_set_names (&msymbols[i], msymbols[i].name,
+                               false, m_objfile->per_bfd);
+             msymbols[i].name_set = 1;
+           }
+       }
+
       build_minimal_symbol_hash_tables (m_objfile);
     }
 }
index 111a0f924d8caf19a3a20b3c4a53282e02964c58..3c05b23dc661549a9d160c0df9eee50d04915e08 100644 (file)
@@ -698,6 +698,10 @@ struct minimal_symbol : public general_symbol_info
 
   unsigned maybe_copied : 1;
 
+  /* Non-zero if this symbol ever had its demangled name set (even if
+     it was set to NULL).  */
+  unsigned int name_set : 1;
+
   /* Minimal symbols with the same hash key are kept on a linked
      list.  This is the link.  */