Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFC 1/6] Defer minimal symbol name-setting
Date: Sat, 09 Mar 2019 17:23:00 -0000	[thread overview]
Message-ID: <20190309172300.2764-2-tom@tromey.com> (raw)
In-Reply-To: <20190309172300.2764-1-tom@tromey.com>

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-03-03  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 |  7 +++++++
 gdb/minsyms.c | 18 +++++++++++++++++-
 gdb/symtab.h  |  4 ++++
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 1b8e67bc98b..7872b7e2588 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1145,7 +1145,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;
@@ -1404,6 +1408,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;
+	    }
+	}
+
       /* Now build the hash tables; we can't do this incrementally
          at an earlier point since we weren't finished with the obstack
 	 yet.  (And if the msymbol obstack gets moved, all the internal
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 85dc3710483..29595685981 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -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.  */
 
-- 
2.17.2


  reply	other threads:[~2019-03-09 17:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-09 17:23 [RFC 0/6] Demangle minimal symbol names in worker threads Tom Tromey
2019-03-09 17:23 ` Tom Tromey [this message]
2019-03-09 17:23 ` [RFC 4/6] Introduce run_on_main_thread Tom Tromey
2019-03-09 17:23 ` [RFC 2/6] Remove static buffer from ada_decode Tom Tromey
2019-03-09 17:23 ` [RFC 5/6] Introduce thread-safe way to handle SIGSEGV Tom Tromey
2019-03-11 17:24   ` John Baldwin
2019-03-09 17:23 ` [RFC 6/6] Demangle minsyms in parallel Tom Tromey
2019-03-09 17:23 ` [RFC 3/6] Lock the demangled hash table Tom Tromey
2019-03-09 18:09 ` [RFC 0/6] Demangle minimal symbol names in worker threads Eli Zaretskii
2019-03-11 17:35   ` John Baldwin
2019-03-11 22:39   ` Tom Tromey
2019-03-12  3:33     ` Eli Zaretskii
2019-03-13 15:38       ` Eli Zaretskii
2019-03-15 23:28         ` Tom Tromey
2019-03-16  7:46           ` Eli Zaretskii
2019-03-16  8:31             ` Eli Zaretskii
2019-03-15 23:40         ` Tom Tromey
2019-03-16  7:52           ` Eli Zaretskii
2019-03-11 17:26 ` John Baldwin
2019-03-11 22:40   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190309172300.2764-2-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox