2012-02-01 Gary Benson <gbenson@redhat.com>
authorGary Benson <gary@redhat.com>
Wed, 1 Feb 2012 16:10:31 +0000 (16:10 +0000)
committerGary Benson <gary@redhat.com>
Wed, 1 Feb 2012 16:10:31 +0000 (16:10 +0000)
* symtab.h (symbol_name_match_p_ftype): New typedef.
(iterate_over_symbols): Use the above.
* symtab.c (iterate_over_symbols): Likewise.
* language.h (language_defn->la_iterate_over_symbols): Likewise.
* ada-lang.c (ada_iterate_over_symbols): Likewise.
* linespec.c (iterate_over_all_matching_symtabs): Likewise.
(iterate_name_matcher): Document return values.
(collect_one_symbol): Likewise.
(collect_function_symbols): Likewise.
(collect_symbols): Likewise.

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

index 56016c9a9b9d7dd7405b0afcd8b52f3d0956f65d..055fdd2ac54fbff1ae8ce99ebd024fa430d662e0 100644 (file)
@@ -1,3 +1,16 @@
+2012-02-01  Gary Benson  <gbenson@redhat.com>
+
+       * symtab.h (symbol_name_match_p_ftype): New typedef.
+       (iterate_over_symbols): Use the above.
+       * symtab.c (iterate_over_symbols): Likewise.
+       * language.h (language_defn->la_iterate_over_symbols): Likewise.
+       * ada-lang.c (ada_iterate_over_symbols): Likewise.
+       * linespec.c (iterate_over_all_matching_symtabs): Likewise.
+       (iterate_name_matcher): Document return values.
+       (collect_one_symbol): Likewise.
+       (collect_function_symbols): Likewise.
+       (collect_symbols): Likewise.
+
 2012-02-01  Tom Tromey  <tromey@redhat.com>
 
        * ada-lang.c (resolve_subexp): Update.
index de165fadf8df7759e51525d56b07f2c7acdccb6c..6ea013c3071a8e226ba7a75f6eb4bbd6c9c6f562 100644 (file)
@@ -5102,7 +5102,7 @@ ada_name_for_lookup (const char *name)
 static void
 ada_iterate_over_symbols (const struct block *block,
                          const char *name, domain_enum domain,
-                         int (*callback) (struct symbol *, void *),
+                         symbol_found_callback_ftype *callback,
                          void *data)
 {
   int ndefs, i;
index c27508394c168ec8b78a07b3755c328679eabb00..d4cce9578da8ad5505a58bd6ddc2fdee4e923ae2 100644 (file)
@@ -354,7 +354,7 @@ struct language_defn
     void (*la_iterate_over_symbols) (const struct block *block,
                                     const char *name,
                                     domain_enum domain,
-                                    int (*callback) (struct symbol *, void *),
+                                    symbol_found_callback_ftype *callback,
                                     void *data);
 
     /* Add fields above this point, so the magic number is always last.  */
index 50ebf6f8a166b70b5c9b2849afb8ded79dd226c9..4e427500a8b813f6fe485728a9b05ef971783a1e 100644 (file)
@@ -341,8 +341,8 @@ iterate_name_matcher (const char *name, void *d)
   const struct symbol_matcher_data *data = d;
 
   if (data->symbol_name_match_p (name, data->lookup_name) == 0)
-    return 1;
-  return 0;
+    return 1; /* Expand this symbol's symbol table.  */
+  return 0; /* Skip this symbol.  */
 }
 
 /* A helper that walks over all matching symtabs in all objfiles and
@@ -353,7 +353,7 @@ iterate_name_matcher (const char *name, void *d)
 static void
 iterate_over_all_matching_symtabs (const char *name,
                                   const domain_enum domain,
-                                  int (*callback) (struct symbol *, void *),
+                                  symbol_found_callback_ftype *callback,
                                   void *data,
                                   struct program_space *search_pspace)
 {
@@ -1808,14 +1808,14 @@ collect_one_symbol (struct symbol *sym, void *d)
   struct type *t;
 
   if (SYMBOL_CLASS (sym) != LOC_TYPEDEF)
-    return 1;
+    return 1; /* Continue iterating.  */
 
   t = SYMBOL_TYPE (sym);
   CHECK_TYPEDEF (t);
   if (TYPE_CODE (t) != TYPE_CODE_STRUCT
       && TYPE_CODE (t) != TYPE_CODE_UNION
       && TYPE_CODE (t) != TYPE_CODE_NAMESPACE)
-    return 1;
+    return 1; /* Continue iterating.  */
 
   slot = htab_find_slot (collector->unique_syms, sym, INSERT);
   if (!*slot)
@@ -1824,7 +1824,7 @@ collect_one_symbol (struct symbol *sym, void *d)
       VEC_safe_push (symbolp, collector->symbols, sym);
     }
 
-  return 1;
+  return 1; /* Continue iterating.  */
 }
 
 /* Return the symbol corresponding to the substring of *ARGPTR ending
@@ -2215,7 +2215,7 @@ collect_function_symbols (struct symbol *sym, void *arg)
   if (SYMBOL_CLASS (sym) == LOC_BLOCK)
     VEC_safe_push (symbolp, *syms, sym);
 
-  return 1;
+  return 1; /* Continue iterating.  */
 }
 
 /* Look up a function symbol in *ARGPTR.  If found, advance *ARGPTR
@@ -2722,7 +2722,7 @@ collect_symbols (struct symbol *sym, void *data)
     add_sal_to_sals (info->state, &info->result, &sal,
                     SYMBOL_NATURAL_NAME (sym));
 
-  return 1;
+  return 1; /* Continue iterating.  */
 }
 
 /* We've found a minimal symbol MSYMBOL to associate with our
index 216d6fe2a106338f0ce911ffbf7e3c133a541f50..c6314c907fbd6e79c4091a57c7994aad36069f32 100644 (file)
@@ -1900,7 +1900,7 @@ lookup_block_symbol (const struct block *block, const char *name,
 void
 iterate_over_symbols (const struct block *block, const char *name,
                      const domain_enum domain,
-                     int (*callback) (struct symbol *, void *),
+                     symbol_found_callback_ftype *callback,
                      void *data)
 {
   while (block)
index 5541402aff65150e48b3f907327d89b0a3ea1f14..d4cb337b79edf2ec9e9d6caa92f7b6581d905776 100644 (file)
@@ -1248,9 +1248,18 @@ DEF_VEC_I (CORE_ADDR);
 VEC (CORE_ADDR) *find_pcs_for_symtab_line (struct symtab *symtab, int line,
                                           struct linetable_entry **best_entry);
 
+/* Callback for LA_ITERATE_OVER_SYMBOLS.  The callback will be called
+   once per matching symbol SYM, with DATA being the argument of the
+   same name that was passed to LA_ITERATE_OVER_SYMBOLS.  The callback
+   should return nonzero to indicate that LA_ITERATE_OVER_SYMBOLS
+   should continue iterating, or zero to indicate that the iteration
+   should end.  */
+
+typedef int (symbol_found_callback_ftype) (struct symbol *sym, void *data);
+
 void iterate_over_symbols (const struct block *block, const char *name,
                           const domain_enum domain,
-                          int (*callback) (struct symbol *, void *),
+                          symbol_found_callback_ftype *callback,
                           void *data);
 
 struct cleanup *demangle_for_lookup (const char *name, enum language lang,