• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o
2# RUN: llvm-dwarfdump -v %t.o 2> %t.err | FileCheck --check-prefix=COMMON --check-prefix=SPLIT %s
3#
4# Check that we don't report an error on a non-existent range list table.
5# RUN: FileCheck -allow-empty --check-prefix ERR %s < %t.err
6
7# Test object to verify dwarfdump handles v5 string offset tables.
8# We have 2 v5 CUs, a v5 TU, and a split v5 CU and TU.
9#
10
11        .section .debug_str,"MS",@progbits,1
12str_producer:
13        .asciz "Handmade DWARF producer"
14str_CU1:
15        .asciz "Compile_Unit_1"
16str_CU1_dir:
17        .asciz "/home/test/CU1"
18str_CU2:
19        .asciz "Compile_Unit_2"
20str_CU2_dir:
21        .asciz "/home/test/CU2"
22str_TU:
23        .asciz "Type_Unit"
24str_TU_type:
25        .asciz "MyStruct"
26str_Subprogram:
27        .asciz "MyFunc"
28str_Variable1:
29        .asciz "MyVar1"
30str_Variable2:
31        .asciz "MyVar2"
32str_Variable3:
33        .asciz "MyVar3"
34
35# Every unit contributes to the string_offsets table.
36        .section .debug_str_offsets,"",@progbits
37# CU1's contribution
38        .long .debug_str_offsets_segment0_end-.debug_str_offsets_base0+4
39        .short 5    # DWARF version
40        .short 0    # Padding
41.debug_str_offsets_base0:
42        .long str_producer
43        .long str_CU1
44        .long str_CU1_dir
45        .long str_Subprogram
46        .long str_Variable1
47        .long str_Variable2
48        .long str_Variable3
49.debug_str_offsets_segment0_end:
50# A 4-byte gap.
51        .long 0
52# CU2's contribution in DWARF64 format
53        .long 0xffffffff
54        .quad .debug_str_offsets_segment1_end-.debug_str_offsets_base1+4
55        .short 5    # DWARF version
56        .short 0    # Padding
57.debug_str_offsets_base1:
58        .quad str_producer
59        .quad str_CU2
60        .quad str_CU2_dir
61.debug_str_offsets_segment1_end:
62# The TU's contribution
63        .long .debug_str_offsets_segment2_end-.debug_str_offsets_base2+4
64        .short 5    # DWARF version
65        .short 0    # Padding
66.debug_str_offsets_base2:
67        .long str_TU
68        .long str_TU_type
69.debug_str_offsets_segment2_end:
70
71        .section .debug_str.dwo,"MS",@progbits,1
72dwo_str_CU_5_producer:
73        .asciz "Handmade split DWARF producer"
74dwo_str_CU_5_name:
75        .asciz "V5_split_compile_unit"
76dwo_str_CU_5_comp_dir:
77        .asciz "/home/test/splitCU"
78dwo_str_TU_5:
79        .asciz "V5_split_type_unit"
80dwo_str_TU_5_type:
81        .asciz "V5_split_Mystruct"
82
83        .section .debug_str_offsets.dwo,"",@progbits
84# One contribution only in a .dwo file
85        .long .debug_dwo_str_offsets_segment0_end-.debug_dwo_str_offsets_base0+4
86        .short 5    # DWARF version
87        .short 0    # Padding
88.debug_dwo_str_offsets_base0:
89        .long dwo_str_CU_5_producer-.debug_str.dwo
90        .long dwo_str_CU_5_name-.debug_str.dwo
91        .long dwo_str_CU_5_comp_dir-.debug_str.dwo
92        .long dwo_str_TU_5-.debug_str.dwo
93        .long dwo_str_TU_5_type-.debug_str.dwo
94.debug_dwo_str_offsets_segment0_end:
95
96# All CUs/TUs use the same abbrev section for simplicity.
97        .section .debug_abbrev,"",@progbits
98        .byte 0x01  # Abbrev code
99        .byte 0x11  # DW_TAG_compile_unit
100        .byte 0x01  # DW_CHILDREN_yes
101        .byte 0x25  # DW_AT_producer
102        .byte 0x1a  # DW_FORM_strx
103        .byte 0x03  # DW_AT_name
104        .byte 0x1a  # DW_FORM_strx
105        .byte 0x72  # DW_AT_str_offsets_base
106        .byte 0x17  # DW_FORM_sec_offset
107        .byte 0x1b  # DW_AT_comp_dir
108        .byte 0x1a  # DW_FORM_strx
109        .byte 0x00  # EOM(1)
110        .byte 0x00  # EOM(2)
111        .byte 0x02  # Abbrev code
112        .byte 0x41  # DW_TAG_type_unit
113        .byte 0x01  # DW_CHILDREN_yes
114        .byte 0x03  # DW_AT_name
115        .byte 0x1a  # DW_FORM_strx
116        .byte 0x72  # DW_AT_str_offsets_base
117        .byte 0x17  # DW_FORM_sec_offset
118        .byte 0x00  # EOM(1)
119        .byte 0x00  # EOM(2)
120        .byte 0x03  # Abbrev code
121        .byte 0x13  # DW_TAG_structure_type
122        .byte 0x00  # DW_CHILDREN_no (no members)
123        .byte 0x03  # DW_AT_name
124        .byte 0x1a  # DW_FORM_strx
125        .byte 0x00  # EOM(1)
126        .byte 0x00  # EOM(2)
127        .byte 0x04  # Abbrev code
128        .byte 0x2e  # DW_TAG_subprogram
129        .byte 0x01  # DW_CHILDREN_yes
130        .byte 0x03  # DW_AT_name
131        .byte 0x25  # DW_FORM_strx1
132        .byte 0x00  # EOM(1)
133        .byte 0x00  # EOM(2)
134        .byte 0x05  # Abbrev code
135        .byte 0x34  # DW_TAG_variable
136        .byte 0x00  # DW_CHILDREN_no
137        .byte 0x03  # DW_AT_name
138        .byte 0x26  # DW_FORM_strx2
139        .byte 0x00  # EOM(1)
140        .byte 0x00  # EOM(2)
141        .byte 0x06  # Abbrev code
142        .byte 0x34  # DW_TAG_variable
143        .byte 0x00  # DW_CHILDREN_no
144        .byte 0x03  # DW_AT_name
145        .byte 0x27  # DW_FORM_strx3
146        .byte 0x00  # EOM(1)
147        .byte 0x00  # EOM(2)
148        .byte 0x07  # Abbrev code
149        .byte 0x34  # DW_TAG_variable
150        .byte 0x00  # DW_CHILDREN_no
151        .byte 0x03  # DW_AT_name
152        .byte 0x28  # DW_FORM_strx4
153        .byte 0x00  # EOM(1)
154        .byte 0x00  # EOM(2)
155        .byte 0x00  # EOM(3)
156
157# And a .dwo copy of a subset for the .dwo sections.
158        .section .debug_abbrev.dwo,"",@progbits
159        .byte 0x01  # Abbrev code
160        .byte 0x11  # DW_TAG_compile_unit
161        .byte 0x00  # DW_CHILDREN_no
162        .byte 0x25  # DW_AT_producer
163        .byte 0x1a  # DW_FORM_strx
164        .byte 0x03  # DW_AT_name
165        .byte 0x1a  # DW_FORM_strx
166        .byte 0x1b  # DW_AT_comp_dir
167        .byte 0x1a  # DW_FORM_strx
168        .byte 0x00  # EOM(1)
169        .byte 0x00  # EOM(2)
170        .byte 0x02  # Abbrev code
171        .byte 0x41  # DW_TAG_type_unit
172        .byte 0x01  # DW_CHILDREN_yes
173        .byte 0x03  # DW_AT_name
174        .byte 0x1a  # DW_FORM_strx
175        .byte 0x00  # EOM(1)
176        .byte 0x00  # EOM(2)
177        .byte 0x03  # Abbrev code
178        .byte 0x13  # DW_TAG_structure_type
179        .byte 0x00  # DW_CHILDREN_no (no members)
180        .byte 0x03  # DW_AT_name
181        .byte 0x1a  # DW_FORM_strx
182        .byte 0x00  # EOM(1)
183        .byte 0x00  # EOM(2)
184        .byte 0x00  # EOM(3)
185
186        .section .debug_info,"",@progbits
187
188# DWARF v5 CU header.
189        .long  CU1_5_end-CU1_5_version  # Length of Unit
190CU1_5_version:
191        .short 5               # DWARF version number
192        .byte 1                # DWARF Unit Type
193        .byte 8                # Address Size (in bytes)
194        .long .debug_abbrev    # Offset Into Abbrev. Section
195# The compile-unit DIE, which has a DW_AT_producer, DW_AT_name,
196# DW_AT_str_offsets and DW_AT_compdir.
197        .byte 1                # Abbreviation code
198        .byte 0                # The index of the producer string
199        .byte 1                # The index of the CU name string
200        .long .debug_str_offsets_base0
201        .byte 2                # The index of the comp dir string
202# A subprogram DIE with DW_AT_name, using DW_FORM_strx1.
203        .byte 4                # Abbreviation code
204        .byte 3                # Subprogram name string (DW_FORM_strx1)
205# A variable DIE with DW_AT_name, using DW_FORM_strx2.
206        .byte 5                # Abbreviation code
207        .short 0x0004          # Subprogram name string (DW_FORM_strx2)
208# A variable DIE with DW_AT_name, using DW_FORM_strx3.
209        .byte 6                # Abbreviation code
210        .byte 5                # Subprogram name string (DW_FORM_strx3)
211        .short 0               # Subprogram name string (DW_FORM_strx3)
212# A variable DIE with DW_AT_name, using DW_FORM_strx4.
213        .byte 7                # Abbreviation code
214        .quad 0x00000006       # Subprogram name string (DW_FORM_strx4)
215        .byte 0 # NULL
216        .byte 0 # NULL
217        .byte 0 # NULL
218CU1_5_end:
219
220# DWARF v5 CU header
221        .long  CU2_5_end-CU2_5_version  # Length of Unit
222CU2_5_version:
223        .short 5               # DWARF version number
224        .byte 1                # DWARF Unit Type
225        .byte 8                # Address Size (in bytes)
226        .long .debug_abbrev    # Offset Into Abbrev. Section
227# The compile-unit DIE, which has a DW_AT_producer, DW_AT_name,
228# DW_AT_str_offsets and DW_AT_compdir.
229        .byte 1                # Abbreviation code
230        .byte 0                # The index of the producer string
231        .byte 1                # The index of the CU name string
232        .long .debug_str_offsets_base1
233        .byte 2                # The index of the comp dir string
234        .byte 0 # NULL
235CU2_5_end:
236
237        .section .debug_types,"",@progbits
238# DWARF v5 Type unit header.
239TU_5_start:
240        .long  TU_5_end-TU_5_version  # Length of Unit
241TU_5_version:
242        .short 5               # DWARF version number
243        .byte 2                # DWARF Unit Type
244        .byte 8                # Address Size (in bytes)
245        .long .debug_abbrev    # Offset Into Abbrev. Section
246        .quad 0x0011223344556677 # Type Signature
247        .long TU_5_type-TU_5_start # Type offset
248# The type-unit DIE, which has a name.
249        .byte 2                # Abbreviation code
250        .byte 0                # Index of the unit type name string
251        .long .debug_str_offsets_base2  # offset into the str_offsets section
252# The type DIE, which has a name.
253TU_5_type:
254        .byte 3                # Abbreviation code
255        .byte 1                # Index of the type name string
256        .byte 0 # NULL
257        .byte 0 # NULL
258TU_5_end:
259
260        .section .debug_info.dwo,"",@progbits
261
262# DWARF v5 split CU header.
263        .long  CU_split_5_end-CU_split_5_version  # Length of Unit
264CU_split_5_version:
265        .short 5               # DWARF version number
266        .byte 1                # DWARF Unit Type
267        .byte 8                # Address Size (in bytes)
268        .long .debug_abbrev.dwo  # Offset Into Abbrev Section
269# The compile-unit DIE, which has a DW_AT_producer, DW_AT_name,
270# DW_AT_str_offsets and DW_AT_compdir.
271        .byte 1                # Abbreviation code
272        .byte 0                # The index of the producer string
273        .byte 1                # The index of the CU name string
274        .byte 2                # The index of the comp dir string
275        .byte 0 # NULL
276CU_split_5_end:
277
278        .section .debug_types.dwo,"",@progbits
279
280# DWARF v5 split type unit header.
281TU_split_5_start:
282        .long  TU_split_5_end-TU_split_5_version  # Length of Unit
283TU_split_5_version:
284        .short 5               # DWARF version number
285        .byte 6                # DWARF Unit Type
286        .byte 8                # Address Size (in bytes)
287        .long .debug_abbrev.dwo  # Offset Into Abbrev Section
288        .quad 0x8899aabbccddeeff # Type Signature
289        .long TU_split_5_type-TU_split_5_start  # Type offset
290# The type-unit DIE, which has a name.
291        .byte 2                # Abbreviation code
292        .byte 3                # The index of the type unit name string
293# The type DIE, which has a name.
294TU_split_5_type:
295        .byte 3                # Abbreviation code
296        .byte 4                # The index of the type name string
297        .byte 0 # NULL
298        .byte 0 # NULL
299TU_split_5_end:
300
301# We are using a hand-constructed object file and are interest in the correct
302# diplay of the DW_str_offsetsbase attribute, the correct display of strings
303# and the dump of the .debug_str_offsets[.dwo] table.
304
305# Abbreviation for DW_AT_str_offsets_base
306# COMMON:      .debug_abbrev contents:
307# COMMON-NOT:  contents:
308# COMMON:      DW_TAG_compile_unit
309# COMMON-NOT:  DW_TAG
310# COMMON:      DW_AT_str_offsets_base DW_FORM_sec_offset
311#
312# Verify that strings are displayed correctly as indexed strings
313# COMMON:      .debug_info contents:
314# COMMON-NOT:  contents:
315# COMMON:      DW_TAG_compile_unit
316# COMMON-NEXT: DW_AT_producer [DW_FORM_strx] ( indexed (00000000) string = "Handmade DWARF producer")
317# COMMON-NEXT: DW_AT_name [DW_FORM_strx] ( indexed (00000001) string = "Compile_Unit_1")
318# COMMON-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000008)
319# COMMON-NEXT: DW_AT_comp_dir [DW_FORM_strx] ( indexed (00000002) string = "/home/test/CU1")
320# COMMON-NOT:  NULL
321# COMMON:      DW_TAG_subprogram
322# COMMON-NEXT: DW_AT_name [DW_FORM_strx1] ( indexed (00000003) string = "MyFunc")
323# COMMON-NOT:  NULL
324# COMMON:      DW_TAG_variable
325# COMMON-NEXT: DW_AT_name [DW_FORM_strx2] ( indexed (00000004) string = "MyVar1")
326# COMMON-NOT:  NULL
327# COMMON:      DW_TAG_variable
328# COMMON-NEXT: DW_AT_name [DW_FORM_strx3] ( indexed (00000005) string = "MyVar2")
329# COMMON-NOT:  NULL
330# COMMON:      DW_TAG_variable
331# COMMON-NEXT: DW_AT_name [DW_FORM_strx4] ( indexed (00000006) string = "MyVar3")
332#
333# Second compile unit (b.cpp)
334# COMMON:      DW_TAG_compile_unit
335# COMMON-NEXT: DW_AT_producer [DW_FORM_strx] ( indexed (00000000) string = "Handmade DWARF producer")
336# COMMON-NEXT: DW_AT_name [DW_FORM_strx] ( indexed (00000001) string = "Compile_Unit_2")
337# COMMON-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000038)
338# COMMON-NEXT: DW_AT_comp_dir [DW_FORM_strx] ( indexed (00000002) string = "/home/test/CU2")
339#
340# The split CU
341# SPLIT:       .debug_info.dwo contents:
342# SPLIT-NOT:   contents:
343# SPLIT:       DW_TAG_compile_unit
344# SPLIT-NEXT:  DW_AT_producer [DW_FORM_strx] ( indexed (00000000) string = "Handmade split DWARF producer")
345# SPLIT-NEXT:  DW_AT_name [DW_FORM_strx] ( indexed (00000001) string = "V5_split_compile_unit")
346# SPLIT-NEXT:  DW_AT_comp_dir [DW_FORM_strx] ( indexed (00000002) string = "/home/test/splitCU")
347#
348# The type unit
349# COMMON:      .debug_types contents:
350# COMMON:      DW_TAG_type_unit
351# COMMON-NEXT: DW_AT_name [DW_FORM_strx] ( indexed (00000000) string = "Type_Unit")
352# COMMON:      DW_TAG_structure_type
353# COMMON-NEXT: DW_AT_name [DW_FORM_strx] ( indexed (00000001) string = "MyStruct")
354#
355# The split type unit
356# SPLIT:       .debug_types.dwo contents:
357# SPLIT:       DW_TAG_type_unit
358# SPLIT-NEXT:  DW_AT_name [DW_FORM_strx] ( indexed (00000003) string = "V5_split_type_unit")
359# SPLIT:       DW_TAG_structure_type
360# SPLIT-NEXT:  DW_AT_name [DW_FORM_strx] ( indexed (00000004) string = "V5_split_Mystruct")
361#
362# The .debug_str_offsets section
363# COMMON:      .debug_str_offsets contents:
364# COMMON-NEXT: 0x00000000: Contribution size = 32, Format = DWARF32, Version = 5
365# COMMON-NEXT: 0x00000008: 00000000 "Handmade DWARF producer"
366# COMMON-NEXT: 0x0000000c: 00000018 "Compile_Unit_1"
367# COMMON-NEXT: 0x00000010: 00000027 "/home/test/CU1"
368# COMMON-NEXT: 0x00000014: 00000067 "MyFunc"
369# COMMON-NEXT: 0x00000018: 0000006e "MyVar1"
370# COMMON-NEXT: 0x0000001c: 00000075 "MyVar2"
371# COMMON-NEXT: 0x00000020: 0000007c "MyVar3"
372# COMMON-NEXT: Gap, length = 4
373# COMMON-NEXT: 0x00000028: Contribution size = 28, Format = DWARF64, Version = 5
374# COMMON-NEXT: 0x00000038: 00000000 "Handmade DWARF producer"
375# COMMON-NEXT: 0x00000040: 00000036 "Compile_Unit_2"
376# COMMON-NEXT: 0x00000048: 00000045 "/home/test/CU2"
377# COMMON-NEXT: 0x00000050: Contribution size = 12, Format = DWARF32, Version = 5
378# COMMON-NEXT: 0x00000058: 00000054 "Type_Unit"
379# COMMON-NEXT: 0x0000005c: 0000005e "MyStruct"
380#
381# SPLIT:       .debug_str_offsets.dwo contents:
382# SPLIT-NEXT:  0x00000000: Contribution size = 24, Format = DWARF32, Version = 5
383# SPLIT-NEXT:  0x00000008: 00000000 "Handmade split DWARF producer"
384# SPLIT-NEXT:  0x0000000c: 0000001e "V5_split_compile_unit"
385# SPLIT-NEXT:  0x00000010: 00000034 "/home/test/splitCU"
386# SPLIT-NEXT:  0x00000014: 00000047 "V5_split_type_unit"
387# SPLIT-NEXT:  0x00000018: 0000005a "V5_split_Mystruct"
388
389# ERR-NOT: parsing a range list table:
390