[sphinx cleanup]
[oota-llvm.git] / docs / SourceLevelDebugging.rst
index e62e89d8672bcd9577b9374458605df6fde19aa8..f7b62cb0872371221da2ed0466b10810da590bc4 100644 (file)
@@ -213,6 +213,7 @@ Compile unit descriptors
     metadata   ;; List of global variables
     metadata   ;; List of imported entities
     metadata   ;; Split debug filename
+    i32        ;; Debug info emission kind (1 = Full Debug Info, 2 = Line Tables Only)
   }
 
 These descriptors contain a source language ID for the file (we use the DWARF
@@ -235,8 +236,8 @@ File descriptors
 .. code-block:: llvm
 
   !0 = metadata !{
-    i32,       ;; Tag = 41 (DW_TAG_file_type)
-    metadata,  ;; Source directory (including trailing slash) & file pair
+    i32,      ;; Tag = 41 (DW_TAG_file_type)
+    metadata, ;; Source directory (including trailing slash) & file pair
   }
 
 These descriptors contain information for a file.  Global variables and top
@@ -269,7 +270,7 @@ Global variable descriptors
     metadata, ;; The static member declaration, if any
   }
 
-These descriptors provide debug information about globals variables.  They
+These descriptors provide debug information about global variables.  They
 provide details such as name, type and where the variable is defined.  All
 global variables are collected inside the named metadata ``!llvm.dbg.cu``.
 
@@ -295,9 +296,9 @@ Subprogram descriptors
     i32,      ;; Index into a virtual function
     metadata, ;; indicates which base type contains the vtable pointer for the
               ;; derived class
-    i32,      ;; Flags - Artifical, Private, Protected, Explicit, Prototyped.
+    i32,      ;; Flags - Artificial, Private, Protected, Explicit, Prototyped.
     i1,       ;; isOptimized
-    Function * , ;; Pointer to LLVM function
+    {}*,      ;; Reference to the LLVM function
     metadata, ;; Lists function template parameters
     metadata, ;; Function declaration descriptor
     metadata, ;; List of function variables
@@ -314,12 +315,12 @@ Block descriptors
 .. code-block:: llvm
 
   !3 = metadata !{
-    i32,     ;; Tag = 11 (DW_TAG_lexical_block)
-    metadata,;; Source directory (including trailing slash) & file pair
-    metadata,;; Reference to context descriptor
-    i32,     ;; Line number
-    i32,     ;; Column number
-    i32      ;; Unique ID to identify blocks from a template function
+    i32,      ;; Tag = 11 (DW_TAG_lexical_block)
+    metadata, ;; Source directory (including trailing slash) & file pair
+    metadata, ;; Reference to context descriptor
+    i32,      ;; Line number
+    i32,      ;; Column number
+    i32       ;; Unique ID to identify blocks from a template function
   }
 
 This descriptor provides debug information about nested blocks within a
@@ -329,9 +330,10 @@ lexical blocks at same depth.
 .. code-block:: llvm
 
   !3 = metadata !{
-    i32,     ;; Tag = 11 (DW_TAG_lexical_block)
-    metadata,;; Source directory (including trailing slash) & file pair
-    metadata ;; Reference to the scope we're annotating with a file change
+    i32,      ;; Tag = 11 (DW_TAG_lexical_block)
+    metadata, ;; Source directory (including trailing slash) & file pair
+    metadata  ;; Reference to the scope we're annotating with a file change
+    i32,      ;; DWARF path discriminator value
   }
 
 This descriptor provides a wrapper around a lexical scope to handle file
@@ -527,9 +529,9 @@ Subrange descriptors
 .. code-block:: llvm
 
   !42 = metadata !{
-    i32,    ;; Tag = 33 (DW_TAG_subrange_type)
-    i64,    ;; Low value
-    i64     ;; High value
+    i32,      ;; Tag = 33 (DW_TAG_subrange_type)
+    i64,      ;; Low value
+    i64       ;; High value
   }
 
 These descriptors are used to define ranges of array subscripts for an array
@@ -566,9 +568,10 @@ Local variables
     metadata, ;; Reference to file where defined
     i32,      ;; 24 bit - Line number where defined
               ;; 8 bit - Argument number. 1 indicates 1st argument.
-    metadata, ;; Type descriptor
+    metadata, ;; Reference to the type descriptor
     i32,      ;; flags
     metadata  ;; (optional) Reference to inline location
+    metadata  ;; (optional) Reference to a complex expression (see below)
   }
 
 These descriptors are used to define variables local to a sub program.  The
@@ -587,6 +590,12 @@ The context is either the subprogram or block where the variable is defined.
 Name the source variable name.  Context and line indicate where the variable
 was defined.  Type descriptor defines the declared type of the variable.
 
+The ``OpPiece`` operator is used for (typically larger aggregate)
+variables that are fragmented across several locations. It takes two
+i32 arguments, an offset and a size in bytes to describe which piece
+of the variable is at this location.
+
+
 .. _format_common_intrinsics:
 
 Debugger intrinsic functions
@@ -650,85 +659,86 @@ Compiled to LLVM, this function would be represented like this:
 
 .. code-block:: llvm
 
-  define void @_Z3foov() #0 {
+  define void @foo() #0 {
   entry:
-    %X = alloca i32, align 4                        ; [#uses=3 type=i32*]
-    %Y = alloca i32, align 4                        ; [#uses=2 type=i32*]
-    %Z = alloca i32, align 4                        ; [#uses=2 type=i32*]
-    call void @llvm.dbg.declare(metadata !{i32* %X}, metadata !8), !dbg !10
+   %X = alloca i32, align 4
+    %Y = alloca i32, align 4
+    %Z = alloca i32, align 4
+    call void @llvm.dbg.declare(metadata !{i32* %X}, metadata !10), !dbg !12
       ; [debug line = 2:7] [debug variable = X]
-    store i32 21, i32* %X, align 4, !dbg !11        ; [debug line = 2:13]
-    call void @llvm.dbg.declare(metadata !{i32* %Y}, metadata !12), !dbg !13
+    store i32 21, i32* %X, align 4, !dbg !12
+    call void @llvm.dbg.declare(metadata !{i32* %Y}, metadata !13), !dbg !14
       ; [debug line = 3:7] [debug variable = Y]
-    store i32 22, i32* %Y, align 4, !dbg !14        ; [debug line = 3:13]
+    store i32 22, i32* %Y, align 4, !dbg !14
     call void @llvm.dbg.declare(metadata !{i32* %Z}, metadata !15), !dbg !17
       ; [debug line = 5:9] [debug variable = Z]
-    store i32 23, i32* %Z, align 4, !dbg !18        ; [debug line = 5:15]
-    %0 = load i32* %X, align 4, !dbg !19            ; [#uses=1 type=i32] \
+    store i32 23, i32* %Z, align 4, !dbg !17
+    %0 = load i32* %X, align 4, !dbg !18
       [debug line = 6:5]
-    store i32 %0, i32* %Z, align 4, !dbg !19        ; [debug line = 6:5]
-    %1 = load i32* %Y, align 4, !dbg !20            ; [#uses=1 type=i32] \
+    store i32 %0, i32* %Z, align 4, !dbg !18
+    %1 = load i32* %Y, align 4, !dbg !19
       [debug line = 8:3]
-    store i32 %1, i32* %X, align 4, !dbg !20        ; [debug line = 8:3]
-    ret void, !dbg !21                              ; [debug line = 9:1]
+    store i32 %1, i32* %X, align 4, !dbg !19
+    ret void, !dbg !20
   }
 
-  ; [#uses=3]
   ; Function Attrs: nounwind readnone
   declare void @llvm.dbg.declare(metadata, metadata) #1
 
-  attributes #0 = { optsize zeroext "less-precise-fpmad"="false"
-    "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true"
-    "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false"
+  attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false"
+    "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"
+    "no-infs-fp-math"="false" "no-nans-fp-math"="false"
+    "stack-protector-buffer-size"="8" "unsafe-fp-math"="false"
     "use-soft-float"="false" }
   attributes #1 = { nounwind readnone }
 
   !llvm.dbg.cu = !{!0}
-  
+  !llvm.module.flags = !{!8}
+  !llvm.ident = !{!9}
+
   !0 = metadata !{i32 786449, metadata !1, i32 12,
-                  metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0,
-                  metadata !2, metadata !2, metadata !3, metadata !2,
-                  metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] \
+                  metadata !"clang version 3.4 (trunk 193128) (llvm/trunk 193139)",
+                  i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3,
+                  metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] \
                     [/private/tmp/foo.c] \
-                    [DW_LANG_C]
-  !1 = metadata !{metadata !"foo.c", metadata !"/private/tmp"}
+                    [DW_LANG_C99]
+  !1 = metadata !{metadata !"t.c", metadata !"/private/tmp"}
   !2 = metadata !{i32 0}
   !3 = metadata !{metadata !4}
   !4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"foo",
-                  metadata !"foo", metadata !"_Z3foov", i32 1, metadata !6,
-                  i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false,
-                  void ()* @_Z3foov, null, null, metadata !2, i32 1}
+                  metadata !"foo", metadata !"", i32 1, metadata !6,
+                  i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false,
+                  void ()* @foo, null, null, metadata !2, i32 1}
                   ; [ DW_TAG_subprogram ] [line 1] [def] [foo]
-  !5 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] \
-                    [/private/tmp/foo.c]
-  !6 = metadata !{i32 786453, i32 0, i32 0, metadata !"", i32 0, i64 0, i64 0,
-                  i64 0, i32 0, null, metadata !7, i32 0, i32 0}
+  !5 = metadata !{i32 786473, metadata !1}  ; [ DW_TAG_file_type ] \
+                    [/private/tmp/t.c]
+  !6 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0,
+                  i64 0, i32 0, null, metadata !7, i32 0, null, null, null}
                   ; [ DW_TAG_subroutine_type ] \
                     [line 0, size 0, align 0, offset 0] [from ]
   !7 = metadata !{null}
-  !8 = metadata !{i32 786688, metadata !4, metadata !"X", metadata !5, i32 2, \
-                  metadata !9, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [X] \
-                    [line 2]
-  !9 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, \
-                  i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] \
-                    [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
-  !10 = metadata !{i32 2, i32 7, metadata !4, null}
-  !11 = metadata !{i32 2, i32 13, metadata !4, null}
-  !12 = metadata !{i32 786688, metadata !4, metadata !"Y", metadata !5, i32 3, \
-                   metadata !9, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [Y] \
+  !8 = metadata !{i32 2, metadata !"Dwarf Version", i32 2}
+  !9 = metadata !{metadata !"clang version 3.4 (trunk 193128) (llvm/trunk 193139)"}
+  !10 = metadata !{i32 786688, metadata !4, metadata !"X", metadata !5, i32 2,
+                   metadata !11, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [X] \
+                     [line 2]
+  !11 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32,
+                   i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] \
+                     [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
+  !12 = metadata !{i32 2, i32 0, metadata !4, null}
+  !13 = metadata !{i32 786688, metadata !4, metadata !"Y", metadata !5, i32 3,
+                   metadata !11, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [Y] \
                      [line 3]
-  !13 = metadata !{i32 3, i32 7, metadata !4, null}
-  !14 = metadata !{i32 3, i32 13, metadata !4, null}
-  !15 = metadata !{i32 786688, metadata !16, metadata !"Z", metadata !5, i32 5, \
-                   metadata !9, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [Z] \
+  !14 = metadata !{i32 3, i32 0, metadata !4, null}
+  !15 = metadata !{i32 786688, metadata !16, metadata !"Z", metadata !5, i32 5,
+                   metadata !11, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [Z] \
                      [line 5]
-  !16 = metadata !{i32 786443, metadata !1, metadata !4, i32 4, i32 3, i32 0}
-                   ; [ DW_TAG_lexical_block ] [/private/tmp/foo.c]
-  !17 = metadata !{i32 5, i32 9, metadata !16, null}
-  !18 = metadata !{i32 5, i32 15, metadata !16, null}
-  !19 = metadata !{i32 6, i32 5, metadata !16, null}
-  !20 = metadata !{i32 8, i32 3, metadata !4, null}
-  !21 = metadata !{i32 9, i32 1, metadata !4, null}
+  !16 = metadata !{i32 786443, metadata !1, metadata !4, i32 4, i32 0, i32 0} \
+                   ; [ DW_TAG_lexical_block ] [/private/tmp/t.c]
+  !17 = metadata !{i32 5, i32 0, metadata !16, null}
+  !18 = metadata !{i32 6, i32 0, metadata !16, null}
+  !19 = metadata !{i32 8, i32 0, metadata !4, null} ; [ DW_TAG_imported_declaration ]
+  !20 = metadata !{i32 9, i32 0, metadata !4, null}
 
 This example illustrates a few important details about LLVM debugging
 information.  In particular, it shows how the ``llvm.dbg.declare`` intrinsic and
@@ -738,23 +748,23 @@ variable definitions, and the code used to implement the function.
 
 .. code-block:: llvm
 
-  call void @llvm.dbg.declare(metadata !{i32* %X}, metadata !8), !dbg !10
+  call void @llvm.dbg.declare(metadata !{i32* %X}, metadata !10), !dbg !12
     ; [debug line = 2:7] [debug variable = X]
 
 The first intrinsic ``%llvm.dbg.declare`` encodes debugging information for the
-variable ``X``.  The metadata ``!dbg !10`` attached to the intrinsic provides
+variable ``X``.  The metadata ``!dbg !12`` attached to the intrinsic provides
 scope information for the variable ``X``.
 
 .. code-block:: llvm
 
-  !10 = metadata !{i32 2, i32 7, metadata !4, null}
+  !12 = metadata !{i32 2, i32 0, metadata !4, null}
   !4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"foo",
-                  metadata !"foo", metadata !"_Z3foov", i32 1, metadata !6,
-                  i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false,
-                  void ()* @_Z3foov, null, null, metadata !2, i32 1}
-                  ; [ DW_TAG_subprogram ] [line 1] [def] [foo]
+                  metadata !"foo", metadata !"", i32 1, metadata !6,
+                  i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false,
+                  void ()* @foo, null, null, metadata !2, i32 1}
+                    ; [ DW_TAG_subprogram ] [line 1] [def] [foo]
 
-Here ``!10`` is metadata providing location information.  It has four fields:
+Here ``!12`` is metadata providing location information.  It has four fields:
 line number, column number, scope, and original scope.  The original scope
 represents inline location if this instruction is inlined inside a caller, and
 is null otherwise.  In this example, scope is encoded by ``!4``, a
@@ -775,12 +785,12 @@ scope information for the variable ``Z``.
 
 .. code-block:: llvm
 
-  !16 = metadata !{i32 786443, metadata !1, metadata !4, i32 4, i32 3, i32 0}
-                   ; [ DW_TAG_lexical_block ] [/private/tmp/foo.c]
-  !17 = metadata !{i32 5, i32 9, metadata !16, null}
+  !16 = metadata !{i32 786443, metadata !1, metadata !4, i32 4, i32 0, i32 0} \
+                   ; [ DW_TAG_lexical_block ] [/private/tmp/t.c]
+  !17 = metadata !{i32 5, i32 0, metadata !16, null}
 
 Here ``!15`` indicates that ``Z`` is declared at line number 5 and
-column number 9 inside of lexical scope ``!16``.  The lexical scope itself
+column number 0 inside of lexical scope ``!16``.  The lexical scope itself
 resides inside of subprogram ``!4`` described above.
 
 The scope information attached with each instruction provides a straightforward
@@ -844,6 +854,7 @@ a C/C++ front-end would generate the following descriptors:
     metadata !2,  ;; Global variables
     metadata !2,  ;; Imported entities (declarations and namespaces)
     metadata !""  ;; Split debug filename
+    1,            ;; Full debug info
   }
 
   ;;
@@ -926,6 +937,7 @@ a C/C++ front-end would generate the following descriptors:
     metadata !3,                      ;; Global Variables
     metadata !1,                      ;; Imported entities
     "",                               ;; Split debug filename
+    1,                                ;; Full debug info
   } ; [ DW_TAG_compile_unit ]
 
   ;; The Array of Global Variables
@@ -2305,7 +2317,7 @@ stringWithCString:]``") and the basename is the selector only
 Mach-O Changes
 """"""""""""""
 
-The sections names for the apple hash tables are for non mach-o files.  For
+The sections names for the apple hash tables are for non-mach-o files.  For
 mach-o files, the sections should be contained in the ``__DWARF`` segment with
 names as follows: