From 89790f76b69d53fffa867aeb3a8d658644a4d574 Mon Sep 17 00:00:00 2001 From: hilfingr Date: Thu, 7 Oct 2010 08:32:36 +0000 Subject: [PATCH] Correct dict_hash to our most recent version. Several changes to dict_hash from Adacore's local version were inadvertantly left out of the last change to that function. These changes conservatively cause dict_hash to revert to msymbol_hash_iw in more cases where the symbol being hashed is known not to be Ada-encoded. This avoids a few cases where the function hashes large groups of names with similar prefixes to the same value. Changelog: gdb/ * dictionary.c (dict_hash): Revert to msymbol_hash_iw in more cases. --- gdb/ChangeLog | 5 +++++ gdb/dictionary.c | 25 +++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 803edfe674..cb316143a5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2010-10-07 Paul Hilfinger + * dictionary.c (dict_hash): Revert to msymbol_hash_iw in + more cases. + +2010-10-07 Paul Hilfinger + * ada-lang.c (full_match): Declare. (ada_match_name): Rename to match_name (we should avoid prefixing static symbols with "ada_"). diff --git a/gdb/dictionary.c b/gdb/dictionary.c index f3ac3069ad..4f18e8c017 100644 --- a/gdb/dictionary.c +++ b/gdb/dictionary.c @@ -786,7 +786,7 @@ expand_hashtable (struct dictionary *dict) comparison operators hash to the same value. */ static unsigned int -dict_hash (const char *string) +dict_hash (const char *string0) { /* The Ada-encoded version of a name P1.P2...Pn has either the form P1__P2__...Pn or _ada_P1__P2__...Pn (where the Pi @@ -796,11 +796,18 @@ dict_hash (const char *string) does this for a superset of both valid Pi and of , but in other cases it simply returns msymbol_hash_iw(STRING0). */ + const char *string; unsigned int hash; int c; - if (*string == '_' && strncmp (string, "_ada_", 5) == 0) - string += 5; + string = string0; + if (*string == '_') + { + if (strncmp (string, "_ada_", 5) == 0) + string += 5; + else + return msymbol_hash_iw (string0); + } hash = 0; while (*string) @@ -810,13 +817,15 @@ dict_hash (const char *string) case '$': case '.': case 'X': - case '(': - return hash; + if (string0 == string) + return msymbol_hash_iw (string0); + else + return hash; case ' ': - string += 1; - break; + case '(': + return msymbol_hash_iw (string0); case '_': - if (string[1] == '_') + if (string[1] == '_' && string != string0) { if (((c = string[2]) < 'a' || c > 'z') && c != 'O') return hash; -- 2.11.0