* [review] Store the mangled name as a string_view
[not found] <gerrit.1571050562000.I24711ae2bcaa9e79ca89a6f8fda385d400419175@gnutoolchain-gerrit.osci.io>
@ 2019-10-16 13:08 ` Christian Biesinger (Code Review)
2019-10-21 20:15 ` [review v3] " Christian Biesinger (Code Review)
` (9 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: Christian Biesinger (Code Review) @ 2019-10-16 13:08 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches
Christian Biesinger has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37
......................................................................
Uploaded patch set 2: Patch Set 1 was rebased.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [review v3] Store the mangled name as a string_view
[not found] <gerrit.1571050562000.I24711ae2bcaa9e79ca89a6f8fda385d400419175@gnutoolchain-gerrit.osci.io>
2019-10-16 13:08 ` [review] Store the mangled name as a string_view Christian Biesinger (Code Review)
@ 2019-10-21 20:15 ` Christian Biesinger (Code Review)
2019-10-21 22:39 ` Simon Marchi (Code Review)
` (8 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: Christian Biesinger (Code Review) @ 2019-10-21 20:15 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches
Christian Biesinger has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37
......................................................................
Patch Set 3:
Ping
^ permalink raw reply [flat|nested] 11+ messages in thread
* [review v3] Store the mangled name as a string_view
[not found] <gerrit.1571050562000.I24711ae2bcaa9e79ca89a6f8fda385d400419175@gnutoolchain-gerrit.osci.io>
2019-10-16 13:08 ` [review] Store the mangled name as a string_view Christian Biesinger (Code Review)
2019-10-21 20:15 ` [review v3] " Christian Biesinger (Code Review)
@ 2019-10-21 22:39 ` Simon Marchi (Code Review)
2019-10-21 22:51 ` [review v4] " Christian Biesinger (Code Review)
` (7 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: Simon Marchi (Code Review) @ 2019-10-21 22:39 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches
Simon Marchi has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37
......................................................................
Patch Set 3:
(1 comment)
https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37/3/gdb/symtab.c
File gdb/symtab.c:
https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37/3/gdb/symtab.c@891
PS3, Line 891: + demangled_len + 1));
Pedantically, since demangled_name_entry is now a non-POD, we should run the constructor here and the destructor when we release them. Running the constructor here would not be too complicated, but running the destructor might be a bit more (and maybe it's not really necessary), I guess we'd need a "delete" function on the htab.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [review v4] Store the mangled name as a string_view
[not found] <gerrit.1571050562000.I24711ae2bcaa9e79ca89a6f8fda385d400419175@gnutoolchain-gerrit.osci.io>
` (2 preceding siblings ...)
2019-10-21 22:39 ` Simon Marchi (Code Review)
@ 2019-10-21 22:51 ` Christian Biesinger (Code Review)
2019-10-21 23:13 ` [review v5] " Christian Biesinger (Code Review)
` (6 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: Christian Biesinger (Code Review) @ 2019-10-21 22:51 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches; +Cc: Simon Marchi
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37
......................................................................
Store the mangled name as a string_view
This should be a bit faster (because we can compare the size first),
but it is also a dependency for the next patch.
(3.47% of gdb startup time is spent in eq_demangled_name_entry when
attaching to Chrome's content_shell binary)
gdb/ChangeLog:
2019-09-27 Christian Biesinger <cbiesinger@google.com>
* symtab.c (struct demangled_name_entry): Change type of mangled
to gdb::string_view.
(hash_demangled_name_entry): Update.
(eq_demangled_name_entry): Update.
(symbol_set_names): Update.
Change-Id: I24711ae2bcaa9e79ca89a6f8fda385d400419175
---
M gdb/symtab.c
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/gdb/symtab.c b/gdb/symtab.c
index fc736fd..f4d35a2 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -68,6 +68,7 @@
#include "filename-seen-cache.h"
#include "arch-utils.h"
#include <algorithm>
+#include "gdbsupport/gdb_string_view.h"
#include "gdbsupport/pathstuff.h"
/* Forward declarations for local functions. */
@@ -713,7 +714,7 @@
/* Objects of this type are stored in the demangled name hash table. */
struct demangled_name_entry
{
- const char *mangled;
+ gdb::string_view mangled;
ENUM_BITFIELD(language) language : LANGUAGE_BITS;
char demangled[1];
};
@@ -726,7 +727,7 @@
const struct demangled_name_entry *e
= (const struct demangled_name_entry *) data;
- return htab_hash_string (e->mangled);
+ return iterative_hash (e->mangled.data (), e->mangled.length (), 0);
}
/* Equality function for the demangled name hash. */
@@ -739,7 +740,16 @@
const struct demangled_name_entry *db
= (const struct demangled_name_entry *) b;
- return strcmp (da->mangled, db->mangled) == 0;
+ return da->mangled == db->mangled;
+}
+
+static void
+free_demangled_name_entry (void *data)
+{
+ struct demangled_name_entry *e
+ = (struct demangled_name_entry *) data;
+
+ e->~demangled_name_entry();
}
/* Create the hash table used for demangled names. Each hash entry is
@@ -855,7 +865,7 @@
else
linkage_name_copy = linkage_name;
- entry.mangled = linkage_name_copy;
+ entry.mangled = gdb::string_view (linkage_name_copy, len);
slot = ((struct demangled_name_entry **)
htab_find_slot (per_bfd->demangled_names_hash.get (),
&entry, INSERT));
@@ -888,7 +898,8 @@
obstack_alloc (&per_bfd->storage_obstack,
offsetof (struct demangled_name_entry, demangled)
+ demangled_len + 1));
- (*slot)->mangled = linkage_name;
+ new (*slot) demangled_name_entry();
+ (*slot)->mangled = gdb::string_view (linkage_name, len);
}
else
{
@@ -904,7 +915,7 @@
+ len + demangled_len + 2));
mangled_ptr = &((*slot)->demangled[demangled_len + 1]);
strcpy (mangled_ptr, linkage_name_copy);
- (*slot)->mangled = mangled_ptr;
+ (*slot)->mangled = gdb::string_view (mangled_ptr, len);
}
(*slot)->language = gsymbol->language;
@@ -917,7 +928,7 @@
|| gsymbol->language == language_auto)
gsymbol->language = (*slot)->language;
- gsymbol->name = (*slot)->mangled;
+ gsymbol->name = (*slot)->mangled.data ();
if ((*slot)->demangled[0] != '\0')
symbol_set_demangled_name (gsymbol, (*slot)->demangled,
&per_bfd->storage_obstack);
^ permalink raw reply [flat|nested] 11+ messages in thread
* [review v5] Store the mangled name as a string_view
[not found] <gerrit.1571050562000.I24711ae2bcaa9e79ca89a6f8fda385d400419175@gnutoolchain-gerrit.osci.io>
` (4 preceding siblings ...)
2019-10-21 23:13 ` [review v5] " Christian Biesinger (Code Review)
@ 2019-10-21 23:13 ` Christian Biesinger (Code Review)
2019-10-22 4:15 ` Simon Marchi (Code Review)
` (4 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: Christian Biesinger (Code Review) @ 2019-10-21 23:13 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches; +Cc: Simon Marchi
Christian Biesinger has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37
......................................................................
Patch Set 5:
(1 comment)
https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37/3/gdb/symtab.c
File gdb/symtab.c:
https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37/3/gdb/symtab.c@891
PS3, Line 891: + demangled_len + 1));
> Pedantically, since demangled_name_entry is now a non-POD, we should run the constructor here and th [â¦]
Sure, happy to add a delete function -- I have another pending patch that also needs one (https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/132).
Done.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [review v5] Store the mangled name as a string_view
[not found] <gerrit.1571050562000.I24711ae2bcaa9e79ca89a6f8fda385d400419175@gnutoolchain-gerrit.osci.io>
` (3 preceding siblings ...)
2019-10-21 22:51 ` [review v4] " Christian Biesinger (Code Review)
@ 2019-10-21 23:13 ` Christian Biesinger (Code Review)
2019-10-21 23:13 ` Christian Biesinger (Code Review)
` (5 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: Christian Biesinger (Code Review) @ 2019-10-21 23:13 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches; +Cc: Simon Marchi
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37
......................................................................
Store the mangled name as a string_view
This should be a bit faster (because we can compare the size first),
but it is also a dependency for the next patch.
(3.47% of gdb startup time is spent in eq_demangled_name_entry when
attaching to Chrome's content_shell binary)
gdb/ChangeLog:
2019-09-27 Christian Biesinger <cbiesinger@google.com>
* symtab.c (struct demangled_name_entry): Change type of mangled
to gdb::string_view.
(hash_demangled_name_entry): Update.
(eq_demangled_name_entry): Update.
(symbol_set_names): Update.
Change-Id: I24711ae2bcaa9e79ca89a6f8fda385d400419175
---
M gdb/symtab.c
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/gdb/symtab.c b/gdb/symtab.c
index fc736fd..06c0d03 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -68,6 +68,7 @@
#include "filename-seen-cache.h"
#include "arch-utils.h"
#include <algorithm>
+#include "gdbsupport/gdb_string_view.h"
#include "gdbsupport/pathstuff.h"
/* Forward declarations for local functions. */
@@ -713,7 +714,10 @@
/* Objects of this type are stored in the demangled name hash table. */
struct demangled_name_entry
{
- const char *mangled;
+ demangled_name_entry (gdb::string_view mangled_name)
+ : mangled (mangled_name) {}
+
+ gdb::string_view mangled;
ENUM_BITFIELD(language) language : LANGUAGE_BITS;
char demangled[1];
};
@@ -726,7 +730,7 @@
const struct demangled_name_entry *e
= (const struct demangled_name_entry *) data;
- return htab_hash_string (e->mangled);
+ return iterative_hash (e->mangled.data (), e->mangled.length (), 0);
}
/* Equality function for the demangled name hash. */
@@ -739,7 +743,16 @@
const struct demangled_name_entry *db
= (const struct demangled_name_entry *) b;
- return strcmp (da->mangled, db->mangled) == 0;
+ return da->mangled == db->mangled;
+}
+
+static void
+free_demangled_name_entry (void *data)
+{
+ struct demangled_name_entry *e
+ = (struct demangled_name_entry *) data;
+
+ e->~demangled_name_entry();
}
/* Create the hash table used for demangled names. Each hash entry is
@@ -756,7 +769,7 @@
per_bfd->demangled_names_hash.reset (htab_create_alloc
(256, hash_demangled_name_entry, eq_demangled_name_entry,
- NULL, xcalloc, xfree));
+ free_demangled_name_entry, xcalloc, xfree));
}
/* Try to determine the demangled name for a symbol, based on the
@@ -817,7 +830,6 @@
struct demangled_name_entry **slot;
/* A 0-terminated copy of the linkage name. */
const char *linkage_name_copy;
- struct demangled_name_entry entry;
if (gsymbol->language == language_ada)
{
@@ -855,7 +867,7 @@
else
linkage_name_copy = linkage_name;
- entry.mangled = linkage_name_copy;
+ struct demangled_name_entry entry (gdb::string_view (linkage_name_copy, len));
slot = ((struct demangled_name_entry **)
htab_find_slot (per_bfd->demangled_names_hash.get (),
&entry, INSERT));
@@ -888,7 +900,8 @@
obstack_alloc (&per_bfd->storage_obstack,
offsetof (struct demangled_name_entry, demangled)
+ demangled_len + 1));
- (*slot)->mangled = linkage_name;
+ new (*slot) demangled_name_entry
+ (gdb::string_view (linkage_name, len));
}
else
{
@@ -904,7 +917,8 @@
+ len + demangled_len + 2));
mangled_ptr = &((*slot)->demangled[demangled_len + 1]);
strcpy (mangled_ptr, linkage_name_copy);
- (*slot)->mangled = mangled_ptr;
+ new (*slot) demangled_name_entry
+ (gdb::string_view (mangled_ptr, len));
}
(*slot)->language = gsymbol->language;
@@ -917,7 +931,7 @@
|| gsymbol->language == language_auto)
gsymbol->language = (*slot)->language;
- gsymbol->name = (*slot)->mangled;
+ gsymbol->name = (*slot)->mangled.data ();
if ((*slot)->demangled[0] != '\0')
symbol_set_demangled_name (gsymbol, (*slot)->demangled,
&per_bfd->storage_obstack);
^ permalink raw reply [flat|nested] 11+ messages in thread
* [review v5] Store the mangled name as a string_view
[not found] <gerrit.1571050562000.I24711ae2bcaa9e79ca89a6f8fda385d400419175@gnutoolchain-gerrit.osci.io>
` (5 preceding siblings ...)
2019-10-21 23:13 ` Christian Biesinger (Code Review)
@ 2019-10-22 4:15 ` Simon Marchi (Code Review)
2019-10-22 16:06 ` Tom Tromey (Code Review)
` (3 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: Simon Marchi (Code Review) @ 2019-10-22 4:15 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches
Simon Marchi has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37
......................................................................
Patch Set 5: Code-Review+2
Thanks, this LGTM. Just make sure to update the ChangeLog entry.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [review v5] Store the mangled name as a string_view
[not found] <gerrit.1571050562000.I24711ae2bcaa9e79ca89a6f8fda385d400419175@gnutoolchain-gerrit.osci.io>
` (6 preceding siblings ...)
2019-10-22 4:15 ` Simon Marchi (Code Review)
@ 2019-10-22 16:06 ` Tom Tromey (Code Review)
2019-10-22 16:17 ` Christian Biesinger (Code Review)
` (2 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey (Code Review) @ 2019-10-22 16:06 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches; +Cc: Simon Marchi
Tom Tromey has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37
......................................................................
Patch Set 5:
(1 comment)
I had a comment on this one, but I agree with Simon that this is fine as-is.
Thanks for doing this.
https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37/5/gdb/symtab.c
File gdb/symtab.c:
https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37/5/gdb/symtab.c@903
PS5, Line 903: new (*slot) demangled_name_entry
FWIW I don't think there's a deep reason these objects have to
be stored on an obstack. We could just use plain new and make
`free_demangled_name_entry` a wrapper for `delete`. Or maybe
it's finally time to import some version of the gcc hash table.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [review v5] Store the mangled name as a string_view
[not found] <gerrit.1571050562000.I24711ae2bcaa9e79ca89a6f8fda385d400419175@gnutoolchain-gerrit.osci.io>
` (7 preceding siblings ...)
2019-10-22 16:06 ` Tom Tromey (Code Review)
@ 2019-10-22 16:17 ` Christian Biesinger (Code Review)
2019-10-22 16:47 ` [review v6] " Christian Biesinger (Code Review)
2019-10-22 17:55 ` [pushed] " Sourceware to Gerrit sync (Code Review)
10 siblings, 0 replies; 11+ messages in thread
From: Christian Biesinger (Code Review) @ 2019-10-22 16:17 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches; +Cc: Tom Tromey, Simon Marchi
Christian Biesinger has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37
......................................................................
Patch Set 5:
(1 comment)
Thanks for the reviews! Will push once I update the rest of this patch series per your comments.
https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37/5/gdb/symtab.c
File gdb/symtab.c:
https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37/5/gdb/symtab.c@903
PS5, Line 903: new (*slot) demangled_name_entry
> FWIW I don't think there's a deep reason these objects have to [â¦]
OK, I'll keep that in mind.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [review v6] Store the mangled name as a string_view
[not found] <gerrit.1571050562000.I24711ae2bcaa9e79ca89a6f8fda385d400419175@gnutoolchain-gerrit.osci.io>
` (8 preceding siblings ...)
2019-10-22 16:17 ` Christian Biesinger (Code Review)
@ 2019-10-22 16:47 ` Christian Biesinger (Code Review)
2019-10-22 17:55 ` [pushed] " Sourceware to Gerrit sync (Code Review)
10 siblings, 0 replies; 11+ messages in thread
From: Christian Biesinger (Code Review) @ 2019-10-22 16:47 UTC (permalink / raw)
To: Christian Biesinger, Simon Marchi, gdb-patches; +Cc: Tom Tromey
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37
......................................................................
Store the mangled name as a string_view
This should be a bit faster (because we can compare the size first),
but it is also a dependency for the next patch.
(3.47% of gdb startup time is spent in eq_demangled_name_entry when
attaching to Chrome's content_shell binary)
gdb/ChangeLog:
2019-10-22 Christian Biesinger <cbiesinger@google.com>
* symtab.c (struct demangled_name_entry): Change type of mangled
to gdb::string_view. Also adds a constructor that takes the
mangled name.
(hash_demangled_name_entry): Update.
(eq_demangled_name_entry): Update.
(free_demangled_name_entry): New function to call the destructor
now that this is not a POD anymore.
(create_demangled_names_hash): Pass free_demangled_name_entry to
htab_create_alloc.
(symbol_set_names): Update.
Change-Id: I24711ae2bcaa9e79ca89a6f8fda385d400419175
---
M gdb/ChangeLog
M gdb/symtab.c
2 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a70f3e1..d271330 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,16 @@
+2019-10-22 Christian Biesinger <cbiesinger@google.com>
+
+ * symtab.c (struct demangled_name_entry): Change type of mangled
+ to gdb::string_view. Also adds a constructor that takes the
+ mangled name.
+ (hash_demangled_name_entry): Update.
+ (eq_demangled_name_entry): Update.
+ (free_demangled_name_entry): New function to call the destructor
+ now that this is not a POD anymore.
+ (create_demangled_names_hash): Pass free_demangled_name_entry to
+ htab_create_alloc.
+ (symbol_set_names): Update.
+
2019-10-21 Ali Tamur <tamu@google.com>
* dwarf2read.c (dir_index): Change type.
diff --git a/gdb/symtab.c b/gdb/symtab.c
index fc736fd..567d09d 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -68,6 +68,7 @@
#include "filename-seen-cache.h"
#include "arch-utils.h"
#include <algorithm>
+#include "gdbsupport/gdb_string_view.h"
#include "gdbsupport/pathstuff.h"
/* Forward declarations for local functions. */
@@ -713,7 +714,7 @@
/* Objects of this type are stored in the demangled name hash table. */
struct demangled_name_entry
{
- const char *mangled;
+ gdb::string_view mangled;
ENUM_BITFIELD(language) language : LANGUAGE_BITS;
char demangled[1];
};
@@ -726,7 +727,7 @@
const struct demangled_name_entry *e
= (const struct demangled_name_entry *) data;
- return htab_hash_string (e->mangled);
+ return iterative_hash (e->mangled.data (), e->mangled.length (), 0);
}
/* Equality function for the demangled name hash. */
@@ -739,7 +740,7 @@
const struct demangled_name_entry *db
= (const struct demangled_name_entry *) b;
- return strcmp (da->mangled, db->mangled) == 0;
+ return da->mangled == db->mangled;
}
/* Create the hash table used for demangled names. Each hash entry is
@@ -855,7 +856,7 @@
else
linkage_name_copy = linkage_name;
- entry.mangled = linkage_name_copy;
+ entry.mangled = gdb::string_view (linkage_name_copy, len);
slot = ((struct demangled_name_entry **)
htab_find_slot (per_bfd->demangled_names_hash.get (),
&entry, INSERT));
@@ -888,7 +889,7 @@
obstack_alloc (&per_bfd->storage_obstack,
offsetof (struct demangled_name_entry, demangled)
+ demangled_len + 1));
- (*slot)->mangled = linkage_name;
+ (*slot)->mangled = gdb::string_view (linkage_name, len);
}
else
{
@@ -904,7 +905,7 @@
+ len + demangled_len + 2));
mangled_ptr = &((*slot)->demangled[demangled_len + 1]);
strcpy (mangled_ptr, linkage_name_copy);
- (*slot)->mangled = mangled_ptr;
+ (*slot)->mangled = gdb::string_view (mangled_ptr, len);
}
(*slot)->language = gsymbol->language;
@@ -917,7 +918,7 @@
|| gsymbol->language == language_auto)
gsymbol->language = (*slot)->language;
- gsymbol->name = (*slot)->mangled;
+ gsymbol->name = (*slot)->mangled.data ();
if ((*slot)->demangled[0] != '\0')
symbol_set_demangled_name (gsymbol, (*slot)->demangled,
&per_bfd->storage_obstack);
^ permalink raw reply [flat|nested] 11+ messages in thread
* [pushed] Store the mangled name as a string_view
[not found] <gerrit.1571050562000.I24711ae2bcaa9e79ca89a6f8fda385d400419175@gnutoolchain-gerrit.osci.io>
` (9 preceding siblings ...)
2019-10-22 16:47 ` [review v6] " Christian Biesinger (Code Review)
@ 2019-10-22 17:55 ` Sourceware to Gerrit sync (Code Review)
10 siblings, 0 replies; 11+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-10-22 17:55 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches; +Cc: Tom Tromey, Simon Marchi
Sourceware to Gerrit sync has submitted this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37
......................................................................
Store the mangled name as a string_view
This should be a bit faster (because we can compare the size first),
but it is also a dependency for the next patch.
(3.47% of gdb startup time is spent in eq_demangled_name_entry when
attaching to Chrome's content_shell binary)
gdb/ChangeLog:
2019-10-22 Christian Biesinger <cbiesinger@google.com>
* symtab.c (struct demangled_name_entry): Change type of mangled
to gdb::string_view. Also adds a constructor that takes the
mangled name.
(hash_demangled_name_entry): Update.
(eq_demangled_name_entry): Update.
(free_demangled_name_entry): New function to call the destructor
now that this is not a POD anymore.
(create_demangled_names_hash): Pass free_demangled_name_entry to
htab_create_alloc.
(symbol_set_names): Update.
Change-Id: I24711ae2bcaa9e79ca89a6f8fda385d400419175
---
M gdb/ChangeLog
M gdb/symtab.c
2 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a70f3e1..d271330 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,16 @@
+2019-10-22 Christian Biesinger <cbiesinger@google.com>
+
+ * symtab.c (struct demangled_name_entry): Change type of mangled
+ to gdb::string_view. Also adds a constructor that takes the
+ mangled name.
+ (hash_demangled_name_entry): Update.
+ (eq_demangled_name_entry): Update.
+ (free_demangled_name_entry): New function to call the destructor
+ now that this is not a POD anymore.
+ (create_demangled_names_hash): Pass free_demangled_name_entry to
+ htab_create_alloc.
+ (symbol_set_names): Update.
+
2019-10-21 Ali Tamur <tamu@google.com>
* dwarf2read.c (dir_index): Change type.
diff --git a/gdb/symtab.c b/gdb/symtab.c
index fc736fd..567d09d 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -68,6 +68,7 @@
#include "filename-seen-cache.h"
#include "arch-utils.h"
#include <algorithm>
+#include "gdbsupport/gdb_string_view.h"
#include "gdbsupport/pathstuff.h"
/* Forward declarations for local functions. */
@@ -713,7 +714,7 @@
/* Objects of this type are stored in the demangled name hash table. */
struct demangled_name_entry
{
- const char *mangled;
+ gdb::string_view mangled;
ENUM_BITFIELD(language) language : LANGUAGE_BITS;
char demangled[1];
};
@@ -726,7 +727,7 @@
const struct demangled_name_entry *e
= (const struct demangled_name_entry *) data;
- return htab_hash_string (e->mangled);
+ return iterative_hash (e->mangled.data (), e->mangled.length (), 0);
}
/* Equality function for the demangled name hash. */
@@ -739,7 +740,7 @@
const struct demangled_name_entry *db
= (const struct demangled_name_entry *) b;
- return strcmp (da->mangled, db->mangled) == 0;
+ return da->mangled == db->mangled;
}
/* Create the hash table used for demangled names. Each hash entry is
@@ -855,7 +856,7 @@
else
linkage_name_copy = linkage_name;
- entry.mangled = linkage_name_copy;
+ entry.mangled = gdb::string_view (linkage_name_copy, len);
slot = ((struct demangled_name_entry **)
htab_find_slot (per_bfd->demangled_names_hash.get (),
&entry, INSERT));
@@ -888,7 +889,7 @@
obstack_alloc (&per_bfd->storage_obstack,
offsetof (struct demangled_name_entry, demangled)
+ demangled_len + 1));
- (*slot)->mangled = linkage_name;
+ (*slot)->mangled = gdb::string_view (linkage_name, len);
}
else
{
@@ -904,7 +905,7 @@
+ len + demangled_len + 2));
mangled_ptr = &((*slot)->demangled[demangled_len + 1]);
strcpy (mangled_ptr, linkage_name_copy);
- (*slot)->mangled = mangled_ptr;
+ (*slot)->mangled = gdb::string_view (mangled_ptr, len);
}
(*slot)->language = gsymbol->language;
@@ -917,7 +918,7 @@
|| gsymbol->language == language_auto)
gsymbol->language = (*slot)->language;
- gsymbol->name = (*slot)->mangled;
+ gsymbol->name = (*slot)->mangled.data ();
if ((*slot)->demangled[0] != '\0')
symbol_set_demangled_name (gsymbol, (*slot)->demangled,
&per_bfd->storage_obstack);
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2019-10-22 17:55 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <gerrit.1571050562000.I24711ae2bcaa9e79ca89a6f8fda385d400419175@gnutoolchain-gerrit.osci.io>
2019-10-16 13:08 ` [review] Store the mangled name as a string_view Christian Biesinger (Code Review)
2019-10-21 20:15 ` [review v3] " Christian Biesinger (Code Review)
2019-10-21 22:39 ` Simon Marchi (Code Review)
2019-10-21 22:51 ` [review v4] " Christian Biesinger (Code Review)
2019-10-21 23:13 ` [review v5] " Christian Biesinger (Code Review)
2019-10-21 23:13 ` Christian Biesinger (Code Review)
2019-10-22 4:15 ` Simon Marchi (Code Review)
2019-10-22 16:06 ` Tom Tromey (Code Review)
2019-10-22 16:17 ` Christian Biesinger (Code Review)
2019-10-22 16:47 ` [review v6] " Christian Biesinger (Code Review)
2019-10-22 17:55 ` [pushed] " 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).