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 >
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. Hi John, What I am after is to be able to emit line number information for COFF (Common Object File Format) object module files, basically it comes down to paired line numbers and virtual address offsets. I have not really set out to look at this yet, just feeling ahead, and was prompted by Saman's question to have a look. So any pointers or help are most welcome, Aaron 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 >_______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Aaron Gray wrote:> 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. > > Hi John, > > What I am after is to be able to emit line number information for COFF > (Common Object File Format) object module files, basically it comes down to > paired line numbers and virtual address offsets. > > I have not really set out to look at this yet, just feeling ahead, and was > prompted by Saman's question to have a look. > > So any pointers or help are most welcome, > > Aaron >So you are digging into the code generator issues. That's beyond my ken. The original question seemed to be interested in getting debug information corresponding to an LLVM instruction at the LLVM IR level. That's what the code above does. In your case, you need additional information about what the code generator is doing. Unfortunately, I can't help you with that, but hopefully someone else can. Sorry. -- 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 >> >> > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
On Thursday 09 July 2009 10:01, John Criswell wrote:> 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.Ick. So line number information is only available at debug stop points? That's bad when compiling optimized code since the debug stops kill optimization, don't they? We have our own privately-maintained way of tracking line information even in optimized code but it's a big hack and not something suitable for pushing upstream. I thought I saw something on the list recently about someone working on integrating line number information directly into LLVM Instructions, SDNodes, MachineInstructions, etc. Am I mis-remembering? If not, what's the status of that? We'd like to switch over to a proper scheme if we can. -Dave
On Jul 9, 2009, at 10:26 AM, David Greene wrote:> On Thursday 09 July 2009 10:01, John Criswell wrote: >> 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. > > Ick. So line number information is only available at debug stop > points? > That's bad when compiling optimized code since the debug stops kill > optimization, don't they?Optimizers explicitly ignore the debug intrinsics.> I thought I saw something on the list recently about someone working > on > integrating line number information directly into LLVM Instructions, > SDNodes, > MachineInstructions, etc. Am I mis-remembering? If not, what's the > status > of that? We'd like to switch over to a proper scheme if we can.I'll let Devang describe the plan, -Chris
Hi David, On Thu, Jul 9, 2009 at 10:26 AM, David Greene<dag at cray.com> wrote:> On Thursday 09 July 2009 10:01, John Criswell wrote: >> 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. > > Ick. So line number information is only available at debug stop points? > That's bad when compiling optimized code since the debug stops kill > optimization, don't they?We worked hard to avoid this. Now if a debug stop point threatens to kill optimization then the llvm optimizer will kill the debug stop point itself! We have updated optimizer in all cases we could find. (Try running nightly tester using TEST=dbgopt and TEST=ipodbgopt and report failures.) However this means, in optimized code you may lose location info here and there.> We have our own privately-maintained way of tracking line information even > in optimized code but it's a big hack and not something suitable for > pushing upstream.Would it be possible to describe the work here ?> I thought I saw something on the list recently about someone working on > integrating line number information directly into LLVM Instructions, SDNodes, > MachineInstructions, etc. Am I mis-remembering? If not, what's the status > of that? We'd like to switch over to a proper scheme if we can.Now, each MI has line number info. The work is in progress to put debug info into LLVM instructions. The first step is to move away from all those pesky llvm.dbg.* GVs and use metadata. - Devang