This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Extend hashed symbol dictionaries to work with Ada
On Wed, 2010-10-06 at 16:59 -0700, Doug Evans wrote:
> Hi. I wouldn't mind having a couple of comments added to this function:
>
Arghh. My mistake. I added a comment to our local version without
submitting it. Updating:
+/* Produce an unsigned hash value from STRING0 that is consistent
+ with strcmp_iw, strcmp, and, at least on Ada symbols, wild_match.
+ That is, two identifiers equivalent according to any of those three
+ comparison operators hash to the same value. */
+
+static unsigned int
+dict_hash (const char *string)
+{
+ /* The Ada-encoded version of a name P1.P2...Pn has either the form
+ P1__P2__...Pn<suffix> or _ada_P1__P2__...Pn<suffix> (where the Pi
+ are lower-cased identifiers). The <suffix> (which can be empty)
+ encodes additional information about the denoted entity. This
+ routine hashes such names to msymbol_hash_iw(Pn). It actually
+ does this for a superset of both valid Pi and of <suffix>, but
+ in other cases it simply returns msymbol_hash_iw(STRING0). */
...
> > + case '_':
> > + if (string[1] == '_')
> > + {
> > + if (((c = string[2]) < 'a' || c > 'z') && c != 'O')
>
> Why does this `if' exist?
>
Follows from the (newly added) comment above. That condition indicates
a __ followed by something that can't be an encoded Ada identifier. We
assume it is part of the suffix (as indicated in the comment, we accept
a superset of the valid suffixes).
> > + return hash;
> > + hash = 0;
>
> Why do we restart calculating the hash here?
As the comments indicate, we are ignoring the prefix of a qualified
name to get wild-matching.
Thanks for your comments.
Paul