This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Merge cpplib and front end hashtables, part 1


Mark Mitchell <mark@codesourcery.com> writes:

> >>>>> "Daniel" == Daniel Berlin <dan@www.cgsoftware.com> writes:
> 
>     Daniel> Personally, I could care less either way.  cpplib as it
>     Daniel> stands right now is too hard to integrate into GDB, mainly
>     Daniel> because expanding macros in gdb means we want a text
>     Daniel> string back, not tokens.
> 
> That would be easy to fix.  cpp knows how to emit preprocessed code
> after all; all that is needed is to provide that interface to GDB.
> 
> I think it would be foolish to contemplate macro expansion in GDB
> without using cpplib.  If cpplib isn't up to the task, for reasons of
> usability, size, what-have-you we should figure out how to clean it
> up/modularize it so that you can get the interface you need.


The main reason it's not up to the task is because we don't want to
parse files. We already have the macro info.
We know what the macros are, and their definitions.
We just want to expand them.

This means informing cpplib of all the macro definitions, and
undefinitions, for the current file, up to the current line.

Since we can jump around all the time in gdb, we'd really have to
clear the macro hashtable before reading each input, lookup every
macro for the current context, up to the current line, and insert them
into cpplib's macro hash table (through do_define or something).  Then
let CPPLIB do the lexing for the C parser, and voila.

We can't parse the source files, we might not have all the include
files, etc.  And we only want to go up to a certain point anyway (the
current context line).
The main pain in the ass in integrating it, therefore, is doing that.

It's the typical "informing something else about all the context we
have" problem.

We know all about the macros, where they are, etc.  We need to tell
them to cpplib, without confusing it.

This is the hard part of hooking it up tot he parser. The rest is
cake.

> 
> --
> Mark Mitchell                   mark@codesourcery.com
> CodeSourcery, LLC               http://www.codesourcery.com

-- 
"It doesn't matter what temperature the room is, it's always room
temperature.
"-Steven Wright


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]