Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: David Carlton <carlton@math.stanford.edu>
To: Elena Zannoni <ezannoni@redhat.com>
Cc: Daniel Jacobowitz <drow@mvista.com>,
	cagney@redhat.com, gdb-patches@sources.redhat.com,
	Jim Blandy <jimb@redhat.com>, Adam Fedor <fedor@doc.com>
Subject: Re: [rfa] teach lookup_symbol about namespace scope
Date: Fri, 16 May 2003 17:26:00 -0000	[thread overview]
Message-ID: <ro1k7cqolak.fsf@jackfruit.Stanford.EDU> (raw)
In-Reply-To: <16068.64366.311139.220476@localhost.redhat.com>

On Fri, 16 May 2003 10:53:34 -0400, Elena Zannoni <ezannoni@redhat.com> said:

> OK, here it goes. I have been ruminating on this patch a long time,
> and I have really mixed feelings about it, no that's not accurate, I
> am completely torn about it.

I'm not surprised to hear that, because I basically share your
qualms.

> On the other hand, the generic flow of control of the symbol search
> gets pulled into c++ territory.

Right.  So what do we do about that?  Some possibilities:

1) Have a separate lookup-symbol function for each language, and make
   sure it gets called wherever is appropriate.

2) Put language-specific hooks in the generic lookup_symbol function.

3) Have the knowledge about what to do actually embedded in the blocks
   themselves.

I don't think option 1 is all that great an idea: e.g. C and C++ share
a parser (and might eventually share it with Objective C as well), so
you don't know which lookup function to call, or in decode_variable
(within decode_line_1), you don't really know what the ambient
language is, so you really want a single function that works for all
languages.

Option 3 might well be a good idea in the long term, and probably my
dictionary patch will begin to set up the framework necessary for
that, but it's far too big a leap for me to want to consider that now:
I just want to get C++ working better.

So that leaves us with option 2.  And, actually, I think there's a
natural place to put a hook:

* Allow languages complete control as to what happens after the local
  variables are looked up.

Local variable lookup is, I hope, fairly uniform across languages.
But the 'is_a_field_of_this' check isn't relevant to C.  The new
namespace stuff isn't relevant to C.  And all of that happens after
local variables are looked up, either before or instead of
global/static symbol lookup.  So that seems to me to be the right
place to allow languages to seize control; if we need more hooks
later, we can add them, but that will give us some place to start, and
will allow me to move my namespace lookup algorithm to cp-support.c or
cp-namespace.c.  I assume this would work for whatever needs
Objective-C has; I'll add Adam to the Cc: list in case he wants to
chime in.  (We should really add him to the MAINTAINERS list as
Objective-C maintainer one of these days.)

To get this to work, we'll obviously need to provide a way to locate
the language associated to a given block.  My first instinct was to
add a 'language' member to each block, but poking around, the symtab
already has that information: how about just adding a 'symtab' member
to each block?  (Or even just to global blocks, if that is any easier
to write: we can bury the details of its access in a function
'block_symtab'.)  That would help make sure that the information is
consistent, and would let us get rid of the ALL_SYMTABS bit in
lookup_symbol_aux_block.

If this sounds good, I'll get to work on it; it should be easy enough
to do, I think.  I have a pretty good idea of what functions symtab.c
will want to export to make life easier for other languages.

> Anyway, here is the symtab.c portion of the patch updated to reflect
> the namespace-->domain changes.

Thanks.

> (about the test changes: do you use namespace1.cc at all? I don't see
> you hooking that up to anything).

Oh, whoops, sorry about that.  Good thing Daniel was asking me to
include tests for symbols in namespace1.cc that are actually supposed
to find a variable instead of not do so...

David Carlton
carlton@math.stanford.edu


  reply	other threads:[~2003-05-16 17:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-24 14:34 David Carlton
2003-04-24 20:14 ` Eli Zaretskii
2003-04-24 20:18 ` Daniel Jacobowitz
2003-04-24 20:44   ` David Carlton
2003-05-16 14:48     ` Elena Zannoni
2003-05-16 17:26       ` David Carlton [this message]
2003-05-16 19:49         ` Elena Zannoni
2003-05-16 20:51           ` David Carlton
2003-05-17  0:09             ` Joel Brobecker
2003-05-19  9:55 Paul Hilfinger
2003-05-19 16:35 ` David Carlton
2003-05-20 11:10   ` Paul Hilfinger
2003-05-20 16:17     ` David Carlton

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=ro1k7cqolak.fsf@jackfruit.Stanford.EDU \
    --to=carlton@math.stanford.edu \
    --cc=cagney@redhat.com \
    --cc=drow@mvista.com \
    --cc=ezannoni@redhat.com \
    --cc=fedor@doc.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=jimb@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