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
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
+Duncan because I don’t remember exactly how things shifted
+Duncan because I don't remember exactly how things shifted
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 Source Level Debugging with LLVM — LLVM 18.0.0git documentation
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();
}