1 # RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o %t.o
2 # RUN: llvm-dwarfdump -v %t.o | FileCheck --check-prefix=COMMON %s
4 # Test object to verify dwarfdump handles v5 string offset tables in Mach-O.
5 # This is similar to dwarfdump-str-offsets.s with 2 CUs and 1 TU, but no
8 .section __DWARF,__debug_str,regular,debug
10 .asciz "Handmade DWARF producer"
12 .asciz "Compile_Unit_1"
14 .asciz "/home/test/CU1"
16 .asciz "Compile_Unit_2"
18 .asciz "/home/test/CU2"
32 .section __DWARF,__debug_str_offs,regular,debug
34 .long Ldebug_str_offsets_segment0_end-Ldebug_str_offsets_base0+4
35 .short 5 # DWARF version
37 Ldebug_str_offsets_base0
:
45 Ldebug_str_offsets_segment0_end
:
48 # CU2's contribution (DWARF64 format)
50 .quad Ldebug_str_offsets_segment1_end-Ldebug_str_offsets_base1+4
51 .short 5 # DWARF version
53 Ldebug_str_offsets_base1
:
57 Ldebug_str_offsets_segment1_end
:
58 # The TU's contribution
59 .long Ldebug_str_offsets_segment2_end-Ldebug_str_offsets_base2+4
60 .short 5 # DWARF version
62 Ldebug_str_offsets_base2
:
65 Ldebug_str_offsets_segment2_end
:
67 .section __DWARF,__debug_abbrev,regular,debug
69 .byte 0x01 # Abbrev code
70 .byte 0x11 # DW_TAG_compile_unit
71 .byte 0x01 # DW_CHILDREN_yes
72 .byte 0x25 # DW_AT_producer
73 .byte 0x1a # DW_FORM_strx
74 .byte 0x03 # DW_AT_name
75 .byte 0x1a # DW_FORM_strx
76 .byte 0x72 # DW_AT_str_offsets_base
77 .byte 0x17 # DW_FORM_sec_offset
78 .byte 0x1b # DW_AT_comp_dir
79 .byte 0x1a # DW_FORM_strx
82 .byte 0x02 # Abbrev code
83 .byte 0x41 # DW_TAG_type_unit
84 .byte 0x01 # DW_CHILDREN_yes
85 .byte 0x03 # DW_AT_name
86 .byte 0x1a # DW_FORM_strx
87 .byte 0x72 # DW_AT_str_offsets_base
88 .byte 0x17 # DW_FORM_sec_offset
91 .byte 0x03 # Abbrev code
92 .byte 0x13 # DW_TAG_structure_type
93 .byte 0x00 # DW_CHILDREN_no (no members)
94 .byte 0x03 # DW_AT_name
95 .byte 0x1a # DW_FORM_strx
98 .byte 0x04 # Abbrev code
99 .byte 0x2e # DW_TAG_subprogram
100 .byte 0x01 # DW_CHILDREN_yes
101 .byte 0x03 # DW_AT_name
102 .byte 0x25 # DW_FORM_strx1
105 .byte 0x05 # Abbrev code
106 .byte 0x34 # DW_TAG_variable
107 .byte 0x00 # DW_CHILDREN_no
108 .byte 0x03 # DW_AT_name
109 .byte 0x26 # DW_FORM_strx2
112 .byte 0x06 # Abbrev code
113 .byte 0x34 # DW_TAG_variable
114 .byte 0x00 # DW_CHILDREN_no
115 .byte 0x03 # DW_AT_name
116 .byte 0x27 # DW_FORM_strx3
119 .byte 0x07 # Abbrev code
120 .byte 0x34 # DW_TAG_variable
121 .byte 0x00 # DW_CHILDREN_no
122 .byte 0x03 # DW_AT_name
123 .byte 0x28 # DW_FORM_strx4
128 .section __DWARF,__debug_info,regular,debug
130 # DWARF v5 CU header.
131 .long CU1_5_end-CU1_5_version # Length of Unit
133 .short 5 # DWARF version number
134 .byte 1 # DWARF Unit Type
135 .byte 8 # Address Size (in bytes)
136 .long 0 # Offset Into Abbrev. Section
137 # The compile-unit DIE, which has a DW_AT_producer, DW_AT_name,
138 # DW_AT_str_offsets and DW_AT_compdir.
139 .byte 1 # Abbreviation code
140 .byte 0 # The index of the producer string
141 .byte 1 # The index of the CU name string
142 .long Ldebug_str_offsets_base0-Ldebug_str_offsets
143 .byte 2 # The index of the comp dir string
144 # A subprogram DIE with DW_AT_name, using DW_FORM_strx1.
145 .byte 4 # Abbreviation code
146 .byte 3 # Subprogram name string (DW_FORM_strx1)
147 # A variable DIE with DW_AT_name, using DW_FORM_strx2.
148 .byte 5 # Abbreviation code
149 .short 0x0004 # Subprogram name string (DW_FORM_strx2)
150 # A variable DIE with DW_AT_name, using DW_FORM_strx3.
151 .byte 6 # Abbreviation code
152 .byte 5 # Subprogram name string (DW_FORM_strx3)
153 .short 0 # Subprogram name string (DW_FORM_strx3)
154 # A variable DIE with DW_AT_name, using DW_FORM_strx4.
155 .byte 7 # Abbreviation code
156 .quad 0x00000006 # Subprogram name string (DW_FORM_strx4)
164 .quad CU2_5_end-CU2_5_version # Length of Unit
166 .short 5 # DWARF version number
167 .byte 1 # DWARF Unit Type
168 .byte 8 # Address Size (in bytes)
169 .quad 0 # Offset Into Abbrev. Section
170 # The compile-unit DIE, which has a DW_AT_producer, DW_AT_name,
171 # DW_AT_str_offsets and DW_AT_compdir.
172 .byte 1 # Abbreviation code
173 .byte 0 # The index of the producer string
174 .byte 1 # The index of the CU name string
175 .quad Ldebug_str_offsets_base1-Ldebug_str_offsets
176 .byte 2 # The index of the comp dir string
180 .section __DWARF,__debug_types,regular,debug
181 # DWARF v5 Type unit header.
183 .long TU_5_end-TU_5_version # Length of Unit
185 .short 5 # DWARF version number
186 .byte 2 # DWARF Unit Type
187 .byte 8 # Address Size (in bytes)
188 .long 0 # Offset Into Abbrev. Section
189 .quad 0x0011223344556677 # Type Signature
190 .long TU_5_type-TU_5_start # Type offset
191 # The type-unit DIE, which has a name.
192 .byte 2 # Abbreviation code
193 .byte 0 # Index of the unit type name string
194 .long Ldebug_str_offsets_base2-Ldebug_str_offsets # offset into the str_offsets section
195 # The type DIE, which has a name.
197 .byte 3 # Abbreviation code
198 .byte 1 # Index of the type name string
204 .subsections_via_symbols
206 # We are using a hand-constructed object file and are interest in the correct
207 # diplay of the DW_str_offsetsbase attribute and the correct display of strings.
209 # Abbreviation for DW_AT_str_offsets_base
210 # COMMON: .debug_abbrev contents:
211 # COMMON-NOT: contents:
212 # COMMON: DW_TAG_compile_unit
214 # COMMON: DW_AT_str_offsets_base DW_FORM_sec_offset
216 # Verify that strings are displayed correctly as indexed strings
217 # COMMON: .debug_info contents:
218 # COMMON-NOT: contents:
219 # COMMON: DW_TAG_compile_unit
220 # COMMON-NEXT: DW_AT_producer [DW_FORM_strx] (indexed (00000000) string = "Handmade DWARF producer")
221 # COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "Compile_Unit_1")
222 # COMMON-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000008)
223 # COMMON-NEXT: DW_AT_comp_dir [DW_FORM_strx] (indexed (00000002) string = "/home/test/CU1")
225 # COMMON: DW_TAG_subprogram
226 # COMMON-NEXT: DW_AT_name [DW_FORM_strx1] (indexed (00000003) string = "MyFunc")
228 # COMMON: DW_TAG_variable
229 # COMMON-NEXT: DW_AT_name [DW_FORM_strx2] (indexed (00000004) string = "MyVar1")
231 # COMMON: DW_TAG_variable
232 # COMMON-NEXT: DW_AT_name [DW_FORM_strx3] (indexed (00000005) string = "MyVar2")
234 # COMMON: DW_TAG_variable
235 # COMMON-NEXT: DW_AT_name [DW_FORM_strx4] (indexed (00000006) string = "MyVar3")
237 # Second compile unit (b.cpp)
238 # COMMON: DW_TAG_compile_unit
239 # COMMON-NEXT: DW_AT_producer [DW_FORM_strx] (indexed (00000000) string = "Handmade DWARF producer")
240 # COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "Compile_Unit_2")
241 # COMMON-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000038)
242 # COMMON-NEXT: DW_AT_comp_dir [DW_FORM_strx] (indexed (00000002) string = "/home/test/CU2")
245 # COMMON: .debug_types contents:
246 # COMMON: DW_TAG_type_unit
247 # COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000000) string = "Type_Unit")
248 # COMMON-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000058)
249 # COMMON: DW_TAG_structure_type
250 # COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "MyStruct")
252 # The .debug_str_offsets section
253 # COMMON: .debug_str_offsets contents:
254 # COMMON-NEXT: 0x00000000: Contribution size = 32, Format = DWARF32, Version = 5
255 # COMMON-NEXT: 0x00000008: 00000000 "Handmade DWARF producer"
256 # COMMON-NEXT: 0x0000000c: 00000018 "Compile_Unit_1"
257 # COMMON-NEXT: 0x00000010: 00000027 "/home/test/CU1"
258 # COMMON-NEXT: 0x00000014: 00000067 "MyFunc"
259 # COMMON-NEXT: 0x00000018: 0000006e "MyVar1"
260 # COMMON-NEXT: 0x0000001c: 00000075 "MyVar2"
261 # COMMON-NEXT: 0x00000020: 0000007c "MyVar3"
262 # COMMON-NEXT: 0x00000024: Gap, length = 4
263 # COMMON-NEXT: 0x00000028: Contribution size = 28, Format = DWARF64, Version = 5
264 # COMMON-NEXT: 0x00000038: 00000000 "Handmade DWARF producer"
265 # COMMON-NEXT: 0x00000040: 00000036 "Compile_Unit_2"
266 # COMMON-NEXT: 0x00000048: 00000045 "/home/test/CU2"
267 # COMMON-NEXT: 0x00000050: Contribution size = 12, Format = DWARF32, Version = 5
268 # COMMON-NEXT: 0x00000058: 00000054 "Type_Unit"
269 # COMMON-NEXT: 0x0000005c: 0000005e "MyStruct"