]> 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>
Tue, 1 Oct 2019 02:30:39 +0000 (20:30 -0600)
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-09-30  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.

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

index 17a8b9875c30d122d96732a398f33034b00f7ca8..f2562517f88098b15032a1c7059cf460e7e229af 100644 (file)
@@ -1,3 +1,10 @@
+2019-09-30  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-09-30  Tom Tromey  <tom@tromey.com>
 
        * configure: Rebuild.
index 83f5d895779e5c86b236e8584a1ddf34f47bccd4..2b259d39c1120067f63a234efb20b89b078dfd43 100644 (file)
@@ -1106,7 +1106,11 @@ minimal_symbol_reader::record_full (const char *name, int name_len,
   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, name_len, copy_name, m_objfile->per_bfd);
+
+  if (copy_name)
+    name = (char *) obstack_copy0 (&m_objfile->per_bfd->storage_obstack,
+                                  name, name_len);
+  msymbol->name = name;
 
   SET_MSYMBOL_VALUE_ADDRESS (msymbol, address);
   MSYMBOL_SECTION (msymbol) = section;
@@ -1327,6 +1331,18 @@ 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,
+                               strlen (msymbols[i].name), 0,
+                               m_objfile->per_bfd);
+             msymbols[i].name_set = 1;
+           }
+       }
+
       build_minimal_symbol_hash_tables (m_objfile);
     }
 }
index 1f0fc62a657dbc7a042bef905d8af5ac99be13e0..c3918a85af7cadad228e17f36d183491e1d33db2 100644 (file)
@@ -669,6 +669,10 @@ struct minimal_symbol : public general_symbol_info
      the object file format may not carry that piece of information.  */
   unsigned int has_size : 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.  */