Vardhan Varma
2013-Mar-06 10:39 UTC
[LLVMdev] embedding trace functions to generate variable values
Hi, This is my first post on this forum so please use soft batons (-; 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. It's a little like the old unix program ctrace[1], but using LLVM, instead of rewriting C ! [1] http://docs.oracle.com/cd/E24457_01/html/E22003/ctrace.1.html Thanx in advance, --Vardhan -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130306/71334002/attachment.html>
Pekka Jääskeläinen
2013-Mar-06 11:18 UTC
[LLVMdev] embedding trace functions to generate variable values
Hi, On 03/06/2013 12:39 PM, 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.At least some time ago I couldn't find something like this in LLVM so I implemented simple IR variable dumping via injecting printf calls to debug data flow issues in pocl parallel region formation. The code might help you to get forward if you want to generalize it: InjectVariablePrintouts(): http://bazaar.launchpad.net/~pocl/pocl/trunk/view/head:/lib/llvmopencl/ParallelRegion.cc#L722 BR, -- Pekka
John Criswell
2013-Mar-06 16:31 UTC
[LLVMdev] embedding trace functions to generate variable values
On 3/6/13 4:39 AM, Vardhan Varma wrote:> > Hi, > This is my first post on this forum so please use soft batons (-; > > 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. > > It's a little like the old unix program ctrace[1], but using LLVM, > instead > of rewriting C ! > > > [1] http://docs.oracle.com/cd/E24457_01/html/E22003/ctrace.1.html > Thanx in advance,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. -- John T.> > --Vardhan > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130306/9d6fbeb0/attachment.html>
Vardhan Varma
2013-Mar-06 17:48 UTC
[LLVMdev] embedding trace functions to generate variable values
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>