<div>Hi edwin,</div>
<div> I am working on a similar project and some of my suggestions regarding your approach are inlined with this email.. :) read below.<br></div>
<div class="gmail_quote"> </div>
<div class="gmail_quote">On Dec 25, 2007 2:56 PM, Török Edwin <<a href="mailto:edwintorok@gmail.com" target="_blank">edwintorok@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi,<br><br>I was looking at how to  use debug info to find out original source:line<br>for a certain function/variable in the llvm bytecode. 
<br><br>I read <a href="http://llvm.org/docs/SourceLevelDebugging.html" target="_blank">http://llvm.org/docs/SourceLevelDebugging.html</a>, and then I have<br>looked in lib/Debugger/ProgramInfo.cpp.<br>getFunction() looks useful, however I am not sure how to call it. I have 
<br>a reference to a Function, however getFunction() takes<br>a GlobalVariable. I tried creating a GlobalVariable that points to my<br>Function, but that didn't work, since getFunction() is looking<br>at uses of the GlobalVariable, which in my case was none. 
</blockquote>
<div> </div>
<div>It could be better to just iterate over the functions using the runOnFunction pass on the bitcode file and then use the getName() method on the returned objects to find the name of the function (as in the high level language)
</div>
<div> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span></span><br><br>Am I missing something obvious here? How do I find out source:line for<br>an LLVM Function? (assuming original file was compiled with debug info, 
<br>and bitcode has debug info)</blockquote>
<div> </div>
<div>It could be possible to do so using the debug info in the file, i have tried it but without any luck. Another approach i have tried and has worked out can be found at my earlier posting at this link <a href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-December/011892.html">
http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-December/011892.html</a></div>
<div> </div>
<div> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span id=""></span><br>Or is it just easier to iterate on the Function's  BasicBlocks, and look<br>for 
llvm.dbg.* instrinsics?<br><br>As you might have guessed from the subject, I want to use this in a <br>static analysis tool (that works on llvm bitcode),<br>and it would be useful if it could provide the user with nice messages,
<br>that include references to the original source file:line, possibly with<br>original types and variable names. </blockquote>
<div> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span></span><br><br>All this seems to be available in the debug info (as generated by<br>llvm-gcc -O0 -g), but I couldn't find functions to query for it. 
<br>I plan on implementing some utility classes for my project, to make it<br>easier to query for such information, and I'd like it to design it in a<br>way that could be useful for LLVM too. Suggestions?<br><br>Best regards, 
<br>--Edwin</blockquote>
<div> </div>
<div>Getting function level information seems to be easier, but it would be quite interesting to see how one can map the information in the bitcode file (along with the debug info) to the source lines in the high level language. 
</div>
<div> </div>
<div>Best of luck and best regards</div>
<div>Prabhat</div>
<div> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span id=""></span><br><br><br><br><br>_______________________________________________<br>LLVM Developers mailing list
<br><a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu/" target="_blank">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br>