xref: /llvm-project/llvm/test/DebugInfo/X86/dwarfdump-rnglists.s (revision 6d0be74af5555f7bc56ac72cbd98ff270fd1291b)
1ad60559bSWolfgang Pieb# 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
6ad60559bSWolfgang Pieb
7ad60559bSWolfgang Pieb# Test object to verify dwarfdump handles v5 range lists.
8ad60559bSWolfgang Pieb# We use very simplified compile unit dies.
9ad60559bSWolfgang Pieb# There are 2 full CUs with DW_AT_rnglists_base, one with a DW_AT_ranges
10ad60559bSWolfgang Pieb# attribute using DW_FORM_sec_offset, the other with DW_AT_ranges using
11ad60559bSWolfgang Pieb# DW_FORM_rnglistx.
12ad60559bSWolfgang Pieb
13ad60559bSWolfgang Pieb        .section .debug_abbrev,"",@progbits
14ad60559bSWolfgang Pieb        .byte 0x01  # Abbrev code
15ad60559bSWolfgang Pieb        .byte 0x11  # DW_TAG_compile_unit
16ad60559bSWolfgang Pieb        .byte 0x00  # DW_CHILDREN_no
17ad60559bSWolfgang Pieb        .byte 0x74  # DW_AT_rnglists_base
18ad60559bSWolfgang Pieb        .byte 0x17  # DW_FORM_sec_offset
19ad60559bSWolfgang Pieb        .byte 0x55  # DW_AT_ranges
20ad60559bSWolfgang Pieb        .byte 0x17  # DW_FORM_sec_offset
21ad60559bSWolfgang Pieb        .byte 0x00  # EOM(1)
22ad60559bSWolfgang Pieb        .byte 0x00  # EOM(2)
23ad60559bSWolfgang Pieb        .byte 0x02  # Abbrev code
24ad60559bSWolfgang Pieb        .byte 0x11  # DW_TAG_compile_unit
25ad60559bSWolfgang Pieb        .byte 0x00  # DW_CHILDREN_no
26ad60559bSWolfgang Pieb        .byte 0x74  # DW_AT_rnglists_base
27ad60559bSWolfgang Pieb        .byte 0x17  # DW_FORM_sec_offset
28ad60559bSWolfgang Pieb        .byte 0x55  # DW_AT_ranges
29ad60559bSWolfgang Pieb        .byte 0x23  # DW_FORM_rnglistx
30ad60559bSWolfgang Pieb        .byte 0x00  # EOM(1)
31ad60559bSWolfgang Pieb        .byte 0x00  # EOM(2)
32ad60559bSWolfgang Pieb        .byte 0x00  # EOM(3)
33ad60559bSWolfgang Pieb
34ad60559bSWolfgang Pieb# The split CU uses DW_FORM_rnglistx (the only correct option).
35ad60559bSWolfgang Pieb# There is no DW_AT_rnglists_base in split units.
36d840e545SFangrui Song        .section .debug_abbrev.dwo,"e",@progbits
37ad60559bSWolfgang Pieb        .byte 0x01  # Abbrev code
38ad60559bSWolfgang Pieb        .byte 0x11  # DW_TAG_compile_unit
39ad60559bSWolfgang Pieb        .byte 0x00  # DW_CHILDREN_no
40ad60559bSWolfgang Pieb        .byte 0x55  # DW_AT_ranges
41ad60559bSWolfgang Pieb        .byte 0x23  # DW_FORM_rnglistx
42ad60559bSWolfgang Pieb        .byte 0x00  # EOM(1)
43ad60559bSWolfgang Pieb        .byte 0x00  # EOM(2)
44ad60559bSWolfgang Pieb        .byte 0x00  # EOM(3)
45ad60559bSWolfgang Pieb
46ad60559bSWolfgang Pieb        .section .debug_info,"",@progbits
47ad60559bSWolfgang Pieb        .long  CU1_5_end-CU1_5_version  # Length of Unit
48ad60559bSWolfgang PiebCU1_5_version:
49ad60559bSWolfgang Pieb        .short 5               # DWARF version number
50ad60559bSWolfgang Pieb        .byte 1                # DWARF Unit Type
51ad60559bSWolfgang Pieb        .byte 4                # Address Size (in bytes)
52ad60559bSWolfgang Pieb        .long .debug_abbrev    # Offset Into Abbrev. Section
53ad60559bSWolfgang Pieb# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
54ad60559bSWolfgang Pieb        .byte 1                # Abbreviation code
55ad60559bSWolfgang Pieb        .long Rnglist_Table0_base     # DW_AT_rnglists_base
56ad60559bSWolfgang Pieb        .long Rnglist_Table0_Rnglist0 # DW_AT_ranges
57ad60559bSWolfgang Pieb        .byte 0 # NULL
58ad60559bSWolfgang Pieb        .byte 0 # NULL
59ad60559bSWolfgang PiebCU1_5_end:
60ad60559bSWolfgang Pieb
61ad60559bSWolfgang Pieb        .long  CU2_5_end-CU2_5_version  # Length of Unit
62ad60559bSWolfgang PiebCU2_5_version:
63ad60559bSWolfgang Pieb        .short 5               # DWARF version number
64ad60559bSWolfgang Pieb        .byte 1                # DWARF Unit Type
65ad60559bSWolfgang Pieb        .byte 4                # Address Size (in bytes)
66ad60559bSWolfgang Pieb        .long .debug_abbrev    # Offset Into Abbrev. Section
67ad60559bSWolfgang Pieb# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
68ad60559bSWolfgang Pieb        .byte 2                # Abbreviation code
69ad60559bSWolfgang Pieb        .long Rnglist_Table0_base   # DW_AT_rnglists_base
70ad60559bSWolfgang Pieb        .uleb128 1             # DW_AT_ranges
71ad60559bSWolfgang Pieb        .byte 0                # NULL
72ad60559bSWolfgang PiebCU2_5_end:
73ad60559bSWolfgang Pieb# A CU with an invalid DW_AT_rnglists_base attribute
74ad60559bSWolfgang Pieb        .long  CU3_5_end-CU3_5_version  # Length of Unit
75ad60559bSWolfgang PiebCU3_5_version:
76ad60559bSWolfgang Pieb        .short 5               # DWARF version number
77ad60559bSWolfgang Pieb        .byte 1                # DWARF Unit Type
78ad60559bSWolfgang Pieb        .byte 4                # Address Size (in bytes)
79ad60559bSWolfgang Pieb        .long .debug_abbrev    # Offset Into Abbrev. Section
80ad60559bSWolfgang Pieb# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
81ad60559bSWolfgang Pieb        .byte 2                # Abbreviation code
82ad60559bSWolfgang Pieb        .long 0x8              # DW_AT_rnglists_base
83ad60559bSWolfgang Pieb        .long 0                # DW_AT_ranges
84ad60559bSWolfgang Pieb        .byte 0                # NULL
85ad60559bSWolfgang PiebCU3_5_end:
8661d8c8d9SWolfgang Pieb# A CU DIE with an incorrect DW_AT_ranges attribute
8761d8c8d9SWolfgang Pieb        .long  CU4_5_end-CU4_5_version  # Length of Unit
8861d8c8d9SWolfgang PiebCU4_5_version:
8961d8c8d9SWolfgang Pieb        .short 5               # DWARF version number
9061d8c8d9SWolfgang Pieb        .byte 1                # DWARF Unit Type
9161d8c8d9SWolfgang Pieb        .byte 4                # Address Size (in bytes)
9261d8c8d9SWolfgang Pieb        .long .debug_abbrev    # Offset Into Abbrev. Section
9361d8c8d9SWolfgang Pieb# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
9461d8c8d9SWolfgang Pieb        .byte 1                # Abbreviation code
9561d8c8d9SWolfgang Pieb        .long Rnglist_Table0_base   # DW_AT_rnglists_base
9661d8c8d9SWolfgang Pieb        .long 4000             # DW_AT_ranges
9761d8c8d9SWolfgang Pieb        .byte 0                # NULL
9861d8c8d9SWolfgang PiebCU4_5_end:
99ad60559bSWolfgang Pieb
100d840e545SFangrui Song        .section .debug_info.dwo,"e",@progbits
101ad60559bSWolfgang Pieb
102ad60559bSWolfgang Pieb# DWARF v5 split CU header.
103ad60559bSWolfgang Pieb        .long  CU_split_5_end-CU_split_5_version  # Length of Unit
104ad60559bSWolfgang PiebCU_split_5_version:
105ad60559bSWolfgang Pieb        .short 5               # DWARF version number
106ad60559bSWolfgang Pieb        .byte 5                # DWARF Unit Type
107ad60559bSWolfgang Pieb        .byte 4                # Address Size (in bytes)
108ad60559bSWolfgang Pieb        .long 0                # Offset Into Abbrev Section
1096f635f90SIgor Kudrin        .quad 0xdeadbeefbaadf00d  # DWO id
110ad60559bSWolfgang Pieb# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
111ad60559bSWolfgang Pieb        .byte 1                # Abbreviation code
112ad60559bSWolfgang Pieb        .uleb128 1             # DW_AT_ranges
113ad60559bSWolfgang Pieb        .byte 0                # NULL
114ad60559bSWolfgang PiebCU_split_5_end:
115ad60559bSWolfgang Pieb
116ad60559bSWolfgang Pieb        .section .debug_rnglists,"",@progbits
117ad60559bSWolfgang Pieb# A rnglist table with 2 range lists. The first one uses DW_RLE_start_end
118ad60559bSWolfgang Pieb# and DW_RLE_start_length. The second one uses DW_RLE_base_address and
119ad60559bSWolfgang Pieb# DW_RLE_offset_pair. The range lists have entries in the offset table.
120ad60559bSWolfgang Pieb        .long Rnglist_Table0_end - Rnglist_Table0   # table length
121ad60559bSWolfgang PiebRnglist_Table0:
122ad60559bSWolfgang Pieb        .short 5                                    # version
123ad60559bSWolfgang Pieb        .byte 4                                     # address size
124ad60559bSWolfgang Pieb        .byte 0                                     # segment selector size
125ad60559bSWolfgang Pieb        .long 2                                     # offset entry count
126ad60559bSWolfgang PiebRnglist_Table0_base:
127ad60559bSWolfgang Pieb# 2 offset entries which can be used by DW_FORM_rnglistx.
128ad60559bSWolfgang Pieb        .long Rnglist_Table0_Rnglist0 - Rnglist_Table0_base
129ad60559bSWolfgang Pieb        .long Rnglist_Table0_Rnglist1 - Rnglist_Table0_base
130ad60559bSWolfgang PiebRnglist_Table0_Rnglist0:
131ad60559bSWolfgang Pieb        .byte 6                                     # DW_RLE_start_end
132ad60559bSWolfgang Pieb        .long Range0_start
133ad60559bSWolfgang Pieb        .long Range0_end
134ad60559bSWolfgang Pieb        .byte 7                                     # DW_RLE_start_length
135ad60559bSWolfgang Pieb        .long Range1_start
136ad60559bSWolfgang Pieb        .uleb128 Range1_end - Range1_start
137ad60559bSWolfgang Pieb        .byte 0                                     # DW_RLE_end_of_list
138ad60559bSWolfgang PiebRnglist_Table0_Rnglist1:
139ad60559bSWolfgang Pieb        .byte 5                                     # DW_RLE_base_address
140ad60559bSWolfgang Pieb        .long Range0_start
141ad60559bSWolfgang Pieb        .byte 4                                     # DW_RLE_offset_pair
142ad60559bSWolfgang Pieb        .uleb128 Range1_start - Range0_start
143ad60559bSWolfgang Pieb        .uleb128 Range1_end - Range0_start
144ad60559bSWolfgang Pieb        .byte 0                                     # DW_RLE_end_of_list
145ad60559bSWolfgang PiebRnglist_Table0_end:
146ad60559bSWolfgang Pieb
147ad60559bSWolfgang Pieb# A rnglist table for the split unit with an empty rangelist and one that
148ad60559bSWolfgang Pieb# uses DW_RLE_base_address and DW_RLE_offset_pair. The ranges have entries
149ad60559bSWolfgang Pieb# in the offset table. We use the empty range list so we can test
150ad60559bSWolfgang Pieb# DW_FORM_rnglistx with an index other than 0.
151d840e545SFangrui Song        .section .debug_rnglists.dwo,"e",@progbits
152ad60559bSWolfgang Pieb        .long Rnglist_Table0_dwo_end - Rnglist_Table0_dwo   # table length
153ad60559bSWolfgang PiebRnglist_Table0_dwo:
154ad60559bSWolfgang Pieb        .short 5                                    # version
155ad60559bSWolfgang Pieb        .byte 4                                     # address size
156ad60559bSWolfgang Pieb        .byte 0                                     # segment selector size
157ad60559bSWolfgang Pieb        .long 2                                     # offset entry count
158ad60559bSWolfgang PiebRnglist_Table0_base_dwo:
159ad60559bSWolfgang Pieb# 2 offset entries which can be used by DW_FORM_rnglistx.
160ad60559bSWolfgang Pieb        .long Rnglist_Table0_Rnglist0_dwo - Rnglist_Table0_base_dwo
161ad60559bSWolfgang Pieb        .long Rnglist_Table0_Rnglist1_dwo - Rnglist_Table0_base_dwo
162ad60559bSWolfgang PiebRnglist_Table0_Rnglist0_dwo:
163ad60559bSWolfgang Pieb        .byte 0                                     # DW_RLE_start_end
164ad60559bSWolfgang PiebRnglist_Table0_Rnglist1_dwo:
165ad60559bSWolfgang Pieb        .byte 5                                     # DW_RLE_base_address
166ad60559bSWolfgang Pieb        .long Range0_start - .text
167ad60559bSWolfgang Pieb        .byte 4                                     # DW_RLE_offset_pair
168ad60559bSWolfgang Pieb        .uleb128 Range1_start - Range0_start
169ad60559bSWolfgang Pieb        .uleb128 Range1_end - Range0_start
170ad60559bSWolfgang Pieb        .byte 0                                     # DW_RLE_end_of_list
171ad60559bSWolfgang PiebRnglist_Table0_dwo_end:
172ad60559bSWolfgang Pieb
173ad60559bSWolfgang Pieb.text
174ad60559bSWolfgang Pieb        .space 20
175ad60559bSWolfgang PiebRange0_start:               # Range0: 0x14 - 0x1c
176ad60559bSWolfgang Pieb        .space 10
177ad60559bSWolfgang PiebRange0_end:
178ad60559bSWolfgang Pieb        .space 12
179ad60559bSWolfgang PiebRange1_start:               # Range1: 0x2a - 0x34
180ad60559bSWolfgang Pieb        .space 10
181ad60559bSWolfgang PiebRange1_end:
182ad60559bSWolfgang Pieb
183ad60559bSWolfgang Pieb# CHECK:      .debug_info contents:
184ad60559bSWolfgang Pieb# CHECK:      Compile Unit:
185ad60559bSWolfgang Pieb# CHECK-NOT:  Compile Unit:
186ad60559bSWolfgang Pieb# CHECK:      DW_TAG_compile_unit
187ad60559bSWolfgang Pieb# CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset]  (0x0000000c)
188ad60559bSWolfgang Pieb# CHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000014
189ad60559bSWolfgang Pieb# CHECK-NEXT: [0x00000014, 0x0000001e) ".text"
190ad60559bSWolfgang Pieb# CHECK-NEXT: [0x0000002a, 0x00000034) ".text")
191ad60559bSWolfgang Pieb
192ad60559bSWolfgang Pieb# CHECK:      Compile Unit:
193ad60559bSWolfgang Pieb# CHECK-NOT:  Compile Unit:
194ad60559bSWolfgang Pieb# CHECK:      DW_TAG_compile_unit
195ad60559bSWolfgang Pieb# CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset]  (0x0000000c)
1964ee76a92SPavel Labath# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000024
197ad60559bSWolfgang Pieb# CHECK-NEXT: [0x0000002a, 0x00000034) ".text")
198ad60559bSWolfgang Pieb
199ad60559bSWolfgang Pieb# CHECK:      .debug_info.dwo contents:
200ad60559bSWolfgang Pieb# CHECK:      Compile Unit:
201ad60559bSWolfgang Pieb# CHECK-NOT:  contents:
202ad60559bSWolfgang Pieb# CHECK:      DW_TAG_compile_unit
2034ee76a92SPavel Labath# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000015
204ad60559bSWolfgang Pieb# CHECK-NEXT: [0x0000002a, 0x00000034))
205ad60559bSWolfgang Pieb
20661d8c8d9SWolfgang Pieb#ERR: error: decoding address ranges: invalid range list offset 0xfa0
207