[cfe-dev] 'recording' program execution w/clang

Eli Friedman eli.friedman at gmail.com
Tue Nov 4 12:44:31 PST 2008


On Tue, Nov 4, 2008 at 9:38 AM, Edward Peschko <horos11 at gmail.com> wrote:
> Chris,
>
> I want to be able to record two versions of the same program and then
> do a diff to see in the code where the execution path changes..
>
> For example, say you want to see in mutt what the 'd' key does in the
> gui, ie: what parts of the source does it execute.. To do so, record
> two sessions, one where you press the d key, and one where you don't.
> Do a 'vimdiff' between the two, and you have your answer - without
> needing to know the structure of the code at all.
>
> Hence, I'd need actual code, because ultimately I want to use this
> with an IDE to trace it back to the original source (and set further
> debug points, etc.)

I'm not completely sure about everything you're trying to do, but it
seems like you have a lot of options depending on the result you're
looking for.

The source-to-source rewriter should be able to safely duplicate what
you've been doing in Perl; it's designed precisely for making global
transformations like this on source code.

At the LLVM IL level, you should also be able to create a similar kind
of trace by doing transformations based on debug info; it might be a
bit tricky to write, though.

There might be a much simpler, approach, though: I'm pretty sure you
can script GDB to create a similar trace for a program with debug
info.

Also, http://code.google.com/p/chronomancer/ might be of interest.

-Eli



More information about the cfe-dev mailing list