Is there a way, using llvm, to relate LLVM instructions to the souce code statements (or line numbers) that they were generated from. So if compile some file test.c and get some binary test.bc can I relate statements in test.bc with source code line numbers in test.c and if so how would I go about doing that. Thanks for your time. - John -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20060407/fd6a6daf/attachment.html>
The debug intrinsics are intended for that. Please see: http://llvm.org/docs/SourceLevelDebugging.html for the details. Please note that this is being worked on actively Jim Laskey at Apple. He's working to get these intrinsics to generate DWARF output so that LLVM generated code can be used with a debugger. However, the intrinsics can be processed in whatever way you'd like via an LLVM pass. Reid. On Fri, 2006-04-07 at 14:59 -0700, John Trimble wrote:> So if compile some file test.c and get some binary test.bc can I > relate statements in test.bc with source code line numbers in test.c > and if so how would I go about doing that. Thanks for your time. >-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20060407/3eaba80e/attachment.sig>
If you use -g on the llvm gcc 4 command line and the C code gen from llc (-march=c) you will get this feature for free. Cheers, -- Jim On Apr 7, 2006, at 6:59 PM, John Trimble wrote:> Is there a way, using llvm, to relate LLVM instructions to the > souce code statements (or line numbers) that they were generated > from. So if compile some file test.c and get some binary test.bc > can I relate statements in test.bc with source code line numbers in > test.c and if so how would I go about doing that. Thanks for your > time. > > - John > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20060407/fb862978/attachment.bin>
Thanks for your help. I took a look at http://llvm.org/docs/SourceLevelDebugging.html and it seems like this doesn't give you much in the way of line number information. If you know what source line you are interested in then you can set a breakpoint, but suppose you want to know the line number in the source code for some arbitrary bytecode instruction. In my particular case, I have a pass that finds bytecode instructions that represent indirect calls, now I want to find out what line number and source file that indirect call came from. Is there currently not a way to get this type of information? Thanks again. - John Trimble On 4/7/06, Reid Spencer <reid at x10sys.com> wrote:> > The debug intrinsics are intended for that. Please see: > http://llvm.org/docs/SourceLevelDebugging.html > for the details. > > Please note that this is being worked on actively Jim Laskey at Apple. > He's working to get these intrinsics to generate DWARF output so that > LLVM generated code can be used with a debugger. However, the intrinsics > can be processed in whatever way you'd like via an LLVM pass. > > Reid. > > On Fri, 2006-04-07 at 14:59 -0700, John Trimble wrote: > > So if compile some file test.c and get some binary test.bc can I > > relate statements in test.bc with source code line numbers in test.c > > and if so how would I go about doing that. Thanks for your time. > > > > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.2.7 (GNU/Linux) > > iD8DBQBENusl3J9yEj6nvGcRAnu4AJ47NLg1bWv7mmzfa5+Et9ktF4QaYQCfUGeN > wpHV/Hj6NkQWvWIJRzdZO2c> =NvMj > -----END PGP SIGNATURE----- > > > _______________________________________________ > 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/20060408/abdc12b8/attachment.html>