Change iterate_over_symbols to return bool
authorTom Tromey <tromey@adacore.com>
Fri, 12 Jul 2019 16:47:21 +0000 (10:47 -0600)
committerTom Tromey <tromey@adacore.com>
Tue, 10 Sep 2019 14:30:45 +0000 (08:30 -0600)
This changes iterate_over_symbols to return a bool.  This allows it to
be reused in another context in a subsequent patch.

gdb/ChangeLog
2019-09-10  Tom Tromey  <tromey@adacore.com>

* ada-lang.c (ada_iterate_over_symbols): Return bool.
* language.h (struct language_defn) <la_iterate_over_symbols>:
Return bool.
* symtab.c (iterate_over_symbols): Return bool.
* symtab.h (iterate_over_symbols): Return bool.

gdb/ChangeLog
gdb/ada-lang.c
gdb/language.h
gdb/symtab.c
gdb/symtab.h

index 1865eeddbbb1fae9f591b8352741a8bd861c4d3d..e2ebafe714cfef68ed5bd2a12f5f1e91e91b38f6 100644 (file)
@@ -1,3 +1,11 @@
+2019-09-10  Tom Tromey  <tromey@adacore.com>
+
+       * ada-lang.c (ada_iterate_over_symbols): Return bool.
+       * language.h (struct language_defn) <la_iterate_over_symbols>:
+       Return bool.
+       * symtab.c (iterate_over_symbols): Return bool.
+       * symtab.h (iterate_over_symbols): Return bool.
+
 2019-09-10  Tom Tromey  <tromey@adacore.com>
 
        * ada-lang.c (aux_add_nonlocal_symbols): Change type.
index d677acdb60e7066e9ea573f3fafaaeab5a38615e..21d40c7aad45d7215e83b4df0d5e27518ea38d91 100644 (file)
@@ -5740,7 +5740,7 @@ ada_lookup_symbol_list (const char *name, const struct block *block,
 
 /* Implementation of the la_iterate_over_symbols method.  */
 
-static void
+static bool
 ada_iterate_over_symbols
   (const struct block *block, const lookup_name_info &name,
    domain_enum domain,
@@ -5754,8 +5754,10 @@ ada_iterate_over_symbols
   for (i = 0; i < ndefs; ++i)
     {
       if (!callback (&results[i]))
-       break;
+       return false;
     }
+
+  return true;
 }
 
 /* The result is as for ada_lookup_symbol_list with FULL_SEARCH set
index 2a100b04917acd370c8e58c6572dd18b4fb66495..0088e5de2dd698ae050768f13dbf3f2bb11843fb 100644 (file)
@@ -407,7 +407,7 @@ struct language_defn
        This field may not be NULL.  If the language does not need any
        special processing here, 'iterate_over_symbols' should be
        used as the definition.  */
-    void (*la_iterate_over_symbols)
+    bool (*la_iterate_over_symbols)
       (const struct block *block, const lookup_name_info &name,
        domain_enum domain,
        gdb::function_view<symbol_found_callback_ftype> callback);
index 88e34de05be4ff70838bc79cfb236ab37a1edb11..5f184454bd153bdb16acd96e688cbd5b318cf10c 100644 (file)
@@ -2822,15 +2822,9 @@ basic_lookup_transparent_type (const char *name)
   return (struct type *) 0;
 }
 
-/* Iterate over the symbols named NAME, matching DOMAIN, in BLOCK.
-
-   For each symbol that matches, CALLBACK is called.  The symbol is
-   passed to the callback.
-
-   If CALLBACK returns false, the iteration ends.  Otherwise, the
-   search continues.  */
+/* See symtab.h.  */
 
-void
+bool
 iterate_over_symbols (const struct block *block,
                      const lookup_name_info &name,
                      const domain_enum domain,
@@ -2847,9 +2841,10 @@ iterate_over_symbols (const struct block *block,
          struct block_symbol block_sym = {sym, block};
 
          if (!callback (&block_sym))
-           return;
+           return false;
        }
     }
+  return true;
 }
 
 /* Find the compunit symtab associated with PC and SECTION.
index f38e544cdb46f4d5cf6347af88d95e3bc2efa32e..49feea62e2a5435c417818ef202d2a1481edfe8e 100644 (file)
@@ -2092,7 +2092,16 @@ std::vector<CORE_ADDR> find_pcs_for_symtab_line
 
 typedef bool (symbol_found_callback_ftype) (struct block_symbol *bsym);
 
-void iterate_over_symbols (const struct block *block,
+/* Iterate over the symbols named NAME, matching DOMAIN, in BLOCK.
+
+   For each symbol that matches, CALLBACK is called.  The symbol is
+   passed to the callback.
+
+   If CALLBACK returns false, the iteration ends and this function
+   returns false.  Otherwise, the search continues, and the function
+   eventually returns true.  */
+
+bool iterate_over_symbols (const struct block *block,
                           const lookup_name_info &name,
                           const domain_enum domain,
                           gdb::function_view<symbol_found_callback_ftype> callback);
This page took 0.056431 seconds and 4 git commands to generate.