X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FSourceLevelDebugging.rst;h=869d3a383107e76e0f423d1b4e910b84307e6c3d;hb=3b52084af899f5eaf7c24845ccaf3d4b6f87e8db;hp=ad038717cb9b8c5554159b91ebf7918fb06f0e38;hpb=61212bcaff0629b03feeebd649078a91e6f13a53;p=oota-llvm.git diff --git a/docs/SourceLevelDebugging.rst b/docs/SourceLevelDebugging.rst index ad038717cb9..869d3a38310 100644 --- a/docs/SourceLevelDebugging.rst +++ b/docs/SourceLevelDebugging.rst @@ -235,8 +235,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 +269,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 +295,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 +314,13 @@ 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, ;; DWARF path discriminator value + i32 ;; Unique ID to identify blocks from a template function } This descriptor provides debug information about nested blocks within a @@ -329,9 +330,9 @@ 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 } This descriptor provides a wrapper around a lexical scope to handle file @@ -346,7 +347,7 @@ Basic type descriptors !4 = metadata !{ i32, ;; Tag = 36 (DW_TAG_base_type) - metadata,;; Source directory (including trailing slash) & file pair (may be null) + metadata, ;; Source directory (including trailing slash) & file pair (may be null) metadata, ;; Reference to context metadata, ;; Name (may be "" for anonymous types) i32, ;; Line number where defined (may be 0) @@ -389,7 +390,7 @@ Derived type descriptors !5 = metadata !{ i32, ;; Tag (see below) - metadata,;; Source directory (including trailing slash) & file pair (may be null) + metadata, ;; Source directory (including trailing slash) & file pair (may be null) metadata, ;; Reference to context metadata, ;; Name (may be "" for anonymous types) i32, ;; Line number where defined (may be 0) @@ -452,7 +453,7 @@ Composite type descriptors !6 = metadata !{ i32, ;; Tag (see below) - metadata,;; Source directory (including trailing slash) & file pair (may be null) + metadata, ;; Source directory (including trailing slash) & file pair (may be null) metadata, ;; Reference to context metadata, ;; Name (may be "" for anonymous types) i32, ;; Line number where defined (may be 0) @@ -462,9 +463,10 @@ Composite type descriptors i32, ;; Flags metadata, ;; Reference to type derived from metadata, ;; Reference to array of member descriptors - i32 ;; Runtime languages + i32, ;; Runtime languages metadata, ;; Base type containing the vtable pointer for this type - metadata ;; Template parameters + metadata, ;; Template parameters + metadata ;; A unique identifier for type uniquing purpose (may be null) } These descriptors are used to define types that are composed of 0 or more @@ -526,9 +528,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 @@ -565,9 +567,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 @@ -649,85 +652,87 @@ 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, + 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 @@ -737,23 +742,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 @@ -774,12 +779,13 @@ 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, + 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 @@ -2304,7 +2310,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: