From: Daniel Berlin <dan@dberlin.org>
To: Neil Booth <neil@daikokuya.demon.co.uk>
Cc: Jim Blandy <jimb@redhat.com>, <gdb-patches@sources.redhat.com>,
<gcc@gcc.gnu.org>
Subject: Re: RFC: C/C++ preprocessor macro support for GDB
Date: Mon, 18 Mar 2002 00:06:00 -0000 [thread overview]
Message-ID: <Pine.LNX.4.44.0203180253320.21768-100000@dberlin.org> (raw)
In-Reply-To: <20020318072916.GB14970@daikokuya.demon.co.uk>
On Mon, 18 Mar 2002, Neil Booth wrote:
> Jim Blandy wrote:-
>
> > (gdb) break *ADDRESS if CONDITION
> >
> > This sets a conditional breakpoint at the address computed by
> > evaluating the expression ADDRESS, whose condition is CONDITION.
> > ADDRESS needs to be evaluated in the current scope --- the currently
> > selected frame and its PC --- but CONDITION needs to be evaluated in
> > the scope in force at the *breakpoint's* address. So you can't just
> > take the whole command and smoosh it through an expander all at
> > once: ADDRESS and CONDITION might have totally different contexts,
> > as far as the preprocessor is concerned.
>
> I don't understand why this is hard. Just expand ADDRESS and CONDITION
> separately, no? I don't think an "if" in address counts as starting the
> condition, right?
>
> > This means you've got to decide if there's an `if' in the command
> > before you can macro-expand things. Obviously, an `if' in a string,
> > or as part of a larger identifier, doesn't count --- you really need
> > to work in terms of tokens.
>
> Why can't you just do a quick scan before expanding anything? What am I
> missing?
>
> > As far as I can tell, libcpp doesn't provide an analogous
> > token-by-token entry point.
>
> It has the ability to macro-expand an arbitrary text buffer; you just
> loop getting the tokens until CPP_EOF.
>
> > There's nothing too hard there. But I wanted to put together a
> > patch which actually worked, while disturbing the existing GDB code
> > as little as possible. And I think there's something unsatisfying
> > about the two-pass approach; parsers ought to be able to leave input
> > unconsumed if they want. It's a common enough idiom. Shouldn't
> > libcpp support it?
>
> I'm afraid I can't see a problem. Maybe a detailed example with an
> actual GDB command with an embedded C macro would help?
>
> > - GDB's macro data structures record all the macros that were ever
> > #defined in a compilation unit, and the line numbers at which they
> > were in force. Given a name and an #inclusion and a line number (or
> > in libcpp's terminology, a logical line number?), it can find the
> > #definition in scope at that point.
>
> Yes. I think I know what you're about to say. I went through this with
> Dan.
Yes, and I had actually implemented libcpp as gdb's macro preprocessor a
while ago to test the macro info output.
You just need a lookup callback to lookup in some outside structure.
That, and a bunch the stupid little niggly defines/typedefs from gcc's
autoconf generated *.h files
Other than that, it's just not hard.
I *really* don't see why Jim went to all the trouble, since it would
probably have taken less than half a week to add the necessary
changes to libcpp.
Even if he didn't want to use libcpp, due to interface, ucpp would fit
well here too and is smaller/has no memory issues. UCPP was "designed to
be fast, with low memory consumption, and reusable as a lexer in other
projects".
You'd end up just replacing the get_macro function.
Heck, it even has sample code on using it as an integrated lexer.
Though personally, i'd still use libcpp.
--Dan
next prev parent reply other threads:[~2002-03-18 8:06 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-16 22:23 Jim Blandy
2002-03-17 0:11 ` Zack Weinberg
2002-03-17 19:33 ` Jim Blandy
2002-03-17 4:46 ` Neil Booth
2002-03-17 20:35 ` Jim Blandy
2002-03-17 23:29 ` Neil Booth
2002-03-18 0:06 ` Daniel Berlin [this message]
2002-03-18 0:36 ` Zack Weinberg
2002-03-18 5:00 ` Daniel Berlin
2002-03-18 5:32 ` Daniel Berlin
2002-03-18 11:18 ` Jim Blandy
2002-03-18 12:09 ` Neil Booth
2002-03-18 10:45 ` Neil Booth
2002-03-18 11:45 ` Stan Shebs
2002-03-18 12:05 ` Neil Booth
2002-03-18 12:19 ` Stan Shebs
2002-03-18 15:45 ` Jim Blandy
2002-03-18 7:16 ` Andrew Cagney
2002-03-17 9:07 ` Daniel Berlin
2002-03-17 16:53 ` Daniel Berlin
2002-03-18 7:35 ` Batons? Was: " Andrew Cagney
2002-03-18 12:08 ` Jim Blandy
2002-03-18 12:55 ` Andrew Cagney
2002-03-18 15:49 ` Jim Blandy
2002-03-18 7:39 ` Andrew Cagney
2002-03-19 13:16 ` Jim Blandy
2002-03-18 10:34 ` Neil Booth
2002-03-18 11:11 ` Neil Booth
2002-03-18 16:03 ` Jim Blandy
2002-03-18 17:42 ` Stan Shebs
2002-03-18 19:51 ` Jim Blandy
2002-03-18 23:23 ` Neil Booth
2002-03-18 20:33 ` Jim Blandy
2002-03-23 12:14 ` Andrew Cagney
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=Pine.LNX.4.44.0203180253320.21768-100000@dberlin.org \
--to=dan@dberlin.org \
--cc=gcc@gcc.gnu.org \
--cc=gdb-patches@sources.redhat.com \
--cc=jimb@redhat.com \
--cc=neil@daikokuya.demon.co.uk \
/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