xref: /llvm-project/llvm/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s (revision 6d0be74af5555f7bc56ac72cbd98ff270fd1291b)
1e4663962SIgor Kudrin# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o
2e0fd87ccSDavid Blaikie# RUN: not llvm-dwarfdump -v -debug-info %t.o 2> %t.err | FileCheck %s
3*6d0be74aSDavid Blaikie# RUN: FileCheck %s --input-file %t.err --check-prefix=ERR --implicit-check-not=error
4e0fd87ccSDavid Blaikie# RUN: not llvm-dwarfdump -lookup 10 %t.o 2> %t2.err
5*6d0be74aSDavid Blaikie# RUN: FileCheck %s --input-file %t2.err --check-prefix=ERR --implicit-check-not=error
62094c5d2SIgor Kudrin# RUN: llvm-dwarfdump -debug-rnglists %t.o | \
72094c5d2SIgor Kudrin# RUN:   FileCheck %s --check-prefix=RNGLISTS
8e4663962SIgor Kudrin
9e4663962SIgor Kudrin# Test object to verify dwarfdump handles v5 range lists in 64-bit DWARF format.
10e4663962SIgor Kudrin# This is similar to 'dwarfdump-rnglists.s', which uses 32-bit DWARF format.
11e4663962SIgor Kudrin# We use very simplified compile unit dies.
12e4663962SIgor Kudrin# There are 2 full CUs with DW_AT_rnglists_base, one with a DW_AT_ranges
13e4663962SIgor Kudrin# attribute using DW_FORM_sec_offset, the other with DW_AT_ranges using
14e4663962SIgor Kudrin# DW_FORM_rnglistx.
15e4663962SIgor Kudrin
16e4663962SIgor Kudrin        .section .debug_abbrev,"",@progbits
17e4663962SIgor Kudrin        .byte 0x01  # Abbrev code
18e4663962SIgor Kudrin        .byte 0x11  # DW_TAG_compile_unit
19e4663962SIgor Kudrin        .byte 0x00  # DW_CHILDREN_no
20e4663962SIgor Kudrin        .byte 0x74  # DW_AT_rnglists_base
21e4663962SIgor Kudrin        .byte 0x17  # DW_FORM_sec_offset
22e4663962SIgor Kudrin        .byte 0x55  # DW_AT_ranges
23e4663962SIgor Kudrin        .byte 0x17  # DW_FORM_sec_offset
24e4663962SIgor Kudrin        .byte 0x00  # EOM(1)
25e4663962SIgor Kudrin        .byte 0x00  # EOM(2)
26e4663962SIgor Kudrin        .byte 0x02  # Abbrev code
27e4663962SIgor Kudrin        .byte 0x11  # DW_TAG_compile_unit
28e4663962SIgor Kudrin        .byte 0x00  # DW_CHILDREN_no
29e4663962SIgor Kudrin        .byte 0x74  # DW_AT_rnglists_base
30e4663962SIgor Kudrin        .byte 0x17  # DW_FORM_sec_offset
31e4663962SIgor Kudrin        .byte 0x55  # DW_AT_ranges
32e4663962SIgor Kudrin        .byte 0x23  # DW_FORM_rnglistx
33e4663962SIgor Kudrin        .byte 0x00  # EOM(1)
34e4663962SIgor Kudrin        .byte 0x00  # EOM(2)
35e4663962SIgor Kudrin        .byte 0x00  # EOM(3)
36e4663962SIgor Kudrin
37e4663962SIgor Kudrin# The split CU uses DW_FORM_rnglistx (the only correct option).
38e4663962SIgor Kudrin# There is no DW_AT_rnglists_base in split units.
39d840e545SFangrui Song        .section .debug_abbrev.dwo,"e",@progbits
40e4663962SIgor Kudrin        .byte 0x01  # Abbrev code
41e4663962SIgor Kudrin        .byte 0x11  # DW_TAG_compile_unit
42e4663962SIgor Kudrin        .byte 0x00  # DW_CHILDREN_no
43e4663962SIgor Kudrin        .byte 0x55  # DW_AT_ranges
44e4663962SIgor Kudrin        .byte 0x23  # DW_FORM_rnglistx
45e4663962SIgor Kudrin        .byte 0x00  # EOM(1)
46e4663962SIgor Kudrin        .byte 0x00  # EOM(2)
47e4663962SIgor Kudrin        .byte 0x00  # EOM(3)
48e4663962SIgor Kudrin
49e4663962SIgor Kudrin        .section .debug_info,"",@progbits
50e4663962SIgor Kudrin        .long 0xffffffff       # DWARF64 mark
51e4663962SIgor Kudrin        .quad  CU1_5_64_end - CU1_5_64_version  # Length of Unit
52e4663962SIgor KudrinCU1_5_64_version:
53e4663962SIgor Kudrin        .short 5               # DWARF version number
54e4663962SIgor Kudrin        .byte 1                # DWARF Unit Type
55e4663962SIgor Kudrin        .byte 4                # Address Size (in bytes)
56e4663962SIgor Kudrin        .quad .debug_abbrev    # Offset Into Abbrev. Section
57e4663962SIgor Kudrin# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
58e4663962SIgor Kudrin        .byte 1                # Abbreviation code
59e4663962SIgor Kudrin        .quad Rnglist_Table0_base     # DW_AT_rnglists_base
60e4663962SIgor Kudrin        .quad Rnglist_Table0_Rnglist0 # DW_AT_ranges
61e4663962SIgor KudrinCU1_5_64_end:
62e4663962SIgor Kudrin
63e4663962SIgor Kudrin        .long 0xffffffff       # DWARF64 mark
64e4663962SIgor Kudrin        .quad  CU2_5_64_end - CU2_5_64_version  # Length of Unit
65e4663962SIgor KudrinCU2_5_64_version:
66e4663962SIgor Kudrin        .short 5               # DWARF version number
67e4663962SIgor Kudrin        .byte 1                # DWARF Unit Type
68e4663962SIgor Kudrin        .byte 4                # Address Size (in bytes)
69e4663962SIgor Kudrin        .quad .debug_abbrev    # Offset Into Abbrev. Section
70e4663962SIgor Kudrin# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
71e4663962SIgor Kudrin        .byte 2                # Abbreviation code
72e4663962SIgor Kudrin        .quad Rnglist_Table0_base   # DW_AT_rnglists_base
73e4663962SIgor Kudrin        .uleb128 1             # DW_AT_ranges
74e4663962SIgor KudrinCU2_5_64_end:
75e4663962SIgor Kudrin
76e4663962SIgor Kudrin# A CU with an invalid DW_AT_rnglists_base attribute
77e4663962SIgor Kudrin        .long 0xffffffff       # DWARF64 mark
78e4663962SIgor Kudrin        .quad  CU3_5_64_end - CU3_5_64_version  # Length of Unit
79e4663962SIgor KudrinCU3_5_64_version:
80e4663962SIgor Kudrin        .short 5               # DWARF version number
81e4663962SIgor Kudrin        .byte 1                # DWARF Unit Type
82e4663962SIgor Kudrin        .byte 4                # Address Size (in bytes)
83e4663962SIgor Kudrin        .quad .debug_abbrev    # Offset Into Abbrev. Section
84e4663962SIgor Kudrin# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
85e4663962SIgor Kudrin        .byte 2                # Abbreviation code
86e4663962SIgor Kudrin        .quad 0x8              # DW_AT_rnglists_base
87e4663962SIgor Kudrin        .uleb128 0             # DW_AT_ranges
88e4663962SIgor KudrinCU3_5_64_end:
89e4663962SIgor Kudrin
90e4663962SIgor Kudrin# A CU DIE with an incorrect DW_AT_ranges attribute
91e4663962SIgor Kudrin        .long 0xffffffff       # DWARF64 mark
92e4663962SIgor Kudrin        .quad  CU4_5_64_end - CU4_5_64_version  # Length of Unit
93e4663962SIgor KudrinCU4_5_64_version:
94e4663962SIgor Kudrin        .short 5               # DWARF version number
95e4663962SIgor Kudrin        .byte 1                # DWARF Unit Type
96e4663962SIgor Kudrin        .byte 4                # Address Size (in bytes)
97e4663962SIgor Kudrin        .quad .debug_abbrev    # Offset Into Abbrev. Section
98e4663962SIgor Kudrin# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
99e4663962SIgor Kudrin        .byte 1                # Abbreviation code
100e4663962SIgor Kudrin        .quad Rnglist_Table0_base   # DW_AT_rnglists_base
101e4663962SIgor Kudrin        .quad 4000             # DW_AT_ranges
102e4663962SIgor KudrinCU4_5_64_end:
103e4663962SIgor Kudrin
104d840e545SFangrui Song        .section .debug_info.dwo,"e",@progbits
105e4663962SIgor Kudrin
106e4663962SIgor Kudrin# DWARF v5 split CU header.
107e4663962SIgor Kudrin        .long 0xffffffff       # DWARF64 mark
108e4663962SIgor Kudrin        .quad  CU_split_5_64_end-CU_split_5_64_version  # Length of Unit
109e4663962SIgor KudrinCU_split_5_64_version:
110e4663962SIgor Kudrin        .short 5               # DWARF version number
111e4663962SIgor Kudrin        .byte 5                # DWARF Unit Type
112e4663962SIgor Kudrin        .byte 4                # Address Size (in bytes)
113e4663962SIgor Kudrin        .quad 0                # Offset Into Abbrev Section
1146f635f90SIgor Kudrin        .quad 0xdeadbeefbaadf00d  # DWO id
115e4663962SIgor Kudrin# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
116e4663962SIgor Kudrin        .byte 1                # Abbreviation code
117e4663962SIgor Kudrin        .uleb128 1             # DW_AT_ranges
118e4663962SIgor KudrinCU_split_5_64_end:
119e4663962SIgor Kudrin
120e4663962SIgor Kudrin        .section .debug_rnglists,"",@progbits
121e4663962SIgor Kudrin# A rnglist table with 2 range lists. The first one uses DW_RLE_start_end
122e4663962SIgor Kudrin# and DW_RLE_start_length. The second one uses DW_RLE_base_address and
123e4663962SIgor Kudrin# DW_RLE_offset_pair. The range lists have entries in the offset table.
124e4663962SIgor Kudrin        .long 0xffffffff                            # DWARF64 mark
125e4663962SIgor Kudrin        .quad Rnglist_Table0_end - Rnglist_Table0   # table length
126e4663962SIgor KudrinRnglist_Table0:
127e4663962SIgor Kudrin        .short 5                                    # version
128e4663962SIgor Kudrin        .byte 4                                     # address size
129e4663962SIgor Kudrin        .byte 0                                     # segment selector size
130e4663962SIgor Kudrin        .long 2                                     # offset entry count
131e4663962SIgor KudrinRnglist_Table0_base:
132e4663962SIgor Kudrin# 2 offset entries which can be used by DW_FORM_rnglistx.
133e4663962SIgor Kudrin        .quad Rnglist_Table0_Rnglist0 - Rnglist_Table0_base
134e4663962SIgor Kudrin        .quad Rnglist_Table0_Rnglist1 - Rnglist_Table0_base
135e4663962SIgor KudrinRnglist_Table0_Rnglist0:
136e4663962SIgor Kudrin        .byte 6                                     # DW_RLE_start_end
137e4663962SIgor Kudrin        .long Range0_start
138e4663962SIgor Kudrin        .long Range0_end
139e4663962SIgor Kudrin        .byte 7                                     # DW_RLE_start_length
140e4663962SIgor Kudrin        .long Range1_start
141e4663962SIgor Kudrin        .uleb128 Range1_end - Range1_start
142e4663962SIgor Kudrin        .byte 0                                     # DW_RLE_end_of_list
143e4663962SIgor KudrinRnglist_Table0_Rnglist1:
144e4663962SIgor Kudrin        .byte 5                                     # DW_RLE_base_address
145e4663962SIgor Kudrin        .long Range0_start
146e4663962SIgor Kudrin        .byte 4                                     # DW_RLE_offset_pair
147e4663962SIgor Kudrin        .uleb128 Range1_start - Range0_start
148e4663962SIgor Kudrin        .uleb128 Range1_end - Range0_start
149e4663962SIgor Kudrin        .byte 0                                     # DW_RLE_end_of_list
150e4663962SIgor KudrinRnglist_Table0_end:
151e4663962SIgor Kudrin
152e4663962SIgor Kudrin# A rnglist table for the split unit with an empty rangelist and one that
153e4663962SIgor Kudrin# uses DW_RLE_base_address and DW_RLE_offset_pair. The ranges have entries
154e4663962SIgor Kudrin# in the offset table. We use the empty range list so we can test
155e4663962SIgor Kudrin# DW_FORM_rnglistx with an index other than 0.
156d840e545SFangrui Song        .section .debug_rnglists.dwo,"e",@progbits
157e4663962SIgor Kudrin        .long 0xffffffff                            # DWARF64 mark
158e4663962SIgor Kudrin        .quad Rnglist_Table0_dwo_end - Rnglist_Table0_dwo   # table length
159e4663962SIgor KudrinRnglist_Table0_dwo:
160e4663962SIgor Kudrin        .short 5                                    # version
161e4663962SIgor Kudrin        .byte 4                                     # address size
162e4663962SIgor Kudrin        .byte 0                                     # segment selector size
163e4663962SIgor Kudrin        .long 2                                     # offset entry count
164e4663962SIgor KudrinRnglist_Table0_base_dwo:
165e4663962SIgor Kudrin# 2 offset entries which can be used by DW_FORM_rnglistx.
166e4663962SIgor Kudrin        .quad Rnglist_Table0_Rnglist0_dwo - Rnglist_Table0_base_dwo
167e4663962SIgor Kudrin        .quad Rnglist_Table0_Rnglist1_dwo - Rnglist_Table0_base_dwo
168e4663962SIgor KudrinRnglist_Table0_Rnglist0_dwo:
169e4663962SIgor Kudrin        .byte 0                                     # DW_RLE_start_end
170e4663962SIgor KudrinRnglist_Table0_Rnglist1_dwo:
171e4663962SIgor Kudrin        .byte 5                                     # DW_RLE_base_address
172e4663962SIgor Kudrin        .long Range0_start - .text
173e4663962SIgor Kudrin        .byte 4                                     # DW_RLE_offset_pair
174e4663962SIgor Kudrin        .uleb128 Range1_start - Range0_start
175e4663962SIgor Kudrin        .uleb128 Range1_end - Range0_start
176e4663962SIgor Kudrin        .byte 0                                     # DW_RLE_end_of_list
177e4663962SIgor KudrinRnglist_Table0_dwo_end:
178e4663962SIgor Kudrin
179e4663962SIgor Kudrin.text
180e4663962SIgor Kudrin        .space 20
181e4663962SIgor KudrinRange0_start:               # Range0: 0x14 - 0x1c
182e4663962SIgor Kudrin        .space 10
183e4663962SIgor KudrinRange0_end:
184e4663962SIgor Kudrin        .space 12
185e4663962SIgor KudrinRange1_start:               # Range1: 0x2a - 0x34
186e4663962SIgor Kudrin        .space 10
187e4663962SIgor KudrinRange1_end:
188e4663962SIgor Kudrin
189e4663962SIgor Kudrin# CHECK:      .debug_info contents:
190e4663962SIgor Kudrin# CHECK:      Compile Unit:
191e4663962SIgor Kudrin# CHECK-NOT:  Compile Unit:
192e4663962SIgor Kudrin# CHECK:      DW_TAG_compile_unit
193f92a5545SIgor Kudrin# CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset]  (0x0000000000000014)
194f92a5545SIgor Kudrin# CHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x0000000000000024
195e4663962SIgor Kudrin# CHECK-NEXT: [0x00000014, 0x0000001e) ".text"
196e4663962SIgor Kudrin# CHECK-NEXT: [0x0000002a, 0x00000034) ".text")
197e4663962SIgor Kudrin
198e4663962SIgor Kudrin# CHECK:      Compile Unit:
199e4663962SIgor Kudrin# CHECK-NOT:  Compile Unit:
200e4663962SIgor Kudrin# CHECK:      DW_TAG_compile_unit
201f92a5545SIgor Kudrin# CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset]  (0x0000000000000014)
2024ee76a92SPavel Labath# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000034
203e4663962SIgor Kudrin# CHECK-NEXT: [0x0000002a, 0x00000034) ".text")
204e4663962SIgor Kudrin
205e4663962SIgor Kudrin# CHECK:      .debug_info.dwo contents:
206e4663962SIgor Kudrin# CHECK:      Compile Unit:
207e4663962SIgor Kudrin# CHECK-NOT:  contents:
208e4663962SIgor Kudrin# CHECK:      DW_TAG_compile_unit
2094ee76a92SPavel Labath# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000025
210e4663962SIgor Kudrin# CHECK-NEXT: [0x0000002a, 0x00000034))
211e4663962SIgor Kudrin
212*6d0be74aSDavid Blaikie#ERR: error: decoding address ranges: invalid range list offset 0x4000500000008
213e4663962SIgor Kudrin#ERR: error: decoding address ranges: invalid range list offset 0xfa0
2142094c5d2SIgor Kudrin
2152094c5d2SIgor Kudrin# RNGLISTS:      .debug_rnglists contents:
2162094c5d2SIgor Kudrin# RNGLISTS:      range list header:
2172094c5d2SIgor Kudrin# RNGLISTS-SAME:   length = 0x0000000000000031,
218def67719SIgor Kudrin# RNGLISTS-SAME:   format = DWARF64,
2192094c5d2SIgor Kudrin# RNGLISTS-SAME:   version = 0x0005,
2202094c5d2SIgor Kudrin# RNGLISTS-SAME:   addr_size = 0x04,
2212094c5d2SIgor Kudrin# RNGLISTS-SAME:   seg_size = 0x00,
2222094c5d2SIgor Kudrin# RNGLISTS-SAME:   offset_entry_count = 0x00000002
2232094c5d2SIgor Kudrin# RNGLISTS-NEXT: offsets: [
2242094c5d2SIgor Kudrin# RNGLISTS-NEXT: 0x0000000000000010
2252094c5d2SIgor Kudrin# RNGLISTS-NEXT: 0x0000000000000020
2262094c5d2SIgor Kudrin# RNGLISTS-NEXT: ]
2272094c5d2SIgor Kudrin# RNGLISTS-NEXT: ranges:
2282094c5d2SIgor Kudrin# RNGLISTS-NEXT: [0x00000014, 0x0000001e)
2292094c5d2SIgor Kudrin# RNGLISTS-NEXT: [0x0000002a, 0x00000034)
2302094c5d2SIgor Kudrin# RNGLISTS-NEXT: <End of list>
2312094c5d2SIgor Kudrin# RNGLISTS-NEXT: [0x0000002a, 0x00000034)
2322094c5d2SIgor Kudrin# RNGLISTS-NEXT: <End of list>
2332094c5d2SIgor Kudrin
2342094c5d2SIgor Kudrin# RNGLISTS:      .debug_rnglists.dwo contents:
2352094c5d2SIgor Kudrin# RNGLISTS:      range list header:
2362094c5d2SIgor Kudrin# RNGLISTS-SAME:   length = 0x0000000000000022,
237def67719SIgor Kudrin# RNGLISTS-SAME:   format = DWARF64,
2382094c5d2SIgor Kudrin# RNGLISTS-SAME:   version = 0x0005,
2392094c5d2SIgor Kudrin# RNGLISTS-SAME:   addr_size = 0x04,
2402094c5d2SIgor Kudrin# RNGLISTS-SAME:   seg_size = 0x00,
2412094c5d2SIgor Kudrin# RNGLISTS-SAME:   offset_entry_count = 0x00000002
2422094c5d2SIgor Kudrin# RNGLISTS-NEXT: offsets: [
2432094c5d2SIgor Kudrin# RNGLISTS-NEXT: 0x0000000000000010
2442094c5d2SIgor Kudrin# RNGLISTS-NEXT: 0x0000000000000011
2452094c5d2SIgor Kudrin# RNGLISTS-NEXT: ]
2462094c5d2SIgor Kudrin# RNGLISTS-NEXT: ranges:
2472094c5d2SIgor Kudrin# RNGLISTS-NEXT: <End of list>
2482094c5d2SIgor Kudrin# RNGLISTS-NEXT: [0x0000002a, 0x00000034)
2492094c5d2SIgor Kudrin# RNGLISTS-NEXT: <End of list>
250