Add 'domain' parameter to expand_symtabs_matching
authorTom Tromey <tom@tromey.com>
Sat, 17 Apr 2021 15:35:04 +0000 (09:35 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 17 Apr 2021 15:35:05 +0000 (09:35 -0600)
Currently, expand_symtabs_matching only accepts a search_domain
parameter.  However, lookup_symbol uses a domain_enum instead, and the
two, confusingly, do quite different things -- one cannot emulate the
other.  So, this patch adds a domain_enum parameter to
expand_symtabs_matching, with UNDEF_DOMAIN used as a wildcard.

This is another step toward replacing lookup_symbol with
expand_symtabs_matching.

gdb/ChangeLog
2021-04-17  Tom Tromey  <tom@tromey.com>

* symtab.c (global_symbol_searcher::expand_symtabs): Update.
* symmisc.c (maintenance_expand_symtabs): Update.
* symfile.c (expand_symtabs_matching): Update.
* symfile-debug.c (objfile::expand_symtabs_matching): Add 'domain'
parameter.
* quick-symbol.h (struct quick_symbol_functions)
<expand_symtabs_matching>: Add 'domain' parameter.
* psymtab.c (recursively_search_psymtabs)
(psymbol_functions::expand_symtabs_matching): Add 'domain'
parameter.
* psympriv.h (struct psymbol_functions) <expand_symtabs_matching>:
Add 'domain' parameter.
* objfiles.h (struct objfile) <expand_symtabs_matching>: Add
'domain' parameter.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* dwarf2/read.c (struct dwarf2_gdb_index)
<expand_symtabs_matching>: Add 'domain' parameter.
(struct dwarf2_debug_names_index) <expand_symtabs_matching>: Add
'domain' parameter.
(dw2_expand_symtabs_matching)
(dwarf2_gdb_index::expand_symtabs_matching)
(dw2_debug_names_iterator)
(dwarf2_debug_names_index::expand_symtabs_matching): Add 'domain'
parameter.

gdb/ChangeLog
gdb/dwarf2/read.c
gdb/linespec.c
gdb/objfiles.h
gdb/psympriv.h
gdb/psymtab.c
gdb/quick-symbol.h
gdb/symfile-debug.c
gdb/symfile.c
gdb/symmisc.c
gdb/symtab.c

index 3d27f68b93c1309b365c3cdad386b2f2deb7080e..31af446c5b611a8558380666f5942f4ee6398825 100644 (file)
@@ -1,3 +1,30 @@
+2021-04-17  Tom Tromey  <tom@tromey.com>
+
+       * symtab.c (global_symbol_searcher::expand_symtabs): Update.
+       * symmisc.c (maintenance_expand_symtabs): Update.
+       * symfile.c (expand_symtabs_matching): Update.
+       * symfile-debug.c (objfile::expand_symtabs_matching): Add 'domain'
+       parameter.
+       * quick-symbol.h (struct quick_symbol_functions)
+       <expand_symtabs_matching>: Add 'domain' parameter.
+       * psymtab.c (recursively_search_psymtabs)
+       (psymbol_functions::expand_symtabs_matching): Add 'domain'
+       parameter.
+       * psympriv.h (struct psymbol_functions) <expand_symtabs_matching>:
+       Add 'domain' parameter.
+       * objfiles.h (struct objfile) <expand_symtabs_matching>: Add
+       'domain' parameter.
+       * linespec.c (iterate_over_all_matching_symtabs): Update.
+       * dwarf2/read.c (struct dwarf2_gdb_index)
+       <expand_symtabs_matching>: Add 'domain' parameter.
+       (struct dwarf2_debug_names_index) <expand_symtabs_matching>: Add
+       'domain' parameter.
+       (dw2_expand_symtabs_matching)
+       (dwarf2_gdb_index::expand_symtabs_matching)
+       (dw2_debug_names_iterator)
+       (dwarf2_debug_names_index::expand_symtabs_matching): Add 'domain'
+       parameter.
+
 2021-04-17  Tom Tromey  <tom@tromey.com>
 
        * symtab.c (global_symbol_searcher::expand_symtabs)
index 824945a95bcd79a80765b15a1639bcece68df21a..43d276f47360447bfe36bae4a10ecfa462a52ec4 100644 (file)
@@ -2290,6 +2290,7 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions
      gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
+     domain_enum domain,
      enum search_domain kind) override;
 };
 
@@ -2320,6 +2321,7 @@ struct dwarf2_debug_names_index : public dwarf2_base_index_functions
      gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
+     domain_enum domain,
      enum search_domain kind) override;
 };
 
@@ -4878,6 +4880,7 @@ dwarf2_gdb_index::expand_symtabs_matching
      gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
+     domain_enum domain,
      enum search_domain kind)
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
@@ -5398,8 +5401,10 @@ public:
 
   dw2_debug_names_iterator (const mapped_debug_names &map,
                            search_domain search, uint32_t namei,
-                           dwarf2_per_objfile *per_objfile)
+                           dwarf2_per_objfile *per_objfile,
+                           domain_enum domain = UNDEF_DOMAIN)
     : m_map (map),
+      m_domain (domain),
       m_search (search),
       m_addr (find_vec_in_debug_names (map, namei, per_objfile)),
       m_per_objfile (per_objfile)
@@ -5950,6 +5955,7 @@ dwarf2_debug_names_index::expand_symtabs_matching
    gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
    gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
    block_search_flags search_flags,
+   domain_enum domain,
    enum search_domain kind)
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
@@ -5983,7 +5989,7 @@ dwarf2_debug_names_index::expand_symtabs_matching
     {
       /* The name was matched, now expand corresponding CUs that were
         marked.  */
-      dw2_debug_names_iterator iter (map, kind, namei, per_objfile);
+      dw2_debug_names_iterator iter (map, kind, namei, per_objfile, domain);
 
       struct dwarf2_per_cu_data *per_cu;
       while ((per_cu = iter.next ()) != NULL)
index f37861b343ae8ff4742584a2b3e43ff9742a2779..03a11fda214c842838978b449ea21302bb1c0555 100644 (file)
@@ -1172,6 +1172,7 @@ iterate_over_all_matching_symtabs
          objfile->expand_symtabs_matching (NULL, &lookup_name, NULL, NULL,
                                            (SEARCH_GLOBAL_BLOCK
                                             | SEARCH_STATIC_BLOCK),
+                                           UNDEF_DOMAIN,
                                            search_domain);
 
          for (compunit_symtab *cu : objfile->compunits ())
index 9a194c1d8d47e7b08a7da618bf098e674bc714e9..ec64b1c3a9838e388481d9e4a1c82711c9cbde81 100644 (file)
@@ -609,6 +609,7 @@ public:
      gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
+     domain_enum domain,
      enum search_domain kind);
 
   /* See quick_symbol_functions.  */
index 70a397f8167b0b31c159a75e6bfe9b03df7ebb04..25f3fe500fa2c7dc8705ff19093a6fec00c3f3ab 100644 (file)
@@ -548,6 +548,7 @@ struct psymbol_functions : public quick_symbol_functions
      gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
+     domain_enum domain,
      enum search_domain kind) override;
 
   struct compunit_symtab *find_pc_sect_compunit_symtab
index c346116829432879f8478a046d78b846d3a6a89f..c766107504d13eb049a4b221c1d228cf8bacf2af 100644 (file)
@@ -1208,7 +1208,8 @@ recursively_search_psymtabs
   (struct partial_symtab *ps,
    struct objfile *objfile,
    block_search_flags search_flags,
-   enum search_domain domain,
+   domain_enum domain,
+   enum search_domain search,
    const lookup_name_info &lookup_name,
    gdb::function_view<expand_symtabs_symbol_matcher_ftype> sym_matcher)
 {
@@ -1230,7 +1231,7 @@ recursively_search_psymtabs
        continue;
 
       r = recursively_search_psymtabs (ps->dependencies[i],
-                                      objfile, search_flags, domain,
+                                      objfile, search_flags, domain, search,
                                       lookup_name, sym_matcher);
       if (r != 0)
        {
@@ -1278,16 +1279,19 @@ recursively_search_psymtabs
        {
          QUIT;
 
-         if ((domain == ALL_DOMAIN
-              || (domain == MODULES_DOMAIN
-                  && (*psym)->domain == MODULE_DOMAIN)
-              || (domain == VARIABLES_DOMAIN
-                  && (*psym)->aclass != LOC_TYPEDEF
-                  && (*psym)->aclass != LOC_BLOCK)
-              || (domain == FUNCTIONS_DOMAIN
-                  && (*psym)->aclass == LOC_BLOCK)
-              || (domain == TYPES_DOMAIN
-                  && (*psym)->aclass == LOC_TYPEDEF))
+         if ((domain == UNDEF_DOMAIN
+              || symbol_matches_domain ((*psym)->ginfo.language (),
+                                        (*psym)->domain, domain))
+             && (search == ALL_DOMAIN
+                 || (search == MODULES_DOMAIN
+                     && (*psym)->domain == MODULE_DOMAIN)
+                 || (search == VARIABLES_DOMAIN
+                     && (*psym)->aclass != LOC_TYPEDEF
+                     && (*psym)->aclass != LOC_BLOCK)
+                 || (search == FUNCTIONS_DOMAIN
+                     && (*psym)->aclass == LOC_BLOCK)
+                 || (search == TYPES_DOMAIN
+                     && (*psym)->aclass == LOC_TYPEDEF))
              && psymbol_name_matches (*psym, lookup_name)
              && (sym_matcher == NULL
                  || sym_matcher ((*psym)->ginfo.search_name ())))
@@ -1315,7 +1319,8 @@ psymbol_functions::expand_symtabs_matching
    gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
    gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
    block_search_flags search_flags,
-   enum search_domain domain)
+   domain_enum domain,
+   enum search_domain search)
 {
   /* Clear the search flags.  */
   for (partial_symtab *ps : require_partial_symbols (objfile))
@@ -1353,7 +1358,8 @@ psymbol_functions::expand_symtabs_matching
        }
 
       if ((symbol_matcher == NULL && lookup_name == NULL)
-         || recursively_search_psymtabs (ps, objfile, search_flags, domain,
+         || recursively_search_psymtabs (ps, objfile, search_flags,
+                                         domain, search,
                                          *psym_lookup_name,
                                          symbol_matcher))
        {
index 3332d329e0230cd81ee9a9c3a71d436819a1ca0f..4c0ef73547278a0a97049097af86f46cf3c77861 100644 (file)
@@ -202,7 +202,8 @@ struct quick_symbol_functions
 
      Otherwise, individual symbols are considered.
 
-     If KIND does not match, the symbol is skipped.
+     If DOMAIN or KIND do not match, the symbol is skipped.
+     If DOMAIN is UNDEF_DOMAIN, that is treated as a wildcard.
 
      If the symbol name does not match LOOKUP_NAME, the symbol is skipped.
 
@@ -220,6 +221,7 @@ struct quick_symbol_functions
      gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
+     domain_enum domain,
      enum search_domain kind) = 0;
 
   /* Return the comp unit from OBJFILE that contains PC and
index b1763243534f3c0eba7ee3c6011999ee5b62c33e..577b0fcd86c576c79b31db50811ed4014317c199 100644 (file)
@@ -272,6 +272,7 @@ objfile::expand_symtabs_matching
    gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
    gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
    block_search_flags search_flags,
+   domain_enum domain,
    enum search_domain kind)
 {
   if (debug_symfile)
@@ -286,7 +287,7 @@ objfile::expand_symtabs_matching
   for (const auto &iter : qf)
     if (!iter->expand_symtabs_matching (this, file_matcher, lookup_name,
                                        symbol_matcher, expansion_notify,
-                                       search_flags, kind))
+                                       search_flags, domain, kind))
       return false;
   return true;
 }
index 5f83cbf67c8ff0dbf22429eb1cf4ccad3612b537..7dfe1ee1ca0153e0252591f29eb0c9b41afb72d9 100644 (file)
@@ -3731,6 +3731,7 @@ expand_symtabs_matching
                                           symbol_matcher,
                                           expansion_notify,
                                           search_flags,
+                                          UNDEF_DOMAIN,
                                           kind))
       return false;
   return true;
index 33657f88fa9e0dddcd6f42a295326425fec453e3..d992c67163554f16cee3a0a71c9b034868448454 100644 (file)
@@ -939,6 +939,7 @@ maintenance_expand_symtabs (const char *args, int from_tty)
         NULL,
         NULL,
         SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
+        UNDEF_DOMAIN,
         ALL_DOMAIN);
 }
 \f
index a34207fc74bb1ef8821901d1e95ba0a56d9339d4..274ddfd1dae26763050d048c9ecbebb6d8046b09 100644 (file)
@@ -4548,6 +4548,7 @@ global_symbol_searcher::expand_symtabs
      },
      NULL,
      SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
+     UNDEF_DOMAIN,
      kind);
 
   /* Here, we search through the minimal symbol tables for functions and