[cfe-dev] Code instrumentation in Clang?

Kostya Serebryany kcc at google.com
Mon Jan 23 09:52:04 PST 2012


Why would you want to add instrumentation in Clang and not in LLVM?
For an example of LLVM instrumentation pass, take a look
at lib/Transforms/Instrumentation/AddressSanitizer.cpp.

--kcc

On Sat, Jan 21, 2012 at 8:13 AM, Robert Ankeney <rrankene at gmail.com> wrote:

> I'm trying to get up to speed on using Clang by doing a bit of dynamic
> code analysis by instrumenting C (and maybe C++) code where I take a
> source file and generate an instrumented output. I'd like to add a
> function call at the beginning of any block to mark statement coverage
> and also change all boolean expressions to call some function so I can
> track that too. For example:
>        foo = a && (b || c);
> would become something like:
>        foo = EXPR_AND(a, EXPR_OR(b, c));
> and thus I can track all combinations of conditions that occur.  I'd
> need to track where in the source code I am too, and save that info
> seperately.  This is a bit beyond what gcov provides.
> I'm gussing that using a RecursiveASTVisitor would be the best
> approach, but whatever approach I take, is there an easy way to output
> the C code for each node I visit?
> Any suggestions of what to look at to accomplish something like this
> would be most appreciated!
>
> Thanks!
> Robert
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120123/a93a388a/attachment.html>


More information about the cfe-dev mailing list