This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/9] Add macro ALL_BLOCK_SYMBOLS_WITH_NAME.


Hi.

This patch adds macro ALL_BLOCK_SYMBOLS_WITH_NAME to go with
the ALL_BLOCK_SYMBOLS macro already in block.h.

2014-10-26  Doug Evans  <xdje42@gmail.com>

	* block.h (ALL_BLOCK_SYMBOLS_WITH_NAME): New macro.
	* cp-support.c (make_symbol_overload_list_block): Use it.
	* symtab.c (iterate_over_symbols): Use it.

diff --git a/gdb/block.h b/gdb/block.h
index e8d3452..50a7919 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -286,4 +286,13 @@ extern struct symbol *block_lookup_symbol (const struct block *block,
        (sym);						\
        (sym) = block_iterator_next (&(iter)))
 
+/* Macro to loop through all symbols with name NAME in BLOCK,
+   in no particular order.  ITER helps keep track of the iteration, and
+   must be a struct block_iterator.  SYM points to the current symbol.  */
+
+#define ALL_BLOCK_SYMBOLS_WITH_NAME(block, name, iter, sym)		\
+  for ((sym) = block_iter_name_first ((block), (name), &(iter));	\
+       (sym) != NULL;							\
+       (sym) = block_iter_name_next ((name), &(iter)))
+
 #endif /* BLOCK_H */
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index b475491..4abbb2e 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1218,9 +1218,7 @@ make_symbol_overload_list_block (const char *name,
   struct block_iterator iter;
   struct symbol *sym;
 
-  for (sym = block_iter_name_first (block, name, &iter);
-       sym != NULL;
-       sym = block_iter_name_next (name, &iter))
+  ALL_BLOCK_SYMBOLS_WITH_NAME (block, name, iter, sym)
     overload_list_add_symbol (sym, name);
 }
 
diff --git a/gdb/symtab.c b/gdb/symtab.c
index c27ea51..19753bc 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2029,9 +2029,7 @@ iterate_over_symbols (const struct block *block, const char *name,
   struct block_iterator iter;
   struct symbol *sym;
 
-  for (sym = block_iter_name_first (block, name, &iter);
-       sym != NULL;
-       sym = block_iter_name_next (name, &iter))
+  ALL_BLOCK_SYMBOLS_WITH_NAME (block, name, iter, sym)
     {
       if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
 				 SYMBOL_DOMAIN (sym), domain))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]