]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Convert ada_add_global_exceptions
authorTom Tromey <tom@tromey.com>
Sun, 8 Dec 2024 00:28:06 +0000 (17:28 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 10 Sep 2025 22:07:49 +0000 (16:07 -0600)
This converts ada_add_global_exceptions to the callback approach,
merging the search loop and the call to expand_symtabs_matching.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998
Acked-By: Simon Marchi <simon.marchi@efficios.com>
gdb/ada-lang.c

index c004ecb9b7fe79629986761bbebe9dde32d3055b..d19dd721e521d67e2b6f2a491d0d82386cbdb1ca 100644 (file)
@@ -13101,31 +13101,11 @@ ada_add_global_exceptions (compiled_regex *preg,
       return preg == nullptr || preg->exec (name, 0, NULL, 0) == 0;
     };
 
-
-  /* In Ada, the symbol "search name" is a linkage name, whereas the
-     regular expression used to do the matching refers to the natural
-     name.  So match against the decoded name.  */
-  expand_symtabs_matching (NULL,
-                          lookup_name_info::match_any (),
-                          [&] (const char *search_name)
-                          {
-                            std::string decoded = ada_decode (search_name);
-                            return name_matches_regex (decoded.c_str ());
-                          },
-                          NULL,
-                          SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
-                          SEARCH_VAR_DOMAIN,
-                          [&] (enum language lang)
-                            {
-                              /* Try to skip non-Ada CUs.  */
-                              return lang == language_ada;
-                            });
-
   /* Iterate over all objfiles irrespective of scope or linker namespaces
      so we get all exceptions anywhere in the progspace.  */
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      for (compunit_symtab *s : objfile->compunits ())
+      auto callback = [&] (compunit_symtab *s)
        {
          const struct blockvector *bv = s->blockvector ();
          int i;
@@ -13144,7 +13124,30 @@ ada_add_global_exceptions (compiled_regex *preg,
                    exceptions->push_back (info);
                  }
            }
-       }
+
+         return true;
+       };
+
+      /* In Ada, the symbol "search name" is a linkage name, whereas
+        the regular expression used to do the matching refers to the
+        natural name.  So match against the decoded name.  */
+      auto any = lookup_name_info::match_any ();
+      objfile->expand_symtabs_matching
+       (nullptr,
+        &any,
+        [&] (const char *search_name)
+          {
+            std::string decoded = ada_decode (search_name);
+            return name_matches_regex (decoded.c_str ());
+          },
+        callback,
+        SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
+        SEARCH_VAR_DOMAIN,
+        [&] (enum language lang)
+          {
+            /* Try to skip non-Ada CUs.  */
+            return lang == language_ada;
+          });
     }
 }