[llvm-commits] [llvm] r99636 - /llvm/trunk/docs/SourceLevelDebugging.html

Devang Patel dpatel at apple.com
Fri Mar 26 12:08:36 PDT 2010


Author: dpatel
Date: Fri Mar 26 14:08:36 2010
New Revision: 99636

URL: http://llvm.org/viewvc/llvm-project?rev=99636&view=rev
Log:
Add a paragram describing how to extract line number information.

Modified:
    llvm/trunk/docs/SourceLevelDebugging.html

Modified: llvm/trunk/docs/SourceLevelDebugging.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/SourceLevelDebugging.html?rev=99636&r1=99635&r2=99636&view=diff
==============================================================================
--- llvm/trunk/docs/SourceLevelDebugging.html (original)
+++ llvm/trunk/docs/SourceLevelDebugging.html Fri Mar 26 14:08:36 2010
@@ -1069,6 +1069,18 @@
 </pre>
 </div>
 
+<p>llvm::Instruction provides easy access to metadata attached with an 
+instruction. One can extract line number information encoded in LLVM IR
+using <tt>Instruction::getMetadata()</tt> and 
+<tt>DILocation::getLineNumber()</tt>.
+<pre>
+ 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();
+ }
+</pre>
 </div>
 
 <!-- ======================================================================= -->





More information about the llvm-commits mailing list