X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fdictionary.c;h=a24789abb4bbe8cea34eeac6c43b8f5a579f4f21;hb=9f1b45b0da430a7a7abf9e54acbe6f2ef9d3a763;hp=9d53ff0e3012e298b9bd5a1f3e6a2891e4c7c9a1;hpb=558b1900b0750489aaedeeb5ad173ce7331db68f;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/dictionary.c b/gdb/dictionary.c index 9d53ff0e30..a24789abb4 100644 --- a/gdb/dictionary.c +++ b/gdb/dictionary.c @@ -1,6 +1,6 @@ /* Routines for name->symbol lookups in GDB. - Copyright (C) 2003, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2003-2014 Free Software Foundation, Inc. Contributed by David Carlton and by Kealia, Inc. @@ -82,9 +82,7 @@ * Define a function dict_ that looks up in the dict_vector and calls the appropriate function. Add a declaration for - dict_ to dictionary.h. - -*/ + dict_ to dictionary.h. */ /* An enum representing the various implementations of dictionaries. Used only for debugging. */ @@ -118,13 +116,11 @@ struct dict_vector struct symbol *(*iterator_next) (struct dict_iterator *iterator); /* Functions to iterate over symbols with a given name. */ struct symbol *(*iter_match_first) (const struct dictionary *dict, - const char *name, - int (*equiv) (const char *, - const char *), - struct dict_iterator *iterator); + const char *name, + symbol_compare_ftype *equiv, + struct dict_iterator *iterator); struct symbol *(*iter_match_next) (const char *name, - int (*equiv) (const char *, - const char *), + symbol_compare_ftype *equiv, struct dict_iterator *iterator); /* A size function, for maint print symtabs. */ int (*size) (const struct dictionary *dict); @@ -243,13 +239,11 @@ static struct symbol *iterator_next_hashed (struct dict_iterator *iterator); static struct symbol *iter_match_first_hashed (const struct dictionary *dict, const char *name, - int (*compare) (const char *, - const char *), + symbol_compare_ftype *compare, struct dict_iterator *iterator); static struct symbol *iter_match_next_hashed (const char *name, - int (*compare) (const char *, - const char *), + symbol_compare_ftype *compare, struct dict_iterator *iterator); static unsigned int dict_hash (const char *string); @@ -277,13 +271,11 @@ static struct symbol *iterator_next_linear (struct dict_iterator *iterator); static struct symbol *iter_match_first_linear (const struct dictionary *dict, const char *name, - int (*compare) (const char *, - const char *), + symbol_compare_ftype *compare, struct dict_iterator *iterator); static struct symbol *iter_match_next_linear (const char *name, - int (*compare) (const char *, - const char *), + symbol_compare_ftype *compare, struct dict_iterator *iterator); static int size_linear (const struct dictionary *dict); @@ -506,6 +498,22 @@ dict_add_symbol (struct dictionary *dict, struct symbol *sym) (DICT_VECTOR (dict))->add_symbol (dict, sym); } +/* Utility to add a list of symbols to a dictionary. + DICT must be an expandable dictionary. */ + +void +dict_add_pending (struct dictionary *dict, const struct pending *symbol_list) +{ + const struct pending *list; + int i; + + for (list = symbol_list; list != NULL; list = list->next) + { + for (i = 0; i < list->nsyms; ++i) + dict_add_symbol (dict, list->symbol[i]); + } +} + /* Initialize ITERATOR to point at the first symbol in DICT, and return that first symbol, or NULL if DICT is empty. */ @@ -542,16 +550,15 @@ dict_iter_name_next (const char *name, struct dict_iterator *iterator) struct symbol * dict_iter_match_first (const struct dictionary *dict, - const char *name, - int (*compare) (const char *, const char *), + const char *name, symbol_compare_ftype *compare, struct dict_iterator *iterator) { - return (DICT_VECTOR (dict))->iter_match_first (dict, name, compare, iterator); + return (DICT_VECTOR (dict))->iter_match_first (dict, name, + compare, iterator); } struct symbol * -dict_iter_match_next (const char *name, - int (*compare) (const char *, const char *), +dict_iter_match_next (const char *name, symbol_compare_ftype *compare, struct dict_iterator *iterator) { return (DICT_VECTOR (DICT_ITERATOR_DICT (iterator))) @@ -646,9 +653,8 @@ iterator_hashed_advance (struct dict_iterator *iterator) } static struct symbol * -iter_match_first_hashed (const struct dictionary *dict, - const char *name, - int (*compare) (const char *, const char *), +iter_match_first_hashed (const struct dictionary *dict, const char *name, + symbol_compare_ftype *compare, struct dict_iterator *iterator) { unsigned int hash_index = dict_hash (name) % DICT_HASHED_NBUCKETS (dict); @@ -677,8 +683,7 @@ iter_match_first_hashed (const struct dictionary *dict, } static struct symbol * -iter_match_next_hashed (const char *name, - int (*compare) (const char *, const char *), +iter_match_next_hashed (const char *name, symbol_compare_ftype *compare, struct dict_iterator *iterator) { struct symbol *next; @@ -811,6 +816,17 @@ dict_hash (const char *string0) hash = 0; while (*string) { + /* Ignore "TKB" suffixes. + + These are used by Ada for subprograms implementing a task body. + For instance for a task T inside package Pck, the name of the + subprogram implementing T's body is `pck__tTKB'. We need to + ignore the "TKB" suffix because searches for this task body + subprogram are going to be performed using `pck__t' (the encoded + version of the natural name `pck.t'). */ + if (strcmp (string, "TKB") == 0) + return hash; + switch (*string) { case '$': @@ -836,7 +852,7 @@ dict_hash (const char *string0) } /* FALL THROUGH */ default: - hash = hash * 67 + *string - 113; + hash = SYMBOL_HASH_NEXT (hash, *string); string += 1; break; } @@ -868,8 +884,7 @@ iterator_next_linear (struct dict_iterator *iterator) static struct symbol * iter_match_first_linear (const struct dictionary *dict, - const char *name, - int (*compare) (const char *, const char *), + const char *name, symbol_compare_ftype *compare, struct dict_iterator *iterator) { DICT_ITERATOR_DICT (iterator) = dict; @@ -879,8 +894,7 @@ iter_match_first_linear (const struct dictionary *dict, } static struct symbol * -iter_match_next_linear (const char *name, - int (*compare) (const char *, const char *), +iter_match_next_linear (const char *name, symbol_compare_ftype *compare, struct dict_iterator *iterator) { const struct dictionary *dict = DICT_ITERATOR_DICT (iterator);