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