I followed the install.txt instructions and have been playing around
with coccinelle-1.0.0-rc5 on Ubuntu 11.04 and have some questions:
I'm interested in the idea of creating different builds of the same C source
file by instrumenting the source file on the fly. For example, I might have
a release build of foo.c and a debug build of foo.c. The debug version of
foo.c might have access to reflective functions and data which are only
available in the debug version. My idea is to use coccinelle to create those
functions and data on the fly. A simple example is as follows: Let's say
foo.c contains an enum. I'd like to auto-generate a reflective function
which given an enum, returns the enum as a string for logging/debugging
purposes. Of course, I could just write such an enum to string function
myself, but then every time I change the enum then I'd have to update the
enum to string function. How can I use coccinelle to give my scripts the
info about foo.c that they need in order to auto-generate such an enum to
string function? I have been playing around with -token_c and -type_c which
look promising. Is this the right way to go for what I want to do? How can I
learn more about using -token_c and understanding the output?
Another thing that I've been thinking about is how coccinelle deals with
#include files. Where can I read up on its handling of included header
files?
Assuming there is a good answer to the first part of my question, in an
extreme example, how could I get coccinelle to tell me whether INVISIBLE is
part of cardsuit or not for my particular build? Obviously my script which
wants to auto-generate the debug_cardsuit_enum_to_text() function needs to
know whether DIAMONDS will be 1 or 2.
enum cardsuit {
CLUBS,
#ifdef SECRETSUIT
INVISIBLE,
#endif
DIAMONDS,
HEARTS,
SPADES
};
Thanks in advance,
Simon
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)