I get it now, I can't believe I didn't understand that before. Thank you all for your help!<br><br>- John<br><br><div><span class="gmail_quote">On 4/8/06, <b class="gmail_sendername">Chris Lattner</b> <<a href="mailto:sabre@nondot.org">
sabre@nondot.org</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On Sat, 8 Apr 2006, Jim Laskey wrote:<br>> If you look at the stoppoint calls you'll see that you can find the line
<br>> number and if you follow the compile unit argument on the call you will find<br>> the file.  The byte codes that follow the call would have been generated by<br>> the code on that source line.<br><br>I'd suggest an approach like this:
<br><br>Given an instruction in the a basic block, scan up and/or down the basic<br>block, stopping at the first llvm.dbg.stoppoint instruction.  Something<br>like this should work:<br><br>#include "llvm/IntrinsicInst.h"
<br>...<br><br>for (...)<br>   if (DbgStopPointInst *SP = dyn_cast<DbgStopPointInst>(Inst))<br>     std::cerr << "Loc: " << SP->getFileName() << ":" << SP->getLine() << "\n";
<br><br>If you look at IntrinsicInst, you'll see methods to get the<br>filename,directory,line#,col#, all packaged up into an easy to use class<br>(some of Jim's excellent work :).<br><br>-Chris<br><br>> On Apr 8, 2006, at 5:33 AM, John Trimble wrote:
<br>><br>>> Thanks for your help. I took a look at <a href="http://llvm.org/docs/">http://llvm.org/docs/</a><br>>> SourceLevelDebugging.html and it seems like this doesn't give you much in<br>>> the way of line number information. If you know what source line you are
<br>>> interested in then you can set a breakpoint, but suppose you want to know<br>>> the line number in the source code for some arbitrary bytecode instruction.<br>>> In my particular case, I have a pass that finds bytecode instructions that
<br>>> represent indirect calls, now I want to find out what line number and<br>>> source file that indirect call came from. Is there currently not a way to<br>>> get this type of information? Thanks again.
<br>>><br>>> - John Trimble<br>>><br>>> On 4/7/06, Reid Spencer <<a href="mailto:reid@x10sys.com">reid@x10sys.com</a>> wrote:<br>>> The debug intrinsics are intended for that.  Please see:
<br>>> <a href="http://llvm.org/docs/SourceLevelDebugging.html">http://llvm.org/docs/SourceLevelDebugging.html</a><br>>> for the details.<br>>><br>>> Please note that this is being worked on actively Jim Laskey at Apple.
<br>>> He's working to get these intrinsics to generate DWARF output so that<br>>> LLVM generated code can be used with a debugger. However, the intrinsics<br>>> can be processed in whatever way you'd like via an LLVM pass.
<br>>><br>>> Reid.<br>>><br>>> On Fri, 2006-04-07 at 14:59 -0700, John Trimble wrote:<br>>> > So if compile some file test.c and get some binary test.bc can I<br>>> > relate statements in 
test.bc with source code line numbers in test.c<br>>> > and if so how would I go about doing that. Thanks for your time.<br>>> ><br>>><br>>><br>>> -----BEGIN PGP SIGNATURE-----<br>>> Version: GnuPG 
v1.2.7 (GNU/Linux)<br>>><br>>> iD8DBQBENusl3J9yEj6nvGcRAnu4AJ47NLg1bWv7mmzfa5+Et9ktF4QaYQCfUGeN<br>>> wpHV/Hj6NkQWvWIJRzdZO2c=<br>>> =NvMj<br>>> -----END PGP SIGNATURE-----<br>>><br>>>
<br>>> _______________________________________________<br>>> LLVM Developers mailing list<br>>> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>          <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu
</a><br>>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>>><br>>><br>>><br>>> _______________________________________________
<br>>> LLVM Developers mailing list<br>>> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br>>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>><br>><br><br>-Chris<br><br>--<br><a href="http://nondot.org/sabre/">http://nondot.org/sabre/</a><br><a href="http://llvm.org/">http://llvm.org/</a><br><br>_______________________________________________
<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br>