[cfe-dev] source-to-source transformation to insert instrumentation calls

Dmitri Gribenko gribozavr at gmail.com
Mon Sep 24 08:50:36 PDT 2012

On Mon, Sep 24, 2012 at 6:43 PM, Jan Smets <jan.smets at alcatel-lucent.com> wrote:
> That's OK. I'm aware that I won't be 100% accurate.

OK, good to know.

> Now I just need to figure out a good location to insert the call! :)

I think that there are cases where inserting instrumentation calls
will require non-trivial rewriting.  For example:

int f(int, int);
int g(int *)
int test(int *a)
    f(*a, g(a));

Function argument evaluation order is unspecified, so we can not
simply insert an instrumentation call for *a before f() because *a can
be evaluated after g(a), which can change *a.

So we need to make an arbitrary decision ourselves and rewrite this to
something like:

int test(int *a)
    int tmp1 = *a;
    int tmp2 = g(a);
    f(tmp1, tmp2);

I didn't give this much thought, but I suspect there are much more
cases like this.


(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/

More information about the cfe-dev mailing list