Hi, I found the following at http://llvm.org/docs/SourceLevelDebugging.html#ccxx_frontend: 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(); } Does this also work for release 2.7? I did not see the same thing at the documentation for release 2.7. Thanks, Guoliang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100707/944903db/attachment.html>
On Jul 6, 2010, at 10:44 PM, Guoliang Jin wrote:> I found the following at http://llvm.org/docs/SourceLevelDebugging.html#ccxx_frontend > : > 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(); > } > Does this also work for release 2.7?Yes.> I did not see the same thing at the documentation for release 2.7.The link you cited is the documentation for release 2.7. Trevor
On 7/7/2010 3:08 PM, Trevor Harmon wrote:> On Jul 6, 2010, at 10:44 PM, Guoliang Jin wrote: > >> I found the following at >> http://llvm.org/docs/SourceLevelDebugging.html#ccxx_frontend: >> 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(); >> } >> Does this also work for release 2.7? > > Yes.OK. Thanks. I will try it.> >> I did not see the same thing at the documentation for release 2.7. > > The link you cited is the documentation for release 2.7.I thought it was documentation for mainline LLVM. Also I thought the documentation for release 2.7 was http://llvm.org/releases/2.7/docs/SourceLevelDebugging.html which does not mention the same example. Guoliang
Apparently Analagous Threads
- [LLVMdev] source line number for instruction
- [LLVMdev] source line number for instruction
- [LLVMdev] DebugInfo from LLVM Instruction
- [LLVMdev] Getting corresponding c-instruction line number along with ir-instruction in a function's CFG
- [LLVMdev] Replacement for findStopPoint() in LLVM 2.7