]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/DebugInfo/X86/dwarfdump-rnglists.s
Vendor import of llvm trunk r338150:
[FreeBSD/FreeBSD.git] / test / DebugInfo / X86 / dwarfdump-rnglists.s
1 # RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o
2 # RUN: llvm-dwarfdump -v -debug-info %t.o 2> %t.err | FileCheck %s
3 # RUN: FileCheck %s --input-file %t.err --check-prefix=ERR
4 # RUN: llvm-dwarfdump -lookup 10 %t.o 2> %t2.err
5 # RUN: FileCheck %s --input-file %t2.err --check-prefix=ERR
6
7 # Test object to verify dwarfdump handles v5 range lists.
8 # We use very simplified compile unit dies.
9 # There are 2 full CUs with DW_AT_rnglists_base, one with a DW_AT_ranges
10 # attribute using DW_FORM_sec_offset, the other with DW_AT_ranges using
11 # DW_FORM_rnglistx.
12
13         .section .debug_abbrev,"",@progbits
14         .byte 0x01  # Abbrev code
15         .byte 0x11  # DW_TAG_compile_unit
16         .byte 0x00  # DW_CHILDREN_no
17         .byte 0x74  # DW_AT_rnglists_base
18         .byte 0x17  # DW_FORM_sec_offset
19         .byte 0x55  # DW_AT_ranges
20         .byte 0x17  # DW_FORM_sec_offset
21         .byte 0x00  # EOM(1)
22         .byte 0x00  # EOM(2)
23         .byte 0x02  # Abbrev code
24         .byte 0x11  # DW_TAG_compile_unit
25         .byte 0x00  # DW_CHILDREN_no
26         .byte 0x74  # DW_AT_rnglists_base
27         .byte 0x17  # DW_FORM_sec_offset
28         .byte 0x55  # DW_AT_ranges
29         .byte 0x23  # DW_FORM_rnglistx
30         .byte 0x00  # EOM(1)
31         .byte 0x00  # EOM(2)
32         .byte 0x00  # EOM(3)
33
34 # The split CU uses DW_FORM_rnglistx (the only correct option).
35 # There is no DW_AT_rnglists_base in split units.
36         .section .debug_abbrev.dwo,"",@progbits
37         .byte 0x01  # Abbrev code
38         .byte 0x11  # DW_TAG_compile_unit
39         .byte 0x00  # DW_CHILDREN_no
40         .byte 0x55  # DW_AT_ranges
41         .byte 0x23  # DW_FORM_rnglistx
42         .byte 0x00  # EOM(1)
43         .byte 0x00  # EOM(2)
44         .byte 0x00  # EOM(3)
45         
46         .section .debug_info,"",@progbits
47         .long  CU1_5_end-CU1_5_version  # Length of Unit
48 CU1_5_version:
49         .short 5               # DWARF version number
50         .byte 1                # DWARF Unit Type
51         .byte 4                # Address Size (in bytes)
52         .long .debug_abbrev    # Offset Into Abbrev. Section
53 # The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
54         .byte 1                # Abbreviation code
55         .long Rnglist_Table0_base     # DW_AT_rnglists_base
56         .long Rnglist_Table0_Rnglist0 # DW_AT_ranges
57         .byte 0 # NULL
58         .byte 0 # NULL
59 CU1_5_end:
60
61         .long  CU2_5_end-CU2_5_version  # Length of Unit
62 CU2_5_version:
63         .short 5               # DWARF version number
64         .byte 1                # DWARF Unit Type
65         .byte 4                # Address Size (in bytes)
66         .long .debug_abbrev    # Offset Into Abbrev. Section
67 # The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
68         .byte 2                # Abbreviation code
69         .long Rnglist_Table0_base   # DW_AT_rnglists_base
70         .uleb128 1             # DW_AT_ranges
71         .byte 0                # NULL
72 CU2_5_end:
73 # A CU with an invalid DW_AT_rnglists_base attribute
74         .long  CU3_5_end-CU3_5_version  # Length of Unit
75 CU3_5_version:
76         .short 5               # DWARF version number
77         .byte 1                # DWARF Unit Type
78         .byte 4                # Address Size (in bytes)
79         .long .debug_abbrev    # Offset Into Abbrev. Section
80 # The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
81         .byte 2                # Abbreviation code
82         .long 0x8              # DW_AT_rnglists_base
83         .long 0                # DW_AT_ranges
84         .byte 0                # NULL
85 CU3_5_end:
86 # A CU DIE with an incorrect DW_AT_ranges attribute
87         .long  CU4_5_end-CU4_5_version  # Length of Unit
88 CU4_5_version:
89         .short 5               # DWARF version number
90         .byte 1                # DWARF Unit Type
91         .byte 4                # Address Size (in bytes)
92         .long .debug_abbrev    # Offset Into Abbrev. Section
93 # The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
94         .byte 1                # Abbreviation code
95         .long Rnglist_Table0_base   # DW_AT_rnglists_base
96         .long 4000             # DW_AT_ranges
97         .byte 0                # NULL
98 CU4_5_end:
99
100         .section .debug_info.dwo,"",@progbits
101
102 # DWARF v5 split CU header.
103         .long  CU_split_5_end-CU_split_5_version  # Length of Unit
104 CU_split_5_version:
105         .short 5               # DWARF version number
106         .byte 5                # DWARF Unit Type
107         .byte 4                # Address Size (in bytes)
108         .long 0                # Offset Into Abbrev Section
109 # The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
110         .byte 1                # Abbreviation code
111         .uleb128 1             # DW_AT_ranges
112         .byte 0                # NULL
113 CU_split_5_end:
114
115         .section .debug_rnglists,"",@progbits
116 # A rnglist table with 2 range lists. The first one uses DW_RLE_start_end
117 # and DW_RLE_start_length. The second one uses DW_RLE_base_address and
118 # DW_RLE_offset_pair. The range lists have entries in the offset table.
119         .long Rnglist_Table0_end - Rnglist_Table0   # table length
120 Rnglist_Table0:
121         .short 5                                    # version
122         .byte 4                                     # address size
123         .byte 0                                     # segment selector size
124         .long 2                                     # offset entry count
125 Rnglist_Table0_base:
126 # 2 offset entries which can be used by DW_FORM_rnglistx.
127         .long Rnglist_Table0_Rnglist0 - Rnglist_Table0_base
128         .long Rnglist_Table0_Rnglist1 - Rnglist_Table0_base
129 Rnglist_Table0_Rnglist0:
130         .byte 6                                     # DW_RLE_start_end
131         .long Range0_start
132         .long Range0_end
133         .byte 7                                     # DW_RLE_start_length
134         .long Range1_start
135         .uleb128 Range1_end - Range1_start 
136         .byte 0                                     # DW_RLE_end_of_list
137 Rnglist_Table0_Rnglist1:
138         .byte 5                                     # DW_RLE_base_address
139         .long Range0_start
140         .byte 4                                     # DW_RLE_offset_pair
141         .uleb128 Range1_start - Range0_start
142         .uleb128 Range1_end - Range0_start
143         .byte 0                                     # DW_RLE_end_of_list
144 Rnglist_Table0_end:
145
146 # A rnglist table for the split unit with an empty rangelist and one that
147 # uses DW_RLE_base_address and DW_RLE_offset_pair. The ranges have entries
148 # in the offset table. We use the empty range list so we can test 
149 # DW_FORM_rnglistx with an index other than 0.
150         .section .debug_rnglists.dwo,"",@progbits
151         .long Rnglist_Table0_dwo_end - Rnglist_Table0_dwo   # table length
152 Rnglist_Table0_dwo:
153         .short 5                                    # version
154         .byte 4                                     # address size
155         .byte 0                                     # segment selector size
156         .long 2                                     # offset entry count
157 Rnglist_Table0_base_dwo:
158 # 2 offset entries which can be used by DW_FORM_rnglistx.
159         .long Rnglist_Table0_Rnglist0_dwo - Rnglist_Table0_base_dwo
160         .long Rnglist_Table0_Rnglist1_dwo - Rnglist_Table0_base_dwo
161 Rnglist_Table0_Rnglist0_dwo:
162         .byte 0                                     # DW_RLE_start_end
163 Rnglist_Table0_Rnglist1_dwo:
164         .byte 5                                     # DW_RLE_base_address
165         .long Range0_start - .text
166         .byte 4                                     # DW_RLE_offset_pair
167         .uleb128 Range1_start - Range0_start
168         .uleb128 Range1_end - Range0_start
169         .byte 0                                     # DW_RLE_end_of_list
170 Rnglist_Table0_dwo_end:
171
172 .text
173         .space 20
174 Range0_start:               # Range0: 0x14 - 0x1c
175         .space 10
176 Range0_end:
177         .space 12
178 Range1_start:               # Range1: 0x2a - 0x34
179         .space 10
180 Range1_end:
181
182 # CHECK:      .debug_info contents:
183 # CHECK:      Compile Unit: 
184 # CHECK-NOT:  Compile Unit:
185 # CHECK:      DW_TAG_compile_unit
186 # CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset]  (0x0000000c)
187 # CHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000014
188 # CHECK-NEXT: [0x00000014, 0x0000001e) ".text"
189 # CHECK-NEXT: [0x0000002a, 0x00000034) ".text")
190
191 # CHECK:      Compile Unit:
192 # CHECK-NOT:  Compile Unit:
193 # CHECK:      DW_TAG_compile_unit
194 # CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset]  (0x0000000c)
195 # CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000018
196 # CHECK-NEXT: [0x0000002a, 0x00000034) ".text")
197
198 # CHECK:      .debug_info.dwo contents:
199 # CHECK:      Compile Unit:
200 # CHECK-NOT:  contents:
201 # CHECK:      DW_TAG_compile_unit
202 # CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000009
203 # CHECK-NEXT: [0x0000002a, 0x00000034))
204
205 #ERR: error: parsing a range list table: Did not detect a valid range list table with base = 0x8
206 #ERR: error: decoding address ranges: missing or invalid range list table
207 #ERR: error: decoding address ranges: invalid range list offset 0xfa0