|
|
475228 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
475228 |
From: Keith Seitz <keiths@redhat.com>
|
|
|
475228 |
Date: Tue, 30 Jul 2019 10:46:38 -0700
|
|
|
475228 |
Subject: gdb-sw24545-perf-regression.patch
|
|
|
475228 |
|
|
|
475228 |
;; Fix 8.3 symbol-reading performance regression
|
|
|
475228 |
;; symtab/24545 (Tom de Vries)
|
|
|
475228 |
|
|
|
475228 |
commit e99f9db0f5211455ca4256e8db9d9081967d255e
|
|
|
475228 |
Author: Tom de Vries <tdevries@suse.de>
|
|
|
475228 |
Date: Mon Jun 10 20:05:04 2019 +0200
|
|
|
475228 |
|
|
|
475228 |
[gdb/symtab] Fix symbol loading performance regression
|
|
|
475228 |
|
|
|
475228 |
The commit "[gdb/symtab] Fix language of duplicate static minimal symbol"
|
|
|
475228 |
introduces a performance regression, when loading a cc1 executable build with
|
|
|
475228 |
-O0 -g and gcc 7.4.0. The performance regression, measured in 'real' time is
|
|
|
475228 |
about 175%.
|
|
|
475228 |
|
|
|
475228 |
The slower execution comes from the fact that the fix in symbol_set_names
|
|
|
475228 |
makes the call to symbol_find_demangled_name unconditional.
|
|
|
475228 |
|
|
|
475228 |
Fix this by reverting the commit, and redoing the fix as follows.
|
|
|
475228 |
|
|
|
475228 |
Recapturing the original problem, the first time symbol_set_names is called
|
|
|
475228 |
with gsymbol.language == lang_auto and linkage_name == "_ZL3foov", the name is
|
|
|
475228 |
not present in the per_bfd->demangled_names_hash hash table, so
|
|
|
475228 |
symbol_find_demangled_name is called to demangle the name, after which the
|
|
|
475228 |
mangled/demangled pair is added to the hashtable. The call to
|
|
|
475228 |
symbol_find_demangled_name also sets gsymbol.language to lang_cplus.
|
|
|
475228 |
The second time symbol_set_names is called with gsymbol.language == lang_auto
|
|
|
475228 |
and linkage_name == "_ZL3foov", the name is present in the hash table, so the
|
|
|
475228 |
demangled name from the hash table is used. However, the language of the
|
|
|
475228 |
symbol remains lang_auto.
|
|
|
475228 |
|
|
|
475228 |
Fix this by adding a field language in struct demangled_name_entry, and using
|
|
|
475228 |
the field in symbol_set_names to set the language of gsymbol, if necessary.
|
|
|
475228 |
|
|
|
475228 |
Tested on x86_64-linux.
|
|
|
475228 |
|
|
|
475228 |
gdb/ChangeLog:
|
|
|
475228 |
|
|
|
475228 |
2019-06-10 Tom de Vries <tdevries@suse.de>
|
|
|
475228 |
|
|
|
475228 |
PR symtab/24545
|
|
|
475228 |
* symtab.c (struct demangled_name_entry): Add language field.
|
|
|
475228 |
(symbol_set_names): Revert "[gdb/symtab] Fix language of duplicate
|
|
|
475228 |
static minimal symbol". Set and use language field.
|
|
|
475228 |
|
|
|
475228 |
diff --git a/gdb/symtab.c b/gdb/symtab.c
|
|
|
475228 |
--- a/gdb/symtab.c
|
|
|
475228 |
+++ b/gdb/symtab.c
|
|
|
475228 |
@@ -701,6 +701,7 @@ symbol_set_language (struct general_symbol_info *gsymbol,
|
|
|
475228 |
struct demangled_name_entry
|
|
|
475228 |
{
|
|
|
475228 |
const char *mangled;
|
|
|
475228 |
+ ENUM_BITFIELD(language) language : LANGUAGE_BITS;
|
|
|
475228 |
char demangled[1];
|
|
|
475228 |
};
|
|
|
475228 |
|
|
|
475228 |
@@ -841,11 +842,6 @@ symbol_set_names (struct general_symbol_info *gsymbol,
|
|
|
475228 |
else
|
|
|
475228 |
linkage_name_copy = linkage_name;
|
|
|
475228 |
|
|
|
475228 |
- /* Set the symbol language. */
|
|
|
475228 |
- char *demangled_name_ptr
|
|
|
475228 |
- = symbol_find_demangled_name (gsymbol, linkage_name_copy);
|
|
|
475228 |
- gdb::unique_xmalloc_ptr<char> demangled_name (demangled_name_ptr);
|
|
|
475228 |
-
|
|
|
475228 |
entry.mangled = linkage_name_copy;
|
|
|
475228 |
slot = ((struct demangled_name_entry **)
|
|
|
475228 |
htab_find_slot (per_bfd->demangled_names_hash,
|
|
|
475228 |
@@ -858,6 +854,9 @@ symbol_set_names (struct general_symbol_info *gsymbol,
|
|
|
475228 |
|| (gsymbol->language == language_go
|
|
|
475228 |
&& (*slot)->demangled[0] == '\0'))
|
|
|
475228 |
{
|
|
|
475228 |
+ char *demangled_name_ptr
|
|
|
475228 |
+ = symbol_find_demangled_name (gsymbol, linkage_name_copy);
|
|
|
475228 |
+ gdb::unique_xmalloc_ptr<char> demangled_name (demangled_name_ptr);
|
|
|
475228 |
int demangled_len = demangled_name ? strlen (demangled_name.get ()) : 0;
|
|
|
475228 |
|
|
|
475228 |
/* Suppose we have demangled_name==NULL, copy_name==0, and
|
|
|
475228 |
@@ -894,12 +893,16 @@ symbol_set_names (struct general_symbol_info *gsymbol,
|
|
|
475228 |
strcpy (mangled_ptr, linkage_name_copy);
|
|
|
475228 |
(*slot)->mangled = mangled_ptr;
|
|
|
475228 |
}
|
|
|
475228 |
+ (*slot)->language = gsymbol->language;
|
|
|
475228 |
|
|
|
475228 |
if (demangled_name != NULL)
|
|
|
475228 |
- strcpy ((*slot)->demangled, demangled_name.get());
|
|
|
475228 |
+ strcpy ((*slot)->demangled, demangled_name.get ());
|
|
|
475228 |
else
|
|
|
475228 |
(*slot)->demangled[0] = '\0';
|
|
|
475228 |
}
|
|
|
475228 |
+ else if (gsymbol->language == language_unknown
|
|
|
475228 |
+ || gsymbol->language == language_auto)
|
|
|
475228 |
+ gsymbol->language = (*slot)->language;
|
|
|
475228 |
|
|
|
475228 |
gsymbol->name = (*slot)->mangled;
|
|
|
475228 |
if ((*slot)->demangled[0] != '\0')
|