[LLVMdev] embedding trace functions to generate variable values

Vardhan Varma vardhanvarma at gmail.com
Wed Mar 6 09:48:23 PST 2013


Hi John,

On Wed, Mar 6, 2013 at 10:01 PM, John Criswell <criswell at illinois.edu>wrote:

>  On 3/6/13 4:39 AM, Vardhan Varma wrote:
>
>    I'm wondering if there is feature already  in LLVM or clang to embed
>   variable tracing instructions in the compiled output, so that on
> execution
>   of the program, a dump of various variables values over time is
> generated.
>
> No, I don't believe there is a tool quite like that in LLVM.  However, we
> have a research prototype dynamic backwards slicing tool called Giri
> written with LLVM.  Giri instruments a program to record all basic block
> and loads/store executions in a trace file and can then use this trace to
> find all LLVM IR instructions that were executed in that execution of the
> program.
>
> You could probably enhance Giri with additional features to do what you
> describe.
>
> If you'd like a copy of Giri, please email the list.
>

Thanks for mentioning the name of 'Giri',
 I search the archives to get a pointer to the svn :
https://llvm.org/svn/llvm-project/giri/trunk/
 I saw from the code that it's not trying to use Metadata. I _think_
solution to my problem will require metadata.

 <Explaining-My-Problem>
  Take a C  Code:
      10. int a = 10;
      11. int b = 100;
      12. a = a + b;
   I'm trying to see if I can instrument this  in LLVM-IR, so that a
logfile like  this can be generated, when the program is executed:
       line = 10, var=a, val=10
       line = 11, var=b, val=100
       line =  12, var=a, val=110
 </Explaining-My-Problem>

       Initially, it looked like the %llvm.dbg.value() intrinsic can be
'replaced' by a printf to achieve this. Howver, by looking at code , I was
not able to follow as to when is the llvm.dbg.value() is generated.
 The reason for looking at %llvm.dbg.value() was that because it seemed
that it already 'knows' about all the temporary names of the actualy
variable. I'll keep investigating, though any more help will do wonders to
my night-lamp  (-:



-Regards
-Vardhan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130306/6d3949e8/attachment.html>


More information about the llvm-dev mailing list