public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Paul Hilfinger <HIlfinger@cs.berkeley.edu>
To: Doug Evans <dje@google.com>
Cc: Hilfinger@adacore.com, Tom Tromey <tromey@redhat.com>,
	       Joel Brobecker <brobecker@adacore.com>,
	gdb-patches@sourceware.org
Subject: Re: [RFA] Extend hashed symbol dictionaries to work with Ada
Date: Thu, 07 Oct 2010 06:29:00 -0000	[thread overview]
Message-ID: <1286432916.2507.24.camel@syracuse.mckusick.com> (raw)
In-Reply-To: <AANLkTinak7-mHU=tvqUKnJwubvMHnwQmtp5uU+14QUVc@mail.gmail.com>

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

      reply	other threads:[~2010-10-07  6:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-05  8:20 Paul Hilfinger
2010-10-06 22:43 ` Tom Tromey
2010-10-06 22:53   ` Tom Tromey
2010-10-07  3:31     ` Paul Hilfinger
2010-10-07  7:17     ` [commit] " Paul Hilfinger
2010-10-07  8:44     ` [commit] Correct dict_hash to our most recent version Paul Hilfinger, :
2010-10-08 22:59       ` Tom Tromey
2010-10-07  3:29   ` [RFA] Extend hashed symbol dictionaries to work with Ada Paul Hilfinger
2010-10-06 23:18 ` Joel Brobecker
2010-10-06 23:59 ` Doug Evans
2010-10-07  6:29   ` Paul Hilfinger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1286432916.2507.24.camel@syracuse.mckusick.com \
    --to=hilfinger@cs.berkeley.edu \
    --cc=Hilfinger@adacore.com \
    --cc=brobecker@adacore.com \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).