Thanks Edwin. I found DebugInfo.cpp may be useful. Could you tell me which function I should call inorder to know the source file name and the line number for a particular instruction? Cheers, Zheng 2010/5/18 Török Edwin <edwintorok at gmail.com>:> On 05/18/2010 01:26 PM, Zheng Wang wrote: >> Hello, >> >> Could I get some debug info at the byte code level? I am writing a >> passer and if will be nice if I can know which line in the source an >> instruction (or value) corresponds to. >> >> I found a document online: >> http://llvm.org/docs/SourceLevelDebugging.html, but I can't find an >> example of doing it at the byte code level. > > -print-dbginfo should print the source lines, at least the one in 2.6, > the one in 2.7 seems to have the source line printing removed. > > I'll add it back when I get some time. > > Best regards, > --Edwin > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Best regards, WANG Zheng
On 05/18/2010 02:08 PM, Zheng Wang wrote:> Thanks Edwin. > > I found DebugInfo.cpp may be useful. Could you tell me which function > I should call inorder to know the source file name and the line number > for a particular instruction?Which version of LLVM? There was a major change between 2.6 and 2.7 so my answer depends on that.> > Cheers, > Zheng > > 2010/5/18 Török Edwin <edwintorok at gmail.com>: >> On 05/18/2010 01:26 PM, Zheng Wang wrote: >>> Hello, >>> >>> Could I get some debug info at the byte code level? I am writing a >>> passer and if will be nice if I can know which line in the source an >>> instruction (or value) corresponds to. >>> >>> I found a document online: >>> http://llvm.org/docs/SourceLevelDebugging.html, but I can't find an >>> example of doing it at the byte code level. >> >> -print-dbginfo should print the source lines, at least the one in 2.6, >> the one in 2.7 seems to have the source line printing removed. >> >> I'll add it back when I get some time. >> >> Best regards, >> --Edwin >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > > >
Thanks Edwin, I will check it out. Cheers, Zheng 2010/5/18 Török Edwin <edwintorok at gmail.com>:> On 05/18/2010 02:13 PM, Zheng Wang wrote: >> Got it. >> >> I am using LLVM 2.6. I guess bool getLocationInfo(const Value *V, >> std::string &DisplayName,...) has everything I need.\ > > Yes, for variables. > For instructions see what printStopPoint() does in DbgInfoPrinter.cpp. > > However I'd suggest upgrading to llvm 2.7 and doing your development > there directly. > First of all llvm 2.7 has much better debuginfo support (in 2.6 applying > any optimization would most likely destroy line number debug info) > Also 2.7 has a new way of representing debug info (Metadata instead of > intrinsics), so it'll be less work to implement it for 2.7 right now > instead of implementing for 2.6, and then reimplementing for 2.7 > >> >> Thanks a lot!! >> >> Cheers, >> Zheng >> >> 2010/5/18 Török Edwin <edwintorok at gmail.com>: >>> On 05/18/2010 02:08 PM, Zheng Wang wrote: >>>> Thanks Edwin. >>>> >>>> I found DebugInfo.cpp may be useful. Could you tell me which function >>>> I should call inorder to know the source file name and the line number >>>> for a particular instruction? >>> >>> Which version of LLVM? >>> There was a major change between 2.6 and 2.7 so my answer depends on that. >>> >>>> >>>> Cheers, >>>> Zheng >>>> >>>> 2010/5/18 Török Edwin <edwintorok at gmail.com>: >>>>> On 05/18/2010 01:26 PM, Zheng Wang wrote: >>>>>> Hello, >>>>>> >>>>>> Could I get some debug info at the byte code level? I am writing a >>>>>> passer and if will be nice if I can know which line in the source an >>>>>> instruction (or value) corresponds to. >>>>>> >>>>>> I found a document online: >>>>>> http://llvm.org/docs/SourceLevelDebugging.html, but I can't find an >>>>>> example of doing it at the byte code level. >>>>> >>>>> -print-dbginfo should print the source lines, at least the one in 2.6, >>>>> the one in 2.7 seems to have the source line printing removed. >>>>> >>>>> I'll add it back when I get some time. >>>>> >>>>> Best regards, >>>>> --Edwin >>>>> _______________________________________________ >>>>> LLVM Developers mailing list >>>>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >>>>> >>>> >>>> >>>> >>> >>> >> >> >> > >-- Best regards, WANG Zheng
2010/5/18 Zheng Wang <jason.wangz at gmail.com>:> > I found DebugInfo.cpp may be useful. Could you tell me which function > I should call inorder to know the source file name and the line number > for a particular instruction? >See http://llvm.org/docs/SourceLevelDebugging.html#ccxx_frontend At the end of "C/C++ source file information" section, there is a small code snippet this describes how to extract this information. - Devang
Devang Patel <devang.patel <at> gmail.com> writes:> > 2010/5/18 Zheng Wang <jason.wangz <at> gmail.com>: > > > > I found DebugInfo.cpp may be useful. Could you tell me which function > > I should call inorder to know the source file name and the line number > > for a particular instruction? > > > > See http://llvm.org/docs/SourceLevelDebugging.html#ccxx_frontend > At the end of "C/C++ source file information" section, there is a > small code snippet this describes how to extract this information. > > - > Devang >Hi Devang, I think the link you provided above is for LLVM 2.7. Is there any way to get source line number from bitcode in LLVM 2.5/2.6? Thanks, Nehal.