Eliminate block_iter_name_*
authorPedro Alves <palves@redhat.com>
Thu, 20 Jul 2017 17:04:46 +0000 (18:04 +0100)
committerPedro Alves <palves@redhat.com>
Thu, 20 Jul 2017 17:04:46 +0000 (18:04 +0100)
This patch gets rid of block_iter_name_* as being unnecessary.  It's
the same as calling block_iter_match_*, and passing strcmp_iw as
comparison routine.

(A later patch will get rid of those new explicit strcmp_iw calls.)

gdb/ChangeLog:
2017-07-20  Pedro Alves  <palves@redhat.com>

* block.c (block_iter_name_step, block_iter_name_first)
(block_iter_name_next): Delete.
(block_lookup_symbol_primary): Adjust to use
dict_iter_match_first/dict_iter_match_next.
* block.h (block_iter_name_first, block_iter_name_next): Delete
declarations.
(ALL_BLOCK_SYMBOLS_WITH_NAME): Adjust to use
dict_iter_match_first/dict_iter_match_next.

gdb/ChangeLog
gdb/block.c
gdb/block.h
gdb/dictionary.c
gdb/dictionary.h

index 41e01cd367c833193ddd79528b40f3aea167850d..f6acd346ee7b7a84f3eecc11e37dcd1ad544f509 100644 (file)
@@ -1,3 +1,14 @@
+2017-07-20  Pedro Alves  <palves@redhat.com>
+
+       * block.c (block_iter_name_step, block_iter_name_first)
+       (block_iter_name_next): Delete.
+       (block_lookup_symbol_primary): Adjust to use
+       dict_iter_match_first/dict_iter_match_next.
+       * block.h (block_iter_name_first, block_iter_name_next): Delete
+       declarations.
+       (ALL_BLOCK_SYMBOLS_WITH_NAME): Adjust to use
+       dict_iter_match_first/dict_iter_match_next.
+
 2017-07-20  Pedro Alves  <palves@redhat.com>
 
        * cp-support.c (cp_find_first_component_aux): Add missing case for
index 2f444605ff23ec42e331033061685c38e826e80d..1c343aade73aea255d5f642e52dd1f89dba22b69 100644 (file)
@@ -589,75 +589,6 @@ block_iterator_next (struct block_iterator *iterator)
   return block_iterator_step (iterator, 0);
 }
 
-/* Perform a single step for a "name" block iterator, iterating across
-   symbol tables as needed.  Returns the next symbol, or NULL when
-   iteration is complete.  */
-
-static struct symbol *
-block_iter_name_step (struct block_iterator *iterator, const char *name,
-                     int first)
-{
-  struct symbol *sym;
-
-  gdb_assert (iterator->which != FIRST_LOCAL_BLOCK);
-
-  while (1)
-    {
-      if (first)
-       {
-         struct compunit_symtab *cust
-           = find_iterator_compunit_symtab (iterator);
-         const struct block *block;
-
-         /* Iteration is complete.  */
-         if (cust == NULL)
-           return  NULL;
-
-         block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
-                                    iterator->which);
-         sym = dict_iter_name_first (BLOCK_DICT (block), name,
-                                     &iterator->dict_iter);
-       }
-      else
-       sym = dict_iter_name_next (name, &iterator->dict_iter);
-
-      if (sym != NULL)
-       return sym;
-
-      /* We have finished iterating the appropriate block of one
-        symtab.  Now advance to the next symtab and begin iteration
-        there.  */
-      ++iterator->idx;
-      first = 1;
-    }
-}
-
-/* See block.h.  */
-
-struct symbol *
-block_iter_name_first (const struct block *block,
-                      const char *name,
-                      struct block_iterator *iterator)
-{
-  initialize_block_iterator (block, iterator);
-
-  if (iterator->which == FIRST_LOCAL_BLOCK)
-    return dict_iter_name_first (block->dict, name, &iterator->dict_iter);
-
-  return block_iter_name_step (iterator, name, 1);
-}
-
-/* See block.h.  */
-
-struct symbol *
-block_iter_name_next (const char *name, struct block_iterator *iterator)
-{
-  if (iterator->which == FIRST_LOCAL_BLOCK)
-    return dict_iter_name_next (name, &iterator->dict_iter);
-
-  return block_iter_name_step (iterator, name, 0);
-}
-
 /* Perform a single step for a "match" block iterator, iterating
    across symbol tables as needed.  Returns the next symbol, or NULL
    when iteration is complete.  */
@@ -812,9 +743,9 @@ block_lookup_symbol_primary (const struct block *block, const char *name,
              || BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL);
 
   other = NULL;
-  for (sym = dict_iter_name_first (block->dict, name, &dict_iter);
+  for (sym = dict_iter_match_first (block->dict, name, strcmp_iw, &dict_iter);
        sym != NULL;
-       sym = dict_iter_name_next (name, &dict_iter))
+       sym = dict_iter_match_next (name, strcmp_iw, &dict_iter))
     {
       if (SYMBOL_DOMAIN (sym) == domain)
        return sym;
index eeb5ed43a76b162d07d84487734c82cc1ac99f37..1741e52c61abb06460ce9aad44dc7f3e2cad2c8c 100644 (file)
@@ -236,25 +236,6 @@ extern struct symbol *block_iterator_first (const struct block *block,
 
 extern struct symbol *block_iterator_next (struct block_iterator *iterator);
 
-/* Initialize ITERATOR to point at the first symbol in BLOCK whose
-   SYMBOL_SEARCH_NAME is NAME (as tested using strcmp_iw), and return
-   that first symbol, or NULL if there are no such symbols.  */
-
-extern struct symbol *block_iter_name_first (const struct block *block,
-                                            const char *name,
-                                            struct block_iterator *iterator);
-
-/* Advance ITERATOR to point at the next symbol in BLOCK whose
-   SYMBOL_SEARCH_NAME is NAME (as tested using strcmp_iw), or NULL if
-   there are no more such symbols.  Don't call this if you've
-   previously received NULL from block_iterator_first or
-   block_iterator_next on this iteration.  And don't call it unless
-   ITERATOR was created by a previous call to block_iter_name_first
-   with the same NAME.  */
-
-extern struct symbol *block_iter_name_next (const char *name,
-                                           struct block_iterator *iterator);
-
 /* Initialize ITERATOR to point at the first symbol in BLOCK whose
    SYMBOL_SEARCH_NAME is NAME, as tested using COMPARE (which must use
    the same conventions as strcmp_iw and be compatible with any
@@ -340,8 +321,9 @@ extern int block_find_non_opaque_type_preferred (struct symbol *sym,
    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));       \
+  for ((sym) = block_iter_match_first ((block), (name),                        \
+                                      strcmp_iw, &(iter));             \
        (sym) != NULL;                                                  \
-       (sym) = block_iter_name_next ((name), &(iter)))
+       (sym) = block_iter_match_next ((name), strcmp_iw, &(iter)))
 
 #endif /* BLOCK_H */
index e78db2ebe76757292a3c66311a1c35ed40dcd16d..b2cfca28ab0fff076f659c472e45473e3ad6b6f0 100644 (file)
@@ -529,20 +529,6 @@ dict_iterator_next (struct dict_iterator *iterator)
     ->iterator_next (iterator);
 }
 
-struct symbol *
-dict_iter_name_first (const struct dictionary *dict,
-                     const char *name,
-                     struct dict_iterator *iterator)
-{
-  return dict_iter_match_first (dict, name, strcmp_iw, iterator);
-}
-
-struct symbol *
-dict_iter_name_next (const char *name, struct dict_iterator *iterator)
-{
-  return dict_iter_match_next (name, strcmp_iw, iterator);
-}
-
 struct symbol *
 dict_iter_match_first (const struct dictionary *dict,
                       const char *name, symbol_compare_ftype *compare,
index 124fc98380106e3428c18e9a0bf731c3ab5baf67..4f4f160b9314b181514e0861a50e2cdeceb3bbd3 100644 (file)
@@ -122,25 +122,6 @@ extern struct symbol *dict_iterator_first (const struct dictionary *dict,
 
 extern struct symbol *dict_iterator_next (struct dict_iterator *iterator);
 
-/* Initialize ITERATOR to point at the first symbol in DICT whose
-   SYMBOL_SEARCH_NAME is NAME (as tested using strcmp_iw), and return
-   that first symbol, or NULL if there are no such symbols.  */
-
-extern struct symbol *dict_iter_name_first (const struct dictionary *dict,
-                                           const char *name,
-                                           struct dict_iterator *iterator);
-
-/* Advance ITERATOR to point at the next symbol in DICT whose
-   SYMBOL_SEARCH_NAME is NAME (as tested using strcmp_iw), or NULL if
-   there are no more such symbols.  Don't call this if you've
-   previously received NULL from dict_iterator_first or
-   dict_iterator_next on this iteration.  And don't call it unless
-   ITERATOR was created by a previous call to dict_iter_name_first
-   with the same NAME.  */
-
-extern struct symbol *dict_iter_name_next (const char *name,
-                                          struct dict_iterator *iterator);
-
 /* Initialize ITERATOR to point at the first symbol in DICT whose
    SYMBOL_SEARCH_NAME is NAME, as tested using COMPARE (which must use
    the same conventions as strcmp_iw and be compatible with any