This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: C/C++ preprocessor macro support for GDB



Neil Booth <neil@daikokuya.demon.co.uk> writes:
> I've looked over your patch a little more, and I don't think your macro
> expander works, because it doesn't mark individual tokens.  A "disabled
> macro" stack is *not* enough by itself to implement ISO C macro expansion
> semantics.  You need to attach information to individual tokens as well.
> I've not tried it, but I'd bet that
> 
> #define A(x) x A(A)(1)
> 
> expands to "1" with your code, whereas the correct expansion is "A(1)".
> Implementing this properly is a PITA, more so with a text-based expander
> like yours.  It would be very hard to get the same (correct) semantics as
> cpplib in corner cases with a text-based expander (2.95 has outstanding
> bugs in this area).

Just for the record:

    (gdb) show macro A
    Defined at /home/jimb/gdb/macros/play/test.c:12
    #define A(x) x
    (gdb) macro expand A(A)(1)
    expands to: A(1)
    (gdb) 

That's not to say that there aren't other subtle bugs in there.  :)
And that's also not to say that replacing my macroexp.c with libcpp
isn't the right thing to do.


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