[llvm-dev] [LLVMdev] DebugInfo from LLVM Instruction

Duncan P. N. Exon Smith via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 6 11:16:49 PDT 2015


> On 2015-Aug-06, at 10:58, David Blaikie <dblaikie at gmail.com> wrote:
> 
> +Duncan because I don't remember exactly how things shifted
> 
> On Thu, Aug 6, 2015 at 8:58 AM, Simone Atzeni via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> Hi all,
> 
> I used to extract the debug information from an LLVM Instruction in the following way:
> 
> if (MDNode *N = I->getMetadata("dbg")) {  // Here I is an LLVM instruction
>   DILocation Loc(N);                      // DILocation is in DebugInfo.h
>   unsigned Line = Loc.getLineNumber();
>   StringRef File = Loc.getFilename();
>   StringRef Dir = Loc.getDirectory();
> }
> 
> As specified also at http://llvm.org/docs/SourceLevelDebugging.html

Fixed the docs in r244238.

Probably what you want these days is something like:

    if (DILocation *Loc = I->getDebugLoc()) {
      unsigned Line = Loc->getLine();
      StringRef File = Loc->getFilename();
      StringRef Dir = Loc->getDirectory();
    }

> 
> However, looks like that the instruction " DILocation Loc(N);” is not valid anymore,
> Since the DILocation class is changed. 
> Is that right?
> How can I extract debug info (line, filename, etc.) from an instruction?
> 
> Thanks.
> Best Regards,
> Simone
> 
> 
> 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org         http://llvm.cs.uiuc.edu
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> 
> 



More information about the llvm-dev mailing list