1 ## Test that yaml2obj and obj2yaml can create mach-o files with valid
2 ## __debug_ranges section.
4 ## The DWARF should end up looking like:
6 ## 0x0000000b: DW_TAG_compile_unit
7 ## DW_AT_name ("/tmp/main.c")
8 ## DW_AT_language (DW_LANG_C_plus_plus)
9 ## DW_AT_low_pc (0x0000000000000000)
10 ## DW_AT_ranges (0x00000000
11 ## [0x0000000000000000, 0x0000000000000020)
12 ## [0x0000000000000000, 0x0000000000000030)
13 ## [0x0000000000001000, 0x0000000000002000))
14 ## DW_AT_stmt_list (0x00000000)
16 ## 0x00000022: DW_TAG_subprogram
17 ## DW_AT_name ("stripped1")
18 ## DW_AT_low_pc (0x0000000000000000)
19 ## DW_AT_high_pc (0x0000000000000020)
21 ## 0x00000033: DW_TAG_subprogram
22 ## DW_AT_name ("stripped2")
23 ## DW_AT_low_pc (0x0000000000000000)
24 ## DW_AT_high_pc (0x0000000000000030)
26 ## 0x00000048: DW_TAG_subprogram
27 ## DW_AT_name ("main")
28 ## DW_AT_low_pc (0x0000000000001000)
29 ## DW_AT_high_pc (0x0000000000002000)
33 # RUN: yaml2obj %s > %t
34 # RUN: llvm-dwarfdump %t | FileCheck %s
35 # RUN: obj2yaml %t | FileCheck --check-prefix=YAML %s
37 # CHECK: DW_AT_ranges (0x00000000
38 # CHECK-NEXT: [0x0000000000000000, 0x0000000000000020)
39 # CHECK-NEXT: [0x0000000000000000, 0x0000000000000030)
40 # CHECK-NEXT: [0x0000000000001000, 0x0000000000002000))
42 # YAML: - sectname: __debug_ranges
43 # YAML-NEXT: segname: __DWARF
44 # YAML-NEXT: addr: 0x7A
46 # YAML-NEXT: offset: 0x28A
49 # YAML-NEXT: - Offset: 0x0
50 # YAML-NEXT: AddrSize: 0x8
52 # YAML-NEXT: - LowOffset: 0x0
53 # YAML-NEXT: HighOffset: 0x20
54 # YAML-NEXT: - LowOffset: 0x0
55 # YAML-NEXT: HighOffset: 0x30
56 # YAML-NEXT: - LowOffset: 0xFFFFFFFFFFFFFFFF
57 # YAML-NEXT: HighOffset: 0x1000
58 # YAML-NEXT: - LowOffset: 0x0
59 # YAML-NEXT: HighOffset: 0x1000
65 cpusubtype: 0x00000003
84 - sectname: __debug_abbrev
86 addr: 0x0000000000000000
96 - sectname: __debug_info
98 addr: 0x0000000000000024
105 reserved1: 0x00000000
106 reserved2: 0x00000000
107 reserved3: 0x00000000
108 - sectname: __debug_ranges
110 addr: 0x000000000000007A
117 reserved1: 0x00000000
118 reserved2: 0x00000000
119 reserved3: 0x00000000
120 - sectname: __debug_str
122 addr: 0x00000000000000CA
129 reserved1: 0x00000000
130 reserved2: 0x00000000
131 reserved3: 0x00000000
138 - cmd: LC_BUILD_VERSION
147 - cmd: LC_DATA_IN_CODE
170 Tag: DW_TAG_compile_unit
171 Children: DW_CHILDREN_yes
173 - Attribute: DW_AT_name
175 - Attribute: DW_AT_language
177 - Attribute: DW_AT_low_pc
179 - Attribute: DW_AT_ranges
180 Form: DW_FORM_sec_offset
182 Tag: DW_TAG_subprogram
183 Children: DW_CHILDREN_no
185 - Attribute: DW_AT_name
187 - Attribute: DW_AT_low_pc
189 - Attribute: DW_AT_high_pc
192 Tag: DW_TAG_subprogram
193 Children: DW_CHILDREN_no
195 - Attribute: DW_AT_name
197 - Attribute: DW_AT_low_pc
199 - Attribute: DW_AT_high_pc
204 - LowOffset: 0x0000000000000000
205 HighOffset: 0x0000000000000020
206 - LowOffset: 0x0000000000000000
207 HighOffset: 0x0000000000000030
208 - LowOffset: 0xFFFFFFFFFFFFFFFF
209 HighOffset: 0x0000000000001000
210 - LowOffset: 0x0000000000000000
211 HighOffset: 0x0000000000001000
218 - AbbrCode: 0x00000001
220 - Value: 0x0000000000000001
221 - Value: 0x0000000000000004
222 - Value: 0x0000000000000000
223 - Value: 0x0000000000000000
224 - AbbrCode: 0x00000002
226 - Value: 0x000000000000000D
227 - Value: 0x0000000000000000
228 - Value: 0x0000000000000020
229 - AbbrCode: 0x00000003
231 - Value: 0x0000000000000017
232 - Value: 0x0000000000000000
233 - Value: 0x0000000000000030
234 - AbbrCode: 0x00000002
236 - Value: 0x0000000000000021
237 - Value: 0x0000000000001000
238 - Value: 0x0000000000001000
239 - AbbrCode: 0x00000000
243 ## Test generating and dumping an empty __debug_ranges section.
245 # RUN: yaml2obj --docnum=2 %s | obj2yaml | FileCheck %s --check-prefix=EMPTY
248 # EMPTY-NEXT: debug_ranges: []
255 cpusubtype: 0x00000003
274 - sectname: __debug_ranges
283 reserved1: 0x00000000
284 reserved2: 0x00000000
285 reserved3: 0x00000000
286 content: [[CONTENT=<none>]]
288 ## Test generating and dumping a __debug_ranges section whose size isn't a
289 ## multiple of the address size. This test case is to ensure that when the
290 ## parser fails, the content of the __debug_ranges section will be dumped into
291 ## the 'content' entry and the 'debug_ranges' entry will not exist.
293 # RUN: yaml2obj --docnum=2 -DSIZE=3 -DCONTENT='010203' %s | obj2yaml | FileCheck %s --check-prefix=FAILS
297 # FAILS-NEXT: - sectname: __debug_ranges
298 # FAILS-NEXT: segname: __DWARF
299 # FAILS-NEXT: addr: 0x0
300 # FAILS-NEXT: size: 3
301 # FAILS-NEXT: offset: 0x210
302 # FAILS-NEXT: align: 0
303 # FAILS-NEXT: reloff: 0x0
304 # FAILS-NEXT: nreloc: 0
305 # FAILS-NEXT: flags: 0x0
306 # FAILS-NEXT: reserved1: 0x0
307 # FAILS-NEXT: reserved2: 0x0
308 # FAILS-NEXT: reserved3: 0x0
309 # FAILS-NEXT: content: '010203'