[cfe-dev] preprocessor hacking

phi clang phi.clang at gmail.com
Sat May 24 08:14:46 PDT 2014


Hi All,

I am new to clang (llvm). As an hacking exercise, I'd like to experiment to
start doing it in the preprocessor. I have an active project where I have
my own 'middle-processor' and so far I work with various compiler with the
following pipe.
cpp | my-middle-processor | cc

More realistically the real pipe is more like
cc -P hi.c | my-middle-processor > hi.i ; cc hi.i

Basically my-middle-processor does simple things that can't be done by cpp
itself, yet don't need to knowledge of what it scan (no C parser needed).

I can still work this way with clang, but as an exercise I'd like to see if
I can glue by text processing inside the clang cpp.

May be later, I could move this recognition as a real 'c extension', then
bring back the cpp it is actual behavior, and recognise the input construct
in the C grammar.

So now I successfully buillt a clang+llvm -g and I am able to run GDB on
it, and the question is, what is the function name I should put a
breakpoint on when cleang cpp is getting its first char.

I tried fread, read, mmap, but those are never catched.

Now things to know I am totally c++ iliterate, I do all my work in C, so
may be I should do something like b class:func but got no idea of what
class name could be.

Any help appreciated.

=================================

A basic side question, I am not using VT100 terminal, (using old hpterm),
it sounds like clang emit escape sequence for error message that seems
vt1000 hardcoded, or at least ignoring my TERM env var, is there a way to
mute the usage of escape sequence (I'm sure this is a trivial question,
don't flame :) )

Cheers,
Phi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140524/a0011ede/attachment.html>


More information about the cfe-dev mailing list