1d2d8e687SWolfgang Pieb; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj < %s | llvm-dwarfdump -v - \ 2d2d8e687SWolfgang Pieb; RUN: | FileCheck --check-prefix=MONOLITHIC %s 32f088116SPavel Labath; RUN: llc -mtriple=x86_64-unknown-linux-gnu -split-dwarf-file=foo.dwo -filetype=obj < %s \ 4d2d8e687SWolfgang Pieb; RUN: | llvm-dwarfdump -v - | FileCheck --check-prefix=SPLIT %s 5d2d8e687SWolfgang Pieb 6d2d8e687SWolfgang Pieb; This basic test checks the emission of a DWARF v5 string offsets table in 7d2d8e687SWolfgang Pieb; the split and non-split (monolithic) scenario. 8d2d8e687SWolfgang Pieb; 9d2d8e687SWolfgang Pieb; Constructed from the following source with 10d2d8e687SWolfgang Pieb; clang -S -emit-llvm -gdwarf-5 11d2d8e687SWolfgang Pieb; 12d2d8e687SWolfgang Pieb; enum E {a, b, c}; 13d2d8e687SWolfgang Pieb; E glob; 14d2d8e687SWolfgang Pieb; 15d2d8e687SWolfgang Pieb; In the non-split scenario, check the DW_AT_str_offsets_base attribute 16d2d8e687SWolfgang Pieb; in .debug_abbrev. 17d2d8e687SWolfgang Pieb; MONOLITHIC: .debug_abbrev contents: 18d2d8e687SWolfgang Pieb; MONOLITHIC-NOT: contents: 19d2d8e687SWolfgang Pieb; MONOLITHIC: DW_TAG_compile_unit 20d2d8e687SWolfgang Pieb; MONOLITHIC-NOT: DW_TAG 21d2d8e687SWolfgang Pieb; MONOLITHIC: DW_AT_str_offsets_base DW_FORM_sec_offset 22d2d8e687SWolfgang Pieb 23d2d8e687SWolfgang Pieb; Check that indexed strings come out correctly and that the DW_str_offsets_base attribute 24d2d8e687SWolfgang Pieb; is there and has the right value. 25d2d8e687SWolfgang Pieb; MONOLITHIC: .debug_info contents: 26d2d8e687SWolfgang Pieb; MONOLITHIC-NOT: contents: 27d2d8e687SWolfgang Pieb; MONOLITHIC: DW_TAG_compile_unit 28d2d8e687SWolfgang Pieb; MONOLITHIC-NOT: {{DW_TAG|NULL}} 29d2d8e687SWolfgang Pieb; MONOLITHIC: DW_AT_producer [DW_FORM_strx1] (indexed (00000000) string = "clang{{.*}}") 30d2d8e687SWolfgang Pieb; MONOLITHIC-NOT: {{DW_TAG|NULL}} 31d2d8e687SWolfgang Pieb; MONOLITHIC: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000008) 32d2d8e687SWolfgang Pieb; MONOLITHIC-NOT: {{DW_TAG|NULL}} 33d2d8e687SWolfgang Pieb; MONOLITHIC: DW_AT_comp_dir [DW_FORM_strx1] (indexed (00000002) string = "/home/{{.*}}") 34d2d8e687SWolfgang Pieb 35d2d8e687SWolfgang Pieb; Extract the string offsets from the .debug_str section so we can check that 36d2d8e687SWolfgang Pieb; they are referenced correctly in the .debug_str_offsets section. 37d2d8e687SWolfgang Pieb; MONOLITHIC: .debug_str contents: 38d2d8e687SWolfgang Pieb; MONOLITHIC-NEXT: 0x00000000: 39d2d8e687SWolfgang Pieb; MONOLITHIC-NEXT: 0x[[STRING2:[0-9a-f]]] 40d2d8e687SWolfgang Pieb; MONOLITHIC-NEXT: 0x[[STRING3:[0-9a-f]]] 41d2d8e687SWolfgang Pieb; MONOLITHIC-NEXT: 0x[[STRING4:[0-9a-f]]] 42d2d8e687SWolfgang Pieb 43d2d8e687SWolfgang Pieb; Verify that the .debug_str_offsets section is there and that it starts 44d2d8e687SWolfgang Pieb; with an 8-byte header, followed by offsets into the .debug_str section. 45d2d8e687SWolfgang Pieb; MONOLITHIC: .debug_str_offsets contents: 46f2b6915eSWolfgang Pieb; MONOLITHIC-NEXT: Contribution size = 36, Format = DWARF32, Version = 5 47d2d8e687SWolfgang Pieb; MONOLITHIC-NEXT: 0x00000008: 00000000 48d2d8e687SWolfgang Pieb; MONOLITHIC-NEXT: 0x0000000c: [[STRING2]] 49d2d8e687SWolfgang Pieb; MONOLITHIC-NEXT: 0x00000010: [[STRING3]] 50d2d8e687SWolfgang Pieb; MONOLITHIC-NEXT: 0x00000014: [[STRING4]] 51d2d8e687SWolfgang Pieb 52d2d8e687SWolfgang Pieb; For split dwarf, verify that the skeleton unit has the DW_AT_str_offsets_base 53d2d8e687SWolfgang Pieb; attribute and that it has the right value. 54d2d8e687SWolfgang Pieb; 55d2d8e687SWolfgang Pieb; SPLIT: .debug_info contents: 56d2d8e687SWolfgang Pieb; SPLIT-NEXT: 0x00000000: Compile Unit:{{.*}}DW_UT_skeleton 57d2d8e687SWolfgang Pieb; SPLIT-NOT: contents: 58789e257cSAlexey Lapshin; SPLIT: DW_TAG_skeleton_unit 59d2d8e687SWolfgang Pieb; SPLIT-NOT: {{DW_TAG|contents:}} 60d2d8e687SWolfgang Pieb; SPLIT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000008) 61560ff355SDavid Blaikie; SPLIT: DW_AT_comp_dir [DW_FORM_strx1] (indexed (00000000) string = "/home/test") 62*fb4d8fe1SSourabh Singh Tomar; SPLIT: DW_AT_dwo_name [DW_FORM_strx1] (indexed (00000001) string = "foo.dwo") 63d2d8e687SWolfgang Pieb 64d2d8e687SWolfgang Pieb; Check for the split CU in .debug_info.dwo. 65d2d8e687SWolfgang Pieb; SPLIT: .debug_info.dwo contents: 66d2d8e687SWolfgang Pieb; SPLIT-NEXT: 0x00000000: Compile Unit:{{.*}}DW_UT_split_compile 67d2d8e687SWolfgang Pieb; SPLIT-NOT: contents: 68d2d8e687SWolfgang Pieb; SPLIT: DW_TAG_compile_unit 69d2d8e687SWolfgang Pieb; 70d2d8e687SWolfgang Pieb; Check that a couple of indexed strings are displayed correctly and that 71d2d8e687SWolfgang Pieb; they have the right format (DW_FORM_strx1). 72d2d8e687SWolfgang Pieb; SPLIT-NOT: contents: 73d2d8e687SWolfgang Pieb; SPLIT: DW_TAG_enumerator 74d2d8e687SWolfgang Pieb; SPLIT-NOT: {{DW_TAG|NULL}} 75560ff355SDavid Blaikie; SPLIT: DW_AT_name [DW_FORM_strx1] (indexed (00000001) string = "a") 76d2d8e687SWolfgang Pieb; SPLIT-NOT: contents: 77d2d8e687SWolfgang Pieb; SPLIT: DW_TAG_enumerator 78d2d8e687SWolfgang Pieb; SPLIT-NOT: {{DW_TAG|NULL}} 79560ff355SDavid Blaikie; SPLIT: DW_AT_name [DW_FORM_strx1] (indexed (00000002) string = "b") 80d2d8e687SWolfgang Pieb; 81d2d8e687SWolfgang Pieb; Extract the string offsets referenced in the main file by the skeleton unit. 82d2d8e687SWolfgang Pieb; SPLIT: .debug_str contents: 83560ff355SDavid Blaikie; SPLIT-NEXT: 0x[[STRHOMETESTSPLIT:[0-9a-f]*]]: "/home/test" 84560ff355SDavid Blaikie; SPLIT-NEXT: 0x[[STRESPLIT:[0-9a-f]*]]: "E" 85560ff355SDavid Blaikie; SPLIT-NEXT: 0x[[STRGLOBSPLIT:[0-9a-f]*]]: "glob" 86560ff355SDavid Blaikie; SPLIT-NEXT: 0x[[STRFOODWOSPLIT:[0-9a-f]*]]: "foo.dwo" 87d2d8e687SWolfgang Pieb; 88d2d8e687SWolfgang Pieb; Extract the string offsets referenced in the .dwo file by the split unit. 89d2d8e687SWolfgang Pieb; SPLIT: .debug_str.dwo contents: 90d2d8e687SWolfgang Pieb; SPLIT-NEXT: 0x00000000:{{.*}} 91d2d8e687SWolfgang Pieb; SPLIT-NEXT: 0x[[STRING2DWO:[0-9a-f]*]]{{.*}} 92d2d8e687SWolfgang Pieb; SPLIT-NEXT: 0x[[STRING3DWO:[0-9a-f]*]]{{.*}} 93d2d8e687SWolfgang Pieb; 94d2d8e687SWolfgang Pieb; Check the string offsets sections in both the main and the .dwo files and 952f088116SPavel Labath; verify that the extracted string offsets are referenced correctly. The 962f088116SPavel Labath; sections should contain only the offsets of strings that are actually 972f088116SPavel Labath; referenced by the debug info. 98d2d8e687SWolfgang Pieb; SPLIT: .debug_str_offsets contents: 992f088116SPavel Labath; SPLIT-NEXT: 0x00000000: Contribution size = 12, Format = DWARF32, Version = 5 100560ff355SDavid Blaikie; SPLIT-NEXT: 0x00000008: [[STRHOMETESTSPLIT]] "/home/test" 101560ff355SDavid Blaikie; SPLIT-NEXT: 0x0000000c: [[STRFOODWOSPLIT]] "foo.dwo" 1022f088116SPavel Labath; SPLIT-EMPTY: 1032f088116SPavel Labath 104d2d8e687SWolfgang Pieb; SPLIT: .debug_str_offsets.dwo contents: 105f2b6915eSWolfgang Pieb; SPLIT-NEXT: 0x00000000: Contribution size = 36, Format = DWARF32, Version = 5 106d2d8e687SWolfgang Pieb; SPLIT-NEXT: 0x00000008: 00000000{{.*}} 107d2d8e687SWolfgang Pieb; SPLIT-NEXT: 0x0000000c: [[STRING2DWO]]{{.*}} 108d2d8e687SWolfgang Pieb; SPLIT-NEXT: 0x00000010: [[STRING3DWO]] 109d2d8e687SWolfgang Pieb 110d2d8e687SWolfgang Pieb@glob = global i32 0, align 4, !dbg !0 111d2d8e687SWolfgang Pieb 112d2d8e687SWolfgang Pieb!llvm.dbg.cu = !{!2} 113d2d8e687SWolfgang Pieb!llvm.module.flags = !{!11, !12, !13} 114d2d8e687SWolfgang Pieb!llvm.ident = !{!14} 115d2d8e687SWolfgang Pieb 116d2d8e687SWolfgang Pieb!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 117d2d8e687SWolfgang Pieb!1 = distinct !DIGlobalVariable(name: "glob", scope: !2, file: !3, line: 3, type: !5, isLocal: false, isDefinition: true) 118d2d8e687SWolfgang Pieb!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 7.0.0 (trunk 322415)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !10) 119d2d8e687SWolfgang Pieb!3 = !DIFile(filename: "en.cpp", directory: "/home/test", checksumkind: CSK_MD5, checksum: "d96b2e2d618e550f0ddd0b6a49c98b02") 120d2d8e687SWolfgang Pieb!4 = !{!5} 121d2d8e687SWolfgang Pieb!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E", file: !3, line: 1, size: 32, elements: !6, identifier: "_ZTS1E") 122d2d8e687SWolfgang Pieb!6 = !{!7, !8, !9} 123d2d8e687SWolfgang Pieb!7 = !DIEnumerator(name: "a", value: 0) 124d2d8e687SWolfgang Pieb!8 = !DIEnumerator(name: "b", value: 1) 125d2d8e687SWolfgang Pieb!9 = !DIEnumerator(name: "c", value: 2) 126d2d8e687SWolfgang Pieb!10 = !{!0} 127d2d8e687SWolfgang Pieb!11 = !{i32 2, !"Dwarf Version", i32 5} 128d2d8e687SWolfgang Pieb!12 = !{i32 2, !"Debug Info Version", i32 3} 129d2d8e687SWolfgang Pieb!13 = !{i32 1, !"wchar_size", i32 4} 130d2d8e687SWolfgang Pieb!14 = !{!"clang version 7.0.0 (trunk 322415)"} 131