]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Convert default_collect_symbol_completion_matches_break_on
authorTom Tromey <tom@tromey.com>
Thu, 19 Dec 2024 02:18:22 +0000 (19:18 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 10 Sep 2025 22:05:28 +0000 (16:05 -0600)
This converts default_collect_symbol_completion_matches_break_on 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/symtab.c

index 134160752003f4508a73b32b7d56cf110d35bec0..9f6797118b5d0435af829e721172fba8bc7de8e6 100644 (file)
@@ -6120,25 +6120,20 @@ default_collect_symbol_completion_matches_break_on
   /* Add completions for all currently loaded symbol tables.  */
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      for (compunit_symtab *cust : objfile->compunits ())
-       add_symtab_completions (cust, tracker, mode, lookup_name,
-                               sym_text, word, code);
-    }
-
-  /* Look through the partial symtabs for all symbols which begin by
-     matching SYM_TEXT.  Expand all CUs that you find to the list.  */
-  expand_symtabs_matching (NULL,
-                          lookup_name,
-                          NULL,
-                          [&] (compunit_symtab *symtab) /* expansion notify */
-                            {
-                              add_symtab_completions (symtab,
-                                                      tracker, mode, lookup_name,
-                                                      sym_text, word, code);
-                              return true;
-                            },
-                          SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
-                          SEARCH_ALL_DOMAINS);
+      /* Look through the partial symtabs for all symbols which begin by
+        matching SYM_TEXT.  Expand all CUs that you find to the list.  */
+      objfile->expand_symtabs_matching
+       (nullptr, &lookup_name, nullptr,
+        [&] (compunit_symtab *symtab)
+          {
+            add_symtab_completions (symtab,
+                                    tracker, mode, lookup_name,
+                                    sym_text, word, code);
+            return true;
+          },
+        SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
+        SEARCH_ALL_DOMAINS);
+    }
 
   /* Search upwards from currently selected frame (so that we can
      complete on local vars).  Also catch fields of types defined in