/* Routines for name->symbol lookups in GDB.
- Copyright (C) 2003-2019 Free Software Foundation, Inc.
+ Copyright (C) 2003-2020 Free Software Foundation, Inc.
Contributed by David Carlton <carlton@bactrian.org> and by Kealia,
Inc.
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
-
-/* Standard C includes. */
#include <ctype.h>
-
-/* Standard C++ includes. */
-#include <unordered_map>
-
-/* Local non-gdb includes. */
+#include "gdb_obstack.h"
+#include "symtab.h"
#include "buildsym.h"
#include "dictionary.h"
-#include "gdb_obstack.h"
#include "safe-ctype.h"
-#include "symtab.h"
+#include <unordered_map>
+#include "language.h"
/* This file implements dictionaries, which are tables that associate
symbols to names. They are represented by an opaque type 'struct
/* Initialize ITERATOR to point at the first symbol in DICT, and
return that first symbol, or NULL if DICT is empty. */
-struct symbol *
+static struct symbol *
dict_iterator_first (const struct dictionary *dict,
struct dict_iterator *iterator)
{
/* Advance ITERATOR, and return the next symbol, or NULL if there are
no more symbols. */
-struct symbol *
+static struct symbol *
dict_iterator_next (struct dict_iterator *iterator)
{
return (DICT_VECTOR (DICT_ITERATOR_DICT (iterator)))
->iterator_next (iterator);
}
-struct symbol *
+static struct symbol *
dict_iter_match_first (const struct dictionary *dict,
const lookup_name_info &name,
struct dict_iterator *iterator)
return (DICT_VECTOR (dict))->iter_match_first (dict, name, iterator);
}
-struct symbol *
+static struct symbol *
dict_iter_match_next (const lookup_name_info &name,
struct dict_iterator *iterator)
{
implemented generically by means of the vtable. Typically, they're
rarely used. */
-/* Test to see if DICT is empty. */
-
-static int
-dict_empty (struct dictionary *dict)
-{
- struct dict_iterator iter;
-
- return (dict_iterator_first (dict, &iter) == NULL);
-}
-
/* The functions implementing the dictionary interface. */
sym = sym->hash_next)
{
/* Warning: the order of arguments to compare matters! */
- if (matches_name (SYMBOL_SEARCH_NAME (sym), name, NULL))
+ if (matches_name (sym->search_name (), name, NULL))
break;
}
next != NULL;
next = next->hash_next)
{
- if (matches_name (SYMBOL_SEARCH_NAME (next), name, NULL))
+ if (matches_name (next->search_name (), name, NULL))
break;
}
/* We don't want to insert a symbol into a dictionary of a different
language. The two may not use the same hashing algorithm. */
- gdb_assert (SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language);
+ gdb_assert (sym->language () == DICT_LANGUAGE (dict)->la_language);
- hash = search_name_hash (SYMBOL_LANGUAGE (sym), SYMBOL_SEARCH_NAME (sym));
+ hash = search_name_hash (sym->language (), sym->search_name ());
hash_index = hash % DICT_HASHED_NBUCKETS (dict);
sym->hash_next = buckets[hash_index];
buckets[hash_index] = sym;
{
sym = DICT_LINEAR_SYM (dict, i);
- if (matches_name (SYMBOL_SEARCH_NAME (sym), name, NULL))
+ if (matches_name (sym->search_name (), name, NULL))
{
retval = sym;
break;
{
std::unordered_map<enum language, std::vector<symbol *>> nsyms;
- for (const struct pending *list_counter = symbol_list;
+ for (const pending *list_counter = symbol_list;
list_counter != nullptr; list_counter = list_counter->next)
{
for (int i = list_counter->nsyms - 1; i >= 0; --i)
{
- enum language language = SYMBOL_LANGUAGE (list_counter->symbol[i]);
+ enum language language = list_counter->symbol[i]->language ();
nsyms[language].push_back (list_counter->symbol[i]);
}
}
mdict_add_symbol (struct multidictionary *mdict, struct symbol *sym)
{
struct dictionary *dict
- = find_language_dictionary (mdict, SYMBOL_LANGUAGE (sym));
+ = find_language_dictionary (mdict, sym->language ());
if (dict == nullptr)
{
/* SYM is of a new language that we haven't previously seen.
Create a new dictionary for it. */
- dict = create_new_language_dictionary (mdict, SYMBOL_LANGUAGE (sym));
+ dict = create_new_language_dictionary (mdict, sym->language ());
}
dict_add_symbol (dict, sym);
return size;
}
-
-/* See dictionary.h. */
-
-bool
-mdict_empty (const struct multidictionary *mdict)
-{
- for (unsigned short idx = 0; idx < mdict->n_allocated_dictionaries; ++idx)
- {
- if (!dict_empty (mdict->dictionaries[idx]))
- return false;
- }
-
- return true;
-}