[28/28] Remove enter_symbol_lookup

Message ID 20250311-search-in-psyms-v1-28-d73d9be20983@tromey.com
State New
Headers
Series Search symbols via quick API |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm fail Test failed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 fail Test failed

Commit Message

Tom Tromey March 11, 2025, 2:13 p.m. UTC
  The "enter_symbol_lookup" class was introduced to work around the lack
of reentrancy in symbol lookup.  There were two problems here:

1. The DWARF reader kept a mark bit on the dwarf2_per_cu_data object.
   This bit is gone now, replaced with a local mark vector.

2. Some spots in gdb first examined the expanded symbol tables, and
   then on failure expanded some symtabs and searched the newly
   expanded ones (skipping previousy-expanded ones).  Fixing this has
   been the main point of this series.

Now that both of these barriers are gone, I think enter_symbol_lookup
can be removed.

One proof of this idea is that, without the first fix mentioned above,
py-symbol.exp regressed because gdbpy_lookup_static_symbols did not
first ensure that the current language was set -- i.e., there was a
latent bug in the enter_symbol_lookup patch anyway.
---
 gdb/symtab.c | 41 -----------------------------------------
 1 file changed, 41 deletions(-)
  

Patch

diff --git a/gdb/symtab.c b/gdb/symtab.c
index c325432f7af0f1f6811916406e7c8b902c5852ee..32a6a5a34fbfa6ad44ccb6a8f5eba921701add34 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -124,41 +124,6 @@  struct main_info
 
 static const registry<program_space>::key<main_info> main_progspace_key;
 
-/* Symbol lookup is not reentrant (though this is not an intrinsic
-   restriction).  Keep track of whether a symbol lookup is active, to be able
-   to detect reentrancy.  */
-static bool in_symbol_lookup;
-
-/* Struct to mark that a symbol lookup is active for the duration of its
-   lifetime.  */
-
-struct enter_symbol_lookup
-{
-  enter_symbol_lookup ()
-  {
-    /* Ensure that the current language has been set.  Normally the
-       language is set lazily.  However, when performing a symbol lookup,
-       this could result in a recursive call into the lookup code in some
-       cases.  Set it now to ensure that this does not happen.  */
-    get_current_language ();
-
-    /* Detect symbol lookup reentrance.  */
-    gdb_assert (!in_symbol_lookup);
-
-    in_symbol_lookup = true;
-  }
-
-  ~enter_symbol_lookup ()
-  {
-    /* Sanity check.  */
-    gdb_assert (in_symbol_lookup);
-
-    in_symbol_lookup = false;
-  }
-
-  DISABLE_COPY_AND_ASSIGN (enter_symbol_lookup);
-};
-
 /* The default symbol cache size.
    There is no extra cpu cost for large N (except when flushing the cache,
    which is rare).  The value here is just a first attempt.  A better default
@@ -2294,8 +2259,6 @@  lookup_symbol_in_block (const char *name, symbol_name_match_type match_type,
 			const struct block *block,
 			const domain_search_flags domain)
 {
-  enter_symbol_lookup tmp;
-
   struct symbol *sym;
 
   if (symbol_lookup_debug)
@@ -2331,8 +2294,6 @@  lookup_global_symbol_from_objfile (struct objfile *main_objfile,
 				   const char *name,
 				   const domain_search_flags domain)
 {
-  enter_symbol_lookup tmp;
-
   gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
 
   for (objfile *objfile : main_objfile->separate_debug_objfiles ())
@@ -2633,8 +2594,6 @@  lookup_global_or_static_symbol (const char *name,
       return result;
     }
 
-  enter_symbol_lookup tmp;
-
   /* Do a global search (of global blocks, heh).  */
   if (result.symbol == NULL)
     gdbarch_iterate_over_objfiles_in_search_order