public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [review] Defer minimal symbol name-setting
@ 2019-10-20  3:55 Tom Tromey (Code Review)
  2019-10-21 13:32 ` [review v2] " Simon Marchi (Code Review)
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Tom Tromey (Code Review) @ 2019-10-20  3:55 UTC (permalink / raw)
  To: gdb-patches

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/166
......................................................................

Defer minimal symbol name-setting

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



diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 731f81c..3794946 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
 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-10-19  Tom Tromey  <tom@tromey.com>
+
 	* configure: Rebuild.
 	* configure.ac: Don't check for sigprocmask.
 	* gdbsupport/common.m4 (GDB_AC_COMMON): Check for sigprocmask.
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index c41e5c3..4e6bd39 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1129,7 +1129,11 @@
   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;
@@ -1350,6 +1354,18 @@
       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);
     }
 }
diff --git a/gdb/symtab.h b/gdb/symtab.h
index dc65409..8552bf1 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -689,6 +689,10 @@
 
   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.  */
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [review v2] Defer minimal symbol name-setting
  2019-10-20  3:55 [review] Defer minimal symbol name-setting Tom Tromey (Code Review)
@ 2019-10-21 13:32 ` Simon Marchi (Code Review)
  2019-10-30 21:53 ` Tom Tromey (Code Review)
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Simon Marchi (Code Review) @ 2019-10-21 13:32 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

Simon Marchi has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/166
......................................................................


Patch Set 2:

(1 comment)

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/166/2/gdb/minsyms.c 
File gdb/minsyms.c:

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/166/2/gdb/minsyms.c@1360 
PS2, Line 1360: 	  if (!msymbols[i].name_set)
In which situation would name_set be already true here?



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [review v2] Defer minimal symbol name-setting
  2019-10-20  3:55 [review] Defer minimal symbol name-setting Tom Tromey (Code Review)
  2019-10-21 13:32 ` [review v2] " Simon Marchi (Code Review)
@ 2019-10-30 21:53 ` Tom Tromey (Code Review)
  2019-10-30 22:51 ` Tom Tromey (Code Review)
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Tom Tromey (Code Review) @ 2019-10-30 21:53 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Tom Tromey has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/166
......................................................................


Patch Set 2:

(1 comment)

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/166/2/gdb/minsyms.c 
File gdb/minsyms.c:

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/166/2/gdb/minsyms.c@1360 
PS2, Line 1360: 
1286 | minimal_symbol_reader::install ()
     | ...
1355 |       m_objfile->per_bfd->msymbols = std::move (msym_holder);
1356 | 
1357 |       msymbols = m_objfile->per_bfd->msymbols.get ();
1358 |       for (int i = 0; i < mcount; ++i)
1359 | 	{
1360 > 	  if (!msymbols[i].name_set)
1361 | 	    {
1362 | 	      symbol_set_names (&msymbols[i], msymbols[i].name,
1363 | 				strlen (msymbols[i].name), 0,
1364 | 				m_objfile->per_bfd);
1365 | 	      msymbols[i].name_set = 1;

> In which situation would name_set be already true here?

I'm under the impression that multiple symbol readers can install
minimal symbols for a given objfile.  This code is to support this
case.

However, I wonder now if this is really the case.  Looking at the
code, I think maybe not.  That would be a nice cleanup to have.



-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I4fe3993b99fb3a43968067806e294d48e377fd76
Gerrit-Change-Number: 166
Gerrit-PatchSet: 2
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-Comment-Date: Wed, 30 Oct 2019 21:53:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-MessageType: comment

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [review v2] Defer minimal symbol name-setting
  2019-10-20  3:55 [review] Defer minimal symbol name-setting Tom Tromey (Code Review)
  2019-10-21 13:32 ` [review v2] " Simon Marchi (Code Review)
  2019-10-30 21:53 ` Tom Tromey (Code Review)
@ 2019-10-30 22:51 ` Tom Tromey (Code Review)
  2019-10-30 22:53 ` [review v3] " Tom Tromey (Code Review)
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Tom Tromey (Code Review) @ 2019-10-30 22:51 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Tom Tromey has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/166
......................................................................


Patch Set 2:

(1 comment)

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/166/2/gdb/minsyms.c 
File gdb/minsyms.c:

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/166/2/gdb/minsyms.c@1360 
PS2, Line 1360: 
1286 | minimal_symbol_reader::install ()
     | ...
1355 |       m_objfile->per_bfd->msymbols = std::move (msym_holder);
1356 | 
1357 |       msymbols = m_objfile->per_bfd->msymbols.get ();
1358 |       for (int i = 0; i < mcount; ++i)
1359 | 	{
1360 > 	  if (!msymbols[i].name_set)
1361 | 	    {
1362 | 	      symbol_set_names (&msymbols[i], msymbols[i].name,
1363 | 				strlen (msymbols[i].name), 0,
1364 | 				m_objfile->per_bfd);
1365 | 	      msymbols[i].name_set = 1;

> I'm under the impression that multiple symbol readers can install […]

Ok, I looked into this, and unfortunately this really can happen.

For example, elfread.c can obviously make minimal symbols itself.
After having done so, though, it can call elfstab_build_psymtabs,
which calls dbx_symfile_read, which can install minimal symbols.

Perhaps with some refactoring a single minimal_symbol_reader
could be created and then passed around.  I am not sure whether
this would really be an improvement -- it may depend on the
other minsym threading changes that Christian is experimenting
with.



-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I4fe3993b99fb3a43968067806e294d48e377fd76
Gerrit-Change-Number: 166
Gerrit-PatchSet: 2
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-Comment-Date: Wed, 30 Oct 2019 22:51:01 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Tom Tromey <tromey@sourceware.org>
Comment-In-Reply-To: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-MessageType: comment

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [review v3] Defer minimal symbol name-setting
  2019-10-20  3:55 [review] Defer minimal symbol name-setting Tom Tromey (Code Review)
                   ` (2 preceding siblings ...)
  2019-10-30 22:51 ` Tom Tromey (Code Review)
@ 2019-10-30 22:53 ` Tom Tromey (Code Review)
  2019-11-22 16:15 ` Pedro Alves (Code Review)
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Tom Tromey (Code Review) @ 2019-10-30 22:53 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/166
......................................................................

Defer minimal symbol name-setting

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



diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0382082..bf2e059 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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-10-30  Christian Biesinger  <cbiesinger@google.com>
 
 	* minsyms.c (clear_minimal_symbol_hash_tables): New function.
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 78cb15b..3af6e2e 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1127,7 +1127,12 @@
   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 @@
       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);
     }
 }
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 20c11d1..ede2600 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -691,6 +691,10 @@
 
   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.  */
 

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I4fe3993b99fb3a43968067806e294d48e377fd76
Gerrit-Change-Number: 166
Gerrit-PatchSet: 3
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-MessageType: newpatchset

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [review v3] Defer minimal symbol name-setting
  2019-10-20  3:55 [review] Defer minimal symbol name-setting Tom Tromey (Code Review)
                   ` (3 preceding siblings ...)
  2019-10-30 22:53 ` [review v3] " Tom Tromey (Code Review)
@ 2019-11-22 16:15 ` Pedro Alves (Code Review)
  2019-11-22 22:29 ` Tom Tromey (Code Review)
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves (Code Review) @ 2019-11-22 16:15 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches; +Cc: Simon Marchi

Pedro Alves has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/166
......................................................................


Patch Set 3: Code-Review+2

(2 comments)

| --- gdb/minsyms.c
| +++ gdb/minsyms.c
| @@ -1348,17 +1353,28 @@ minimal_symbol_reader::install ()
|           The strings themselves are also located in the storage_obstack
|           of this objfile.  */
|  
|        if (m_objfile->per_bfd->minimal_symbol_count != 0)
|  	clear_minimal_symbol_hash_tables (m_objfile);
|  
|        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;
| +	    }
| +	}

PS3, Line 1371:

I was wondering whether we could do without the name_set field by
doing this symbol_set_names loop only over the new minsyms, before
appending them to the objfile's preexisting minsyms list, but I guess
the need for deduplication shows that we'd be demangling more than
necessary.

| +
|        build_minimal_symbol_hash_tables (m_objfile);
|      }
|  }
|  
|  /* Check if PC is in a shared library trampoline code stub.
|     Return minimal symbol for the trampoline entry or NULL if PC is not
|     in a trampoline code stub.  */
|  
| --- gdb/symtab.h
| +++ gdb/symtab.h
| @@ -683,19 +683,23 @@ struct minimal_symbol : public general_symbol_info
|       the object file format may not carry that piece of information.  */
|    unsigned int has_size : 1;
|  
|    /* For data symbols only, if this is set, then the symbol might be
|       subject to copy relocation.  In this case, a minimal symbol
|       matching the symbol's linkage name is first looked for in the
|       main objfile.  If found, then that address is used; otherwise the
|       address in this symbol is used.  */
|  
|    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;

PS3, Line 696:

Don't change it, since the other fields are the same, but,

I'm wondering whether nowadays with C++ we shouldn't be writing

  bool name_set : 1;

and then use true/false instead of 0/1.

I assume that it compiles down to the same.

| +
|    /* Minimal symbols with the same hash key are kept on a linked
|       list.  This is the link.  */
|  
|    struct minimal_symbol *hash_next;
|  
|    /* Minimal symbols are stored in two different hash tables.  This is
|       the `next' pointer for the demangled hash table.  */
|  

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I4fe3993b99fb3a43968067806e294d48e377fd76
Gerrit-Change-Number: 166
Gerrit-PatchSet: 3
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-Comment-Date: Fri, 22 Nov 2019 16:15:21 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [review v3] Defer minimal symbol name-setting
  2019-10-20  3:55 [review] Defer minimal symbol name-setting Tom Tromey (Code Review)
                   ` (4 preceding siblings ...)
  2019-11-22 16:15 ` Pedro Alves (Code Review)
@ 2019-11-22 22:29 ` Tom Tromey (Code Review)
  2019-11-22 23:50 ` [review v4] " Tom Tromey (Code Review)
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Tom Tromey (Code Review) @ 2019-11-22 22:29 UTC (permalink / raw)
  To: gdb-patches; +Cc: Pedro Alves, Simon Marchi

Tom Tromey has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/166
......................................................................


Patch Set 3:

(1 comment)

| --- gdb/symtab.h
| +++ gdb/symtab.h
| @@ -683,19 +683,23 @@ struct minimal_symbol : public general_symbol_info
|       the object file format may not carry that piece of information.  */
|    unsigned int has_size : 1;
|  
|    /* For data symbols only, if this is set, then the symbol might be
|       subject to copy relocation.  In this case, a minimal symbol
|       matching the symbol's linkage name is first looked for in the
|       main objfile.  If found, then that address is used; otherwise the
|       address in this symbol is used.  */
|  
|    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;

PS3, Line 696:

I wasn't sure if there was some caveat to using a boolean
bitfield, or not.  So, I followed the pre-existing code.
Also in the Windows ABI using the same type for bit-fields
yields better packing, which argues for switching them all
at the same time.

| +
|    /* Minimal symbols with the same hash key are kept on a linked
|       list.  This is the link.  */
|  
|    struct minimal_symbol *hash_next;
|  
|    /* Minimal symbols are stored in two different hash tables.  This is
|       the `next' pointer for the demangled hash table.  */
|  

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I4fe3993b99fb3a43968067806e294d48e377fd76
Gerrit-Change-Number: 166
Gerrit-PatchSet: 3
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-Comment-Date: Fri, 22 Nov 2019 22:28:55 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Pedro Alves <palves@redhat.com>
Gerrit-MessageType: comment

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [review v4] Defer minimal symbol name-setting
  2019-10-20  3:55 [review] Defer minimal symbol name-setting Tom Tromey (Code Review)
                   ` (5 preceding siblings ...)
  2019-11-22 22:29 ` Tom Tromey (Code Review)
@ 2019-11-22 23:50 ` Tom Tromey (Code Review)
  2019-11-26 21:13 ` [pushed] " Sourceware to Gerrit sync (Code Review)
  2019-11-26 21:14 ` Sourceware to Gerrit sync (Code Review)
  8 siblings, 0 replies; 10+ messages in thread
From: Tom Tromey (Code Review) @ 2019-11-22 23:50 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches; +Cc: Simon Marchi

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/166
......................................................................

Defer minimal symbol name-setting

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



diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 65da2ff..562fb61 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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-22  Tom Tromey  <tom@tromey.com>
 
 	* observable.h: Update comments.
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index a9ba66b..6e7021a 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1127,7 +1127,12 @@
   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 @@
       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);
     }
 }
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 897ffda..bcbc9c8 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -668,6 +668,10 @@
 
   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.  */
 

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I4fe3993b99fb3a43968067806e294d48e377fd76
Gerrit-Change-Number: 166
Gerrit-PatchSet: 4
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-MessageType: newpatchset

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pushed] Defer minimal symbol name-setting
  2019-10-20  3:55 [review] Defer minimal symbol name-setting Tom Tromey (Code Review)
                   ` (6 preceding siblings ...)
  2019-11-22 23:50 ` [review v4] " Tom Tromey (Code Review)
@ 2019-11-26 21:13 ` Sourceware to Gerrit sync (Code Review)
  2019-11-26 21:14 ` Sourceware to Gerrit sync (Code Review)
  8 siblings, 0 replies; 10+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-11-26 21:13 UTC (permalink / raw)
  To: Tom Tromey, Pedro Alves, gdb-patches; +Cc: Simon Marchi

The original change was created by Tom Tromey.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/166
......................................................................

Defer minimal symbol name-setting

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-11-26  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
---
M gdb/ChangeLog
M gdb/minsyms.c
M gdb/symtab.h
3 files changed, 28 insertions(+), 1 deletion(-)



diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b061e88..dc684be 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2019-11-26  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-26  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 
 	* python/python.c (gdbpy_enter::~gdbpy_enter): Release GIL after
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index a9ba66b..6e7021a 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1127,7 +1127,12 @@
   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 @@
       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);
     }
 }
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 897ffda..bcbc9c8 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -668,6 +668,10 @@
 
   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.  */
 

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I4fe3993b99fb3a43968067806e294d48e377fd76
Gerrit-Change-Number: 166
Gerrit-PatchSet: 5
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-MessageType: newpatchset

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pushed] Defer minimal symbol name-setting
  2019-10-20  3:55 [review] Defer minimal symbol name-setting Tom Tromey (Code Review)
                   ` (7 preceding siblings ...)
  2019-11-26 21:13 ` [pushed] " Sourceware to Gerrit sync (Code Review)
@ 2019-11-26 21:14 ` Sourceware to Gerrit sync (Code Review)
  8 siblings, 0 replies; 10+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-11-26 21:14 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches; +Cc: Pedro Alves, Simon Marchi

Sourceware to Gerrit sync has submitted this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/166
......................................................................

Defer minimal symbol name-setting

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-11-26  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
---
M gdb/ChangeLog
M gdb/minsyms.c
M gdb/symtab.h
3 files changed, 28 insertions(+), 1 deletion(-)


diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b061e88..dc684be 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2019-11-26  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-26  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 
 	* python/python.c (gdbpy_enter::~gdbpy_enter): Release GIL after
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index a9ba66b..6e7021a 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1127,7 +1127,12 @@
   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 @@
       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);
     }
 }
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 897ffda..bcbc9c8 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -668,6 +668,10 @@
 
   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.  */
 

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I4fe3993b99fb3a43968067806e294d48e377fd76
Gerrit-Change-Number: 166
Gerrit-PatchSet: 5
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-Reviewer: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-MessageType: merged

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-11-26 21:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-20  3:55 [review] Defer minimal symbol name-setting Tom Tromey (Code Review)
2019-10-21 13:32 ` [review v2] " Simon Marchi (Code Review)
2019-10-30 21:53 ` Tom Tromey (Code Review)
2019-10-30 22:51 ` Tom Tromey (Code Review)
2019-10-30 22:53 ` [review v3] " Tom Tromey (Code Review)
2019-11-22 16:15 ` Pedro Alves (Code Review)
2019-11-22 22:29 ` Tom Tromey (Code Review)
2019-11-22 23:50 ` [review v4] " Tom Tromey (Code Review)
2019-11-26 21:13 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-11-26 21:14 ` Sourceware to Gerrit sync (Code Review)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).