aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-02-14 09:48:34 -0700
committerTom Tromey <tromey@adacore.com>2024-03-19 11:53:21 -0600
commit1ab9eefe3cea741aba17e11ff28ed48ac3a8293a (patch)
tree618699fc2561149ed37db02151ad2457c14339cf /gdb/symtab.c
parent12d5d5bfd0201711ac3b14d8cd92589919a82b7a (diff)
downloadgdb-1ab9eefe3cea741aba17e11ff28ed48ac3a8293a.zip
gdb-1ab9eefe3cea741aba17e11ff28ed48ac3a8293a.tar.gz
gdb-1ab9eefe3cea741aba17e11ff28ed48ac3a8293a.tar.bz2
Speed up lookup of "type_specific_data"
I noticed that "info locals" on a certain large Ada program was very slow. I tracked this down to ada_get_tsd_type expanding nearly every CU in the program. This patch fixes the problem by changing this code to use the more efficient lookup_transparent_type which, unlike the Ada-specific lookup functions, does not try to find all matching instances. Note that I first tried fixing this by changing ada_find_any_type, but this did not work -- I may revisit this approach at some later date. Also note that the copyright dates on the test files are set that way because I copied them from another test. New in v2: the new test failed on the Linaro regression tester. Looking at the logs, it seems that gdb was picking up a 'value' from libgnat: $1 = {<text variable, no debug info>} 0xf7e227a4 <ada.calendar.formatting.value> This version renames the local variable in an attempt to work around this. v3: In v2, while trying to reproduce the problem locally, I accidentally forgot to commit one of the changes.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index cd2bc8f..33b664f 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2694,9 +2694,9 @@ symbol::matches (domain_search_flags flags) const
/* See symtab.h. */
struct type *
-lookup_transparent_type (const char *name)
+lookup_transparent_type (const char *name, domain_search_flags flags)
{
- return current_language->lookup_transparent_type (name);
+ return current_language->lookup_transparent_type (name, flags);
}
/* A helper for basic_lookup_transparent_type that interfaces with the
@@ -2705,6 +2705,7 @@ lookup_transparent_type (const char *name)
static struct type *
basic_lookup_transparent_type_quick (struct objfile *objfile,
enum block_enum block_index,
+ domain_search_flags flags,
const lookup_name_info &name)
{
struct compunit_symtab *cust;
@@ -2712,14 +2713,14 @@ basic_lookup_transparent_type_quick (struct objfile *objfile,
const struct block *block;
struct symbol *sym;
- cust = objfile->lookup_symbol (block_index, name, SEARCH_STRUCT_DOMAIN);
+ cust = objfile->lookup_symbol (block_index, name, flags);
if (cust == NULL)
return NULL;
bv = cust->blockvector ();
block = bv->block (block_index);
- sym = block_find_symbol (block, name, SEARCH_STRUCT_DOMAIN, nullptr);
+ sym = block_find_symbol (block, name, flags, nullptr);
if (sym == nullptr)
error_in_psymtab_expansion (block_index, name.c_str (), cust);
gdb_assert (!TYPE_IS_OPAQUE (sym->type ()));
@@ -2733,6 +2734,7 @@ basic_lookup_transparent_type_quick (struct objfile *objfile,
static struct type *
basic_lookup_transparent_type_1 (struct objfile *objfile,
enum block_enum block_index,
+ domain_search_flags flags,
const lookup_name_info &name)
{
const struct blockvector *bv;
@@ -2743,7 +2745,7 @@ basic_lookup_transparent_type_1 (struct objfile *objfile,
{
bv = cust->blockvector ();
block = bv->block (block_index);
- sym = block_find_symbol (block, name, SEARCH_STRUCT_DOMAIN, nullptr);
+ sym = block_find_symbol (block, name, flags, nullptr);
if (sym != nullptr)
{
gdb_assert (!TYPE_IS_OPAQUE (sym->type ()));
@@ -2761,7 +2763,7 @@ basic_lookup_transparent_type_1 (struct objfile *objfile,
global blocks. */
struct type *
-basic_lookup_transparent_type (const char *name)
+basic_lookup_transparent_type (const char *name, domain_search_flags flags)
{
struct type *t;
@@ -2775,7 +2777,7 @@ basic_lookup_transparent_type (const char *name)
for (objfile *objfile : current_program_space->objfiles ())
{
t = basic_lookup_transparent_type_1 (objfile, GLOBAL_BLOCK,
- lookup_name);
+ flags, lookup_name);
if (t)
return t;
}
@@ -2783,7 +2785,7 @@ basic_lookup_transparent_type (const char *name)
for (objfile *objfile : current_program_space->objfiles ())
{
t = basic_lookup_transparent_type_quick (objfile, GLOBAL_BLOCK,
- lookup_name);
+ flags, lookup_name);
if (t)
return t;
}
@@ -2798,7 +2800,7 @@ basic_lookup_transparent_type (const char *name)
for (objfile *objfile : current_program_space->objfiles ())
{
t = basic_lookup_transparent_type_1 (objfile, STATIC_BLOCK,
- lookup_name);
+ flags, lookup_name);
if (t)
return t;
}
@@ -2806,7 +2808,7 @@ basic_lookup_transparent_type (const char *name)
for (objfile *objfile : current_program_space->objfiles ())
{
t = basic_lookup_transparent_type_quick (objfile, STATIC_BLOCK,
- lookup_name);
+ flags, lookup_name);
if (t)
return t;
}