Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Berlin <dan@cgsoftware.com>
To: Jim Blandy <jimb@zwingli.cygnus.com>
Cc: Daniel Berlin <dan@cgsoftware.com>, gdb-patches@sources.redhat.com
Subject: Re: macro-expanding expressions in GDB
Date: Thu, 07 Jun 2001 12:04:00 -0000	[thread overview]
Message-ID: <877kyonmc1.fsf@cgsoftware.com> (raw)
In-Reply-To: <np1yow15qw.fsf@zwingli.cygnus.com>

Jim Blandy <jimb@zwingli.cygnus.com> writes:

> Daniel Berlin <dan@cgsoftware.com> writes:
>> I've actually already done it, I can post it if you like.
>> 
>> Macros live in the MACRO_NAMESPACE.
>> Each macro's name is it's symbol name.
>> The text of the macro is the symbol's value.
>> 
>> The hardest part was actually getting the macros into the right
>> blocks, as you would imagine.
> 
> Yeah.  I guess I don't see the point in trying to fit them into the
> existing symbol table structure:
> 
> - Macros aren't scoped in a block-structured fashion; they have ranges
>   of lines over which they're in force.  So the block tree is a total
>   misfit for them.

Right.

> 
> - They don't have addresses or types, so the fields of struct symbol
>   are mostly garbage.
> 
Right.

> - Struct symbol doesn't have anyplace really appropriate to store
>   an argument list.
Right again.

> 
> I would want them in a separate structure that can accurately
> represent their behavior.
I had them there, then i changed it.
I'll change it back.

> 
> Ideally, given an object code location, I want to be able to find the
> definitions that were in force when that object code was emitted.
> Unfortunately, we can't do this perfectly; if a file is #included more
> than once, perhaps with different #definitions in force each time,
> that control #if directives that establish different definitions for
> other macros, no debugging format (including Dwarf 2) provides enough
> information for us to tell which #inclusion corresponds to which code
> address.   Dwarf 2's macro information does it right, but its text
> address <-> source location mapping doesn't.
Right. Well, yet, anyway.
There is an accepted proposal for discontiguous scopes, which may let
you do this, actually (even though that's not it's real intention).


The best we can do right now is take the PC you give us, find the
closest line, and tell you what macros were in force at that *line*.
And we can do this perfectly, actually.


> 
>> The callback i'm referring to is the fact that we need cpplib to
>> provide a callback when it goes to determine if something is a macro
>> or not.  That way, we can look it up in gdb's symbol table instead.  Right
>> now, it looks it up in it's internal symbol table.  This will of
>> course, never find it.   The other ways around this (not using a
>> callback) are so hairy it's not even funny.  There was a discussion
>> about it on the gcc list.
> 
> Yeah, to be useful to GDB, cpplib's expansion code needs to be
> decoupled from the rest of the CPP stuff --- and that includes the
> code for #define, which establishes the definitions in the first
> place.

This isn't possible/genreally considered a bad idea.
We had this discussion on the gcc list a few weeks ago, i asked for
the very same thing.
Everyone told me this was a bad idea.
:)


-- 
"My neighbor has a circular driveway...  He can't get out.
"-Steven Wright


  reply	other threads:[~2001-06-07 12:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-22 14:06 [RFA] linespec.c change to stop "malformed template specification" error Daniel Berlin
2001-06-06 16:09 ` Elena Zannoni
2001-06-06 17:00   ` Fernando Nasser
2001-06-06 21:00   ` Jim Blandy
2001-06-06 22:09     ` Daniel Berlin
2001-06-07  8:40       ` Jim Blandy
2001-06-07  8:47       ` macro-expanding expressions in GDB Jim Blandy
2001-06-07  9:01         ` Daniel Berlin
2001-06-07 11:52           ` Jim Blandy
2001-06-07 12:04             ` Daniel Berlin [this message]
2001-06-07 11:16         ` Stan Shebs
2001-06-06 23:36     ` [RFA] linespec.c change to stop "malformed template specification" error Daniel Berlin
2001-06-07  6:00     ` Fernando Nasser
2001-06-07  9:09       ` Jim Blandy
2001-06-07  7:40     ` Elena Zannoni
     [not found]       ` <nppucg1eq5.fsf@zwingli.cygnus.com>
2001-06-07  9:13         ` Daniel Berlin
2001-06-07 11:18           ` Jim Blandy
2001-06-07 11:35             ` Daniel Berlin
2001-06-07 15:22               ` Jim Blandy
2001-06-07 16:40                 ` Daniel Berlin
2001-06-07 10:27         ` Elena Zannoni
2001-06-07 12:30           ` Fernando Nasser
2001-06-07 15:14           ` Jim Blandy

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=877kyonmc1.fsf@cgsoftware.com \
    --to=dan@cgsoftware.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=jimb@zwingli.cygnus.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