diff options
author | Doug Evans <xdje42@gmail.com> | 2014-11-06 22:50:12 -0800 |
---|---|---|
committer | Doug Evans <xdje42@gmail.com> | 2014-11-06 22:50:12 -0800 |
commit | 358d6ab39c95691e721820fd54e9780208faf252 (patch) | |
tree | 202ffc1baa8eefa831df7e716f707ad08697722c | |
parent | 16b2eaa164b48aa0529304eec38102f1c60578be (diff) | |
download | gdb-358d6ab39c95691e721820fd54e9780208faf252.zip gdb-358d6ab39c95691e721820fd54e9780208faf252.tar.gz gdb-358d6ab39c95691e721820fd54e9780208faf252.tar.bz2 |
New macro ALL_BLOCK_SYMBOLS_WITH_NAME.
gdb/ChangeLog:
* block.h (ALL_BLOCK_SYMBOLS_WITH_NAME): New macro.
* block.c (block_lookup_symbol): Use it.
* cp-support.c (make_symbol_overload_list_block): Use it.
* symtab.c (iterate_over_symbols): Use it.
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/block.c | 8 | ||||
-rw-r--r-- | gdb/block.h | 9 | ||||
-rw-r--r-- | gdb/cp-support.c | 4 | ||||
-rw-r--r-- | gdb/symtab.c | 4 |
5 files changed, 20 insertions, 12 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index dc78a6a..d6125d7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2014-11-06 Doug Evans <xdje42@gmail.com> + * block.h (ALL_BLOCK_SYMBOLS_WITH_NAME): New macro. + * block.c (block_lookup_symbol): Use it. + * cp-support.c (make_symbol_overload_list_block): Use it. + * symtab.c (iterate_over_symbols): Use it. + +2014-11-06 Doug Evans <xdje42@gmail.com> + * symtab.c (lookup_block_symbol): Moved to ... * block.c (block_lookup_symbol): ... here and renamed. All callers updated. diff --git a/gdb/block.c b/gdb/block.c index 3bb9de0..1cb9875 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -706,9 +706,7 @@ block_lookup_symbol (const struct block *block, const char *name, if (!BLOCK_FUNCTION (block)) { - 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)) @@ -726,9 +724,7 @@ block_lookup_symbol (const struct block *block, const char *name, struct symbol *sym_found = NULL; - 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)) 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 d35920c..72ffb52 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 482a23d..9add71f 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2031,9 +2031,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)) |