>> -----Original Message----- >> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] > On >> Behalf Of Saman Aliari Zonouz >> Sent: Thursday, July 09, 2009 11:44 AM >> To: llvmdev at cs.uiuc.edu >> Subject: [LLVMdev] Source file information. >> >> Hi, >> >> I am new to LLVM, and need to find the line number and cpp source file >> name for each instruction in a .bc file. I suppose llvm debugger might >> have that feature but there is no documentation on it. Would you > please >> give me some help how to do it? >> > Compile the original .cpp file with clang -g option. > The file/line is maintained in SDNodes with DebugLoc field.Can you also get this information in LLVM ? And what about with llvm-gcc ? Many thanks in advance, Aaron
On 2009-07-09 11:17, Aaron Gray wrote:>>> -----Original Message----- >>> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] >>> >> On >> >>> Behalf Of Saman Aliari Zonouz >>> Sent: Thursday, July 09, 2009 11:44 AM >>> To: llvmdev at cs.uiuc.edu >>> Subject: [LLVMdev] Source file information. >>> >>> Hi, >>> >>> I am new to LLVM, and need to find the line number and cpp source file >>> name for each instruction in a .bc file. I suppose llvm debugger might >>> have that feature but there is no documentation on it. Would you >>> >> please >> >>> give me some help how to do it? >>> >>> >> Compile the original .cpp file with clang -g option. >> The file/line is maintained in SDNodes with DebugLoc field. >> > > Can you also get this information in LLVM ? >See Analysis/DebugInfo.h, and opt -print-dbginfo for an example of how to use it.> And what about with llvm-gcc ? >Yes, if compiled with -g. Best regards, --Edwin
> On 2009-07-09 11:17, Aaron Gray wrote: >>>> -----Original Message----- >>>> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] >>>> >>> On >>> >>>> Behalf Of Saman Aliari Zonouz >>>> Sent: Thursday, July 09, 2009 11:44 AM >>>> To: llvmdev at cs.uiuc.edu >>>> Subject: [LLVMdev] Source file information. >>>> >>>> Hi, >>>> >>>> I am new to LLVM, and need to find the line number and cpp source file >>>> name for each instruction in a .bc file. I suppose llvm debugger might >>>> have that feature but there is no documentation on it. Would you >>>> >>> please >>> >>>> give me some help how to do it? >>>> >>>> >>> Compile the original .cpp file with clang -g option. >>> The file/line is maintained in SDNodes with DebugLoc field. >>> >> >> Can you also get this information in LLVM ? >> > > See Analysis/DebugInfo.h, and opt -print-dbginfo for an example of how > to use it. >> And what about with llvm-gcc ? >> > > Yes, if compiled with -g.Thanks Edwin. I will look into this when I get some spare time. Aaron
Dear All, To add to this, what you want to do is find the appropriate debug stop point intrinsic and then use it to look up the information for that instruction. Here is some sample code from SAFECode that finds the debug information associated with a CallInst (LLVM call instruction) held in the variable CI. It uses the findStopPoint() function in llvm/Analyis/DebugInfo.h: // // Get the line number and source file information for the call. // const DbgStopPointInst * StopPt = findStopPoint (CI); Value * LineNumber; Value * SourceFile; if (StopPt) { LineNumber = StopPt->getLineValue(); SourceFile = StopPt->getFileName(); } -- John T. Török Edwin wrote:> On 2009-07-09 11:17, Aaron Gray wrote: > >>>> -----Original Message----- >>>> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] >>>> >>>> >>> On >>> >>> >>>> Behalf Of Saman Aliari Zonouz >>>> Sent: Thursday, July 09, 2009 11:44 AM >>>> To: llvmdev at cs.uiuc.edu >>>> Subject: [LLVMdev] Source file information. >>>> >>>> Hi, >>>> >>>> I am new to LLVM, and need to find the line number and cpp source file >>>> name for each instruction in a .bc file. I suppose llvm debugger might >>>> have that feature but there is no documentation on it. Would you >>>> >>>> >>> please >>> >>> >>>> give me some help how to do it? >>>> >>>> >>>> >>> Compile the original .cpp file with clang -g option. >>> The file/line is maintained in SDNodes with DebugLoc field. >>> >>> >> Can you also get this information in LLVM ? >> >> > > See Analysis/DebugInfo.h, and opt -print-dbginfo for an example of how > to use it. > >> And what about with llvm-gcc ? >> >> > > Yes, if compiled with -g. > > 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 >