X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Fdictionary.c;h=e1c2010bc1c386d46bf4d821b441a9982b10ec64;hb=e7fbb131d42983eec31231f8bb69cdd8d5a33ee6;hp=3802000763710e6f2c26e4924d9b02edf1277619;hpb=de4f826b0f698dc2858f6eda71f2613a89579c50;p=binutils-gdb.git diff --git a/gdb/dictionary.c b/gdb/dictionary.c index 38020007637..e1c2010bc1c 100644 --- a/gdb/dictionary.c +++ b/gdb/dictionary.c @@ -1,6 +1,6 @@ /* Routines for name->symbol lookups in GDB. - Copyright 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. Contributed by David Carlton and by Kealia, Inc. @@ -9,18 +9,16 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at - your option) any later version. + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + along with this program. If not, see . */ #include "defs.h" #include "gdb_obstack.h" @@ -99,7 +97,7 @@ enum dict_type /* Symbols are stored in a fixed-size array. */ DICT_LINEAR, /* Symbols are stored in an expandable array. */ - DICT_LINEAR_EXPANDABLE, + DICT_LINEAR_EXPANDABLE }; /* The virtual function table. */ @@ -289,7 +287,7 @@ static const struct dict_vector dict_hashed_vector = DICT_HASHED, /* type */ free_obstack, /* free */ add_symbol_nonexpandable, /* add_symbol */ - iterator_first_hashed, /* iteractor_first */ + iterator_first_hashed, /* iterator_first */ iterator_next_hashed, /* iterator_next */ iter_name_first_hashed, /* iter_name_first */ iter_name_next_hashed, /* iter_name_next */ @@ -301,7 +299,7 @@ static const struct dict_vector dict_hashed_expandable_vector = DICT_HASHED_EXPANDABLE, /* type */ free_hashed_expandable, /* free */ add_symbol_hashed_expandable, /* add_symbol */ - iterator_first_hashed, /* iteractor_first */ + iterator_first_hashed, /* iterator_first */ iterator_next_hashed, /* iterator_next */ iter_name_first_hashed, /* iter_name_first */ iter_name_next_hashed, /* iter_name_next */ @@ -313,7 +311,7 @@ static const struct dict_vector dict_linear_vector = DICT_LINEAR, /* type */ free_obstack, /* free */ add_symbol_nonexpandable, /* add_symbol */ - iterator_first_linear, /* iteractor_first */ + iterator_first_linear, /* iterator_first */ iterator_next_linear, /* iterator_next */ iter_name_first_linear, /* iter_name_first */ iter_name_next_linear, /* iter_name_next */ @@ -325,7 +323,7 @@ static const struct dict_vector dict_linear_expandable_vector = DICT_LINEAR_EXPANDABLE, /* type */ free_linear_expandable, /* free */ add_symbol_linear_expandable, /* add_symbol */ - iterator_first_linear, /* iteractor_first */ + iterator_first_linear, /* iterator_first */ iterator_next_linear, /* iterator_next */ iter_name_first_linear, /* iter_name_first */ iter_name_next_linear, /* iter_name_next */ @@ -563,7 +561,7 @@ static void add_symbol_nonexpandable (struct dictionary *dict, struct symbol *sym) { internal_error (__FILE__, __LINE__, - "dict_add_symbol: non-expandable dictionary"); + _("dict_add_symbol: non-expandable dictionary")); } /* Functions for DICT_HASHED and DICT_HASHED_EXPANDABLE. */ @@ -580,7 +578,6 @@ iterator_first_hashed (const struct dictionary *dict, static struct symbol * iterator_next_hashed (struct dict_iterator *iterator) { - const struct dictionary *dict = DICT_ITERATOR_DICT (iterator); struct symbol *next; next = DICT_ITERATOR_CURRENT (iterator)->hash_next; @@ -636,7 +633,7 @@ iter_name_first_hashed (const struct dictionary *dict, sym = sym->hash_next) { /* Warning: the order of arguments to strcmp_iw matters! */ - if (strcmp_iw (SYMBOL_NATURAL_NAME (sym), name) == 0) + if (strcmp_iw (SYMBOL_SEARCH_NAME (sym), name) == 0) { break; } @@ -656,7 +653,7 @@ iter_name_next_hashed (const char *name, struct dict_iterator *iterator) next != NULL; next = next->hash_next) { - if (strcmp_iw (SYMBOL_NATURAL_NAME (next), name) == 0) + if (strcmp_iw (SYMBOL_SEARCH_NAME (next), name) == 0) break; } @@ -674,7 +671,7 @@ insert_symbol_hashed (struct dictionary *dict, unsigned int hash_index; struct symbol **buckets = DICT_HASHED_BUCKETS (dict); - hash_index = (msymbol_hash_iw (SYMBOL_NATURAL_NAME (sym)) + hash_index = (msymbol_hash_iw (SYMBOL_SEARCH_NAME (sym)) % DICT_HASHED_NBUCKETS (dict)); sym->hash_next = buckets[hash_index]; buckets[hash_index] = sym; @@ -727,21 +724,24 @@ expand_hashtable (struct dictionary *dict) DICT_HASHED_NBUCKETS (dict) = new_nbuckets; DICT_HASHED_BUCKETS (dict) = new_buckets; - for (i = 0; i < old_nbuckets; ++i) { - struct symbol *sym, *next_sym; - - sym = old_buckets[i]; - if (sym != NULL) { - for (next_sym = sym->hash_next; - next_sym != NULL; - next_sym = sym->hash_next) { - insert_symbol_hashed (dict, sym); - sym = next_sym; - } + for (i = 0; i < old_nbuckets; ++i) + { + struct symbol *sym, *next_sym; - insert_symbol_hashed (dict, sym); + sym = old_buckets[i]; + if (sym != NULL) + { + for (next_sym = sym->hash_next; + next_sym != NULL; + next_sym = sym->hash_next) + { + insert_symbol_hashed (dict, sym); + sym = next_sym; + } + + insert_symbol_hashed (dict, sym); + } } - } xfree (old_buckets); } @@ -789,7 +789,7 @@ iter_name_next_linear (const char *name, struct dict_iterator *iterator) for (i = DICT_ITERATOR_INDEX (iterator) + 1; i < nsyms; ++i) { sym = DICT_LINEAR_SYM (dict, i); - if (strcmp_iw (SYMBOL_NATURAL_NAME (sym), name) == 0) + if (strcmp_iw (SYMBOL_SEARCH_NAME (sym), name) == 0) { retval = sym; break; @@ -824,13 +824,14 @@ add_symbol_linear_expandable (struct dictionary *dict, int nsyms = ++DICT_LINEAR_NSYMS (dict); /* Do we have enough room? If not, grow it. */ - if (nsyms > DICT_LINEAR_EXPANDABLE_CAPACITY (dict)) { - DICT_LINEAR_EXPANDABLE_CAPACITY (dict) *= 2; - DICT_LINEAR_SYMS (dict) - = xrealloc (DICT_LINEAR_SYMS (dict), - DICT_LINEAR_EXPANDABLE_CAPACITY (dict) - * sizeof (struct symbol *)); - } + if (nsyms > DICT_LINEAR_EXPANDABLE_CAPACITY (dict)) + { + DICT_LINEAR_EXPANDABLE_CAPACITY (dict) *= 2; + DICT_LINEAR_SYMS (dict) + = xrealloc (DICT_LINEAR_SYMS (dict), + DICT_LINEAR_EXPANDABLE_CAPACITY (dict) + * sizeof (struct symbol *)); + } DICT_LINEAR_SYM (dict, nsyms - 1) = sym; }