aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-03-03 10:15:30 -0700
committerTom Tromey <tom@tromey.com>2019-11-26 14:02:58 -0700
commitd55c9a68473d4378e484a870d3ca4222a68078ca (patch)
tree481619709ee6a4382df2f8b48d6d9835d942a31a /gdb/symtab.c
parenta0b57563b1317e0000a67a7bed4c1712403682f3 (diff)
downloadfsf-binutils-gdb-d55c9a68473d4378e484a870d3ca4222a68078ca.zip
fsf-binutils-gdb-d55c9a68473d4378e484a870d3ca4222a68078ca.tar.gz
fsf-binutils-gdb-d55c9a68473d4378e484a870d3ca4222a68078ca.tar.bz2
Demangle minsyms in parallel
This patch introduces a simple parallel for_each and changes the minimal symbol reader to use it when computing the demangled name for a minimal symbol. This yields a speedup when reading minimal symbols. 2019-11-26 Christian Biesinger <cbiesinger@google.com> Tom Tromey <tom@tromey.com> * minsyms.c (minimal_symbol_reader::install): Use parallel_for_each. * gdbsupport/parallel-for.h: New file. * Makefile.in (HFILES_NO_SRCDIR): Add gdbsupport/parallel-for.h. Change-Id: I220341f70e94dd02df5dd424272c50a5afb64978
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 711f8ef..b5c8109 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -787,13 +787,9 @@ create_demangled_names_hash (struct objfile_per_bfd_storage *per_bfd)
free_demangled_name_entry, xcalloc, xfree));
}
-/* Try to determine the demangled name for a symbol, based on the
- language of that symbol. If the language is set to language_auto,
- it will attempt to find any demangling algorithm that works and
- then set the language appropriately. The returned name is allocated
- by the demangler and should be xfree'd. */
+/* See symtab.h */
-static char *
+char *
symbol_find_demangled_name (struct general_symbol_info *gsymbol,
const char *mangled)
{
@@ -894,8 +890,15 @@ symbol_set_names (struct general_symbol_info *gsymbol,
else
linkage_name_copy = linkage_name;
- gdb::unique_xmalloc_ptr<char> demangled_name_ptr
- (symbol_find_demangled_name (gsymbol, linkage_name_copy.data ()));
+ /* The const_cast is safe because the only reason it is already
+ initialized is if we purposefully set it from a background
+ thread to avoid doing the work here. However, it is still
+ allocated from the heap and needs to be freed by us, just
+ like if we called symbol_find_demangled_name here. */
+ gdb::unique_xmalloc_ptr<char> demangled_name
+ (gsymbol->language_specific.demangled_name
+ ? const_cast<char *> (gsymbol->language_specific.demangled_name)
+ : symbol_find_demangled_name (gsymbol, linkage_name_copy.data ()));
/* Suppose we have demangled_name==NULL, copy_name==0, and
linkage_name_copy==linkage_name. In this case, we already have the
@@ -929,7 +932,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
new (*slot) demangled_name_entry
(gdb::string_view (mangled_ptr, linkage_name.length ()));
}
- (*slot)->demangled = std::move (demangled_name_ptr);
+ (*slot)->demangled = std::move (demangled_name);
(*slot)->language = gsymbol->language;
}
else if (gsymbol->language == language_unknown