Expand on comment.
[oota-llvm.git] / docs / SourceLevelDebugging.html
index 66a9a2e34ef8a36a43d00caac5671eb2e42982b4..e4c84606107b47369d51cde12f9accaa2f08ada7 100644 (file)
@@ -144,7 +144,7 @@ height="369">
    an LLVM user a relationship between generated code and the original program
    source code.</p>
 
-<p>Currently, debug information is consumed by the DwarfWriter to produce dwarf
+<p>Currently, debug information is consumed by DwarfDebug to produce dwarf
    information used by the gdb debugger.  Other targets could use the same
    information to produce stabs or other debug forms.</p>
 
@@ -289,26 +289,25 @@ height="369">
    0x1000.)</p>
 
 <p>The fields of debug descriptors used internally by LLVM 
-   are restricted to only the simple data types <tt>int</tt>, <tt>uint</tt>,
-   <tt>bool</tt>, <tt>float</tt>, <tt>double</tt>, <tt>mdstring</tt> and
-   <tt>mdnode</tt>. </p>
+   are restricted to only the simple data types <tt>i32</tt>, <tt>i1</tt>,
+   <tt>float</tt>, <tt>double</tt>, <tt>mdstring</tt> and <tt>mdnode</tt>. </p>
 
 <div class="doc_code">
 <pre>
 !1 = metadata !{
-  uint,   ;; A tag
+  i32,   ;; A tag
   ...
 }
 </pre>
 </div>
 
 <p><a name="LLVMDebugVersion">The first field of a descriptor is always an
-   <tt>uint</tt> containing a tag value identifying the content of the
+   <tt>i32</tt> containing a tag value identifying the content of the
    descriptor.  The remaining fields are specific to the descriptor.  The values
    of tags are loosely bound to the tag values of DWARF information entries.
    However, that does not restrict the use of the information supplied to DWARF
    targets.  To facilitate versioning of debug information, the tag is augmented
-   with the current debug version (LLVMDebugVersion = 8 << 16 or 0x80000 or
+   with the current debug version (LLVMDebugVersion = 8 &lt;&lt; 16 or 0x80000 or
    524288.)</a></p>
 
 <p>The details of the various descriptors follow.</p>  
@@ -829,8 +828,8 @@ DW_TAG_return_variable = 258
    rules.</p>
 
 <p>In order to handle this, the LLVM debug format uses the metadata attached to
-   llvm instructions to encode line nuber and scoping information. Consider the
-   following C fragment, for example:</p>
+   llvm instructions to encode line number and scoping information. Consider
+   the following C fragment, for example:</p>
 
 <div class="doc_code">
 <pre>
@@ -1069,6 +1068,18 @@ int main(int argc, char *argv[]) {
 </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>
 
 <!-- ======================================================================= -->