xref: /llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/dwarf5_tu_index_abbrev_offset.s (revision 8a64d80a959bf2844df33f9112e456f33de7b468)
1## This test checks that lldb uses the abbrev_offset from .debug_tu_index when
2## reading TUs in the .debug_info section of a DWARF v5 DWP.
3##
4## The assembly here is, essentially, slightly hand-reduced output from
5## `clang -gsplit-dwarf -gdwarf-5 -fdebug-types-section`, with a manually-added
6## .debug_cu_index and a .debug_tu_index to create a DWP, and a twist: abbrevs
7## from the TU are listed *AFTER* abbrevs from the CU so that they don't begin
8## at offset 0.
9
10# RUN: llvm-mc --filetype=obj --triple x86_64 %s -o %t --defsym MAIN=1
11# RUN: llvm-mc --filetype=obj --triple x86_64 %s -o %t.dwp
12# RUN: %lldb %t -o "image lookup -t t1" -b | FileCheck %s
13# CHECK: struct t1
14
15.ifdef MAIN
16## Main file
17	.text
18	.globl	main                            # -- Begin function main
19main:                                   # @main
20.Lfunc_begin0:
21	pushq	%rbp
22	movq	%rsp, %rbp
23	xorl	%eax, %eax
24	popq	%rbp
25	retq
26.Lfunc_end0:
27                                        # -- End function
28	.section	.debug_abbrev,"",@progbits
29	.byte	1                               # Abbreviation Code
30	.byte	74                              # DW_TAG_skeleton_unit
31	.byte	0                               # DW_CHILDREN_no
32	.byte	118                             # DW_AT_dwo_name
33	.byte	8                               # DW_FORM_string
34	.byte	17                              # DW_AT_low_pc
35	.byte	27                              # DW_FORM_addrx
36	.byte	18                              # DW_AT_high_pc
37	.byte	6                               # DW_FORM_data4
38	.byte	115                             # DW_AT_addr_base
39	.byte	23                              # DW_FORM_sec_offset
40	.byte	0                               # EOM(1)
41	.byte	0                               # EOM(2)
42	.byte	0                               # EOM(3)
43
44
45	.section	.debug_info,"",@progbits
46.Lcu_begin0:
47	.long	.Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
48.Ldebug_info_start0:
49	.short	5                             # DWARF version number
50	.byte	4                               # DWARF Unit Type
51	.byte	8                               # Address Size (in bytes)
52	.long	.debug_abbrev                   # Offset Into Abbrev. Section
53	.quad	-8218585293556409984            # dwo_id
54	.byte	1                               # Abbrev [1] 0x14:0x14 DW_TAG_skeleton_unit
55	.asciz "hello.dwo"                    # DW_AT_dwo_name
56	.byte	0                               # DW_AT_low_pc
57	.long	.Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
58	.long	.Laddr_table_base0              # DW_AT_addr_base
59.Ldebug_info_end0:
60
61
62	.section	.debug_addr,"",@progbits
63	.long	.Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
64.Ldebug_addr_start0:
65	.short	5                               # DWARF version number
66	.byte	8                               # Address size
67	.byte	0                               # Segment selector size
68.Laddr_table_base0:
69	.quad	.Lfunc_begin0
70.Ldebug_addr_end0:
71
72
73.else
74## DWP file
75	.section	.debug_info.dwo,"e",@progbits
76	.long	.Ldebug_info_dwo_end0-.Ldebug_info_dwo_start0 # Length of Unit
77.Ldebug_info_dwo_start0:
78	.short	5                               # DWARF version number
79	.byte	6                               # DWARF Unit Type
80	.byte	8                               # Address Size (in bytes)
81	.long	0                               # Offset Into Abbrev. Section
82	.quad	-4149699470930386446            # Type Signature
83	.long	31                              # Type DIE Offset
84	.byte	1                               # Abbrev [1] 0x18:0xe DW_TAG_type_unit
85	.short	33                              # DW_AT_language
86	.long	0                               # DW_AT_stmt_list
87	.byte	2                               # Abbrev [2] 0x1f:0x6 DW_TAG_structure_type
88	.byte	5                               # DW_AT_calling_convention
89	.byte	3                               # DW_AT_name
90	.byte	1                               # DW_AT_byte_size
91	.byte	0                               # DW_AT_decl_file
92	.byte	1                               # DW_AT_decl_line
93	.byte	0                               # End Of Children Mark
94.Ldebug_info_dwo_end0:
95	.long	.Ldebug_info_dwo_end1-.Ldebug_info_dwo_start1 # Length of Unit
96.Ldebug_info_dwo_start1:
97	.short	5                               # DWARF version number
98	.byte	5                               # DWARF Unit Type
99	.byte	8                               # Address Size (in bytes)
100	.long	0                               # Offset Into Abbrev. Section
101	.quad	-8218585293556409984
102	.byte	3                               # Abbrev [3] 0x14:0x2f DW_TAG_compile_unit
103	.byte	4                               # DW_AT_producer
104	.short	33                              # DW_AT_language
105	.byte	5                               # DW_AT_name
106	.byte	6                               # DW_AT_dwo_name
107	.byte	4                               # Abbrev [4] 0x1a:0x1b DW_TAG_subprogram
108	.byte	0                               # DW_AT_low_pc
109	.long	8                               # DW_AT_high_pc
110	.byte	1                               # DW_AT_frame_base
111	.byte	86
112	.byte	0                               # DW_AT_name
113	.byte	0                               # DW_AT_decl_file
114	.byte	2                               # DW_AT_decl_line
115	.long	53                              # DW_AT_type
116                                        # DW_AT_external
117	.byte	5                               # Abbrev [5] 0x29:0xb DW_TAG_variable
118	.byte	2                               # DW_AT_location
119	.byte	145
120	.byte	120
121	.byte	2                               # DW_AT_name
122	.byte	0                               # DW_AT_decl_file
123	.byte	3                               # DW_AT_decl_line
124	.long	57                              # DW_AT_type
125	.byte	0                               # End Of Children Mark
126	.byte	6                               # Abbrev [6] 0x35:0x4 DW_TAG_base_type
127	.byte	1                               # DW_AT_name
128	.byte	5                               # DW_AT_encoding
129	.byte	4                               # DW_AT_byte_size
130	.byte	7                               # Abbrev [7] 0x39:0x9 DW_TAG_structure_type
131                                        # DW_AT_declaration
132	.quad	-4149699470930386446            # DW_AT_signature
133	.byte	0                               # End Of Children Mark
134.Ldebug_info_dwo_end1:
135
136
137
138	.section	.debug_str.dwo,"eMS",@progbits,1
139.Linfo_string0:
140	.asciz	"main"
141.Linfo_string1:
142	.asciz	"int"
143.Linfo_string2:
144	.asciz	"v1"
145.Linfo_string3:
146	.asciz	"t1"
147.Linfo_string4:
148	.asciz	"hand-tuned clang output"
149.Linfo_string5:
150	.asciz	"test.cc"
151.Linfo_string6:
152	.asciz	"test.dwo"
153
154
155	.section	.debug_str_offsets.dwo,"e",@progbits
156	.long	32                              # Length of String Offsets Set
157	.short	5
158	.short	0
159
160	.long	.Linfo_string0-.debug_str.dwo
161	.long	.Linfo_string1-.debug_str.dwo
162	.long	.Linfo_string2-.debug_str.dwo
163	.long	.Linfo_string3-.debug_str.dwo
164	.long	.Linfo_string4-.debug_str.dwo
165	.long	.Linfo_string5-.debug_str.dwo
166	.long	.Linfo_string6-.debug_str.dwo
167.Lstr_offsets_end:
168
169	.section	.debug_abbrev.dwo,"e",@progbits
170.Ldebug_cu_abbrev_begin:
171	.byte	3                               # Abbreviation Code
172	.byte	17                              # DW_TAG_compile_unit
173	.byte	1                               # DW_CHILDREN_yes
174	.byte	37                              # DW_AT_producer
175	.byte	37                              # DW_FORM_strx1
176	.byte	19                              # DW_AT_language
177	.byte	5                               # DW_FORM_data2
178	.byte	3                               # DW_AT_name
179	.byte	37                              # DW_FORM_strx1
180	.byte	118                             # DW_AT_dwo_name
181	.byte	37                              # DW_FORM_strx1
182	.byte	0                               # EOM(1)
183	.byte	0                               # EOM(2)
184	.byte	4                               # Abbreviation Code
185	.byte	46                              # DW_TAG_subprogram
186	.byte	1                               # DW_CHILDREN_yes
187	.byte	17                              # DW_AT_low_pc
188	.byte	27                              # DW_FORM_addrx
189	.byte	18                              # DW_AT_high_pc
190	.byte	6                               # DW_FORM_data4
191	.byte	64                              # DW_AT_frame_base
192	.byte	24                              # DW_FORM_exprloc
193	.byte	3                               # DW_AT_name
194	.byte	37                              # DW_FORM_strx1
195	.byte	58                              # DW_AT_decl_file
196	.byte	11                              # DW_FORM_data1
197	.byte	59                              # DW_AT_decl_line
198	.byte	11                              # DW_FORM_data1
199	.byte	73                              # DW_AT_type
200	.byte	19                              # DW_FORM_ref4
201	.byte	63                              # DW_AT_external
202	.byte	25                              # DW_FORM_flag_present
203	.byte	0                               # EOM(1)
204	.byte	0                               # EOM(2)
205	.byte	5                               # Abbreviation Code
206	.byte	52                              # DW_TAG_variable
207	.byte	0                               # DW_CHILDREN_no
208	.byte	2                               # DW_AT_location
209	.byte	24                              # DW_FORM_exprloc
210	.byte	3                               # DW_AT_name
211	.byte	37                              # DW_FORM_strx1
212	.byte	58                              # DW_AT_decl_file
213	.byte	11                              # DW_FORM_data1
214	.byte	59                              # DW_AT_decl_line
215	.byte	11                              # DW_FORM_data1
216	.byte	73                              # DW_AT_type
217	.byte	19                              # DW_FORM_ref4
218	.byte	0                               # EOM(1)
219	.byte	0                               # EOM(2)
220	.byte	6                               # Abbreviation Code
221	.byte	36                              # DW_TAG_base_type
222	.byte	0                               # DW_CHILDREN_no
223	.byte	3                               # DW_AT_name
224	.byte	37                              # DW_FORM_strx1
225	.byte	62                              # DW_AT_encoding
226	.byte	11                              # DW_FORM_data1
227	.byte	11                              # DW_AT_byte_size
228	.byte	11                              # DW_FORM_data1
229	.byte	0                               # EOM(1)
230	.byte	0                               # EOM(2)
231	.byte	7                               # Abbreviation Code
232	.byte	19                              # DW_TAG_structure_type
233	.byte	0                               # DW_CHILDREN_no
234	.byte	60                              # DW_AT_declaration
235	.byte	25                              # DW_FORM_flag_present
236	.byte	105                             # DW_AT_signature
237	.byte	32                              # DW_FORM_ref_sig8
238	.byte	0                               # EOM(1)
239	.byte	0                               # EOM(2)
240	.byte	0                               # EOM(3)
241.Ldebug_cu_abbrev_end:
242.Ldebug_tu_abbrev_begin:
243  .byte	1                               # Abbreviation Code
244	.byte	65                              # DW_TAG_type_unit
245	.byte	1                               # DW_CHILDREN_yes
246	.byte	19                              # DW_AT_language
247	.byte	5                               # DW_FORM_data2
248	.byte	16                              # DW_AT_stmt_list
249	.byte	23                              # DW_FORM_sec_offset
250	.byte	0                               # EOM(1)
251	.byte	0                               # EOM(2)
252	.byte	2                               # Abbreviation Code
253	.byte	19                              # DW_TAG_structure_type
254	.byte	0                               # DW_CHILDREN_no
255	.byte	54                              # DW_AT_calling_convention
256	.byte	11                              # DW_FORM_data1
257	.byte	3                               # DW_AT_name
258	.byte	37                              # DW_FORM_strx1
259	.byte	11                              # DW_AT_byte_size
260	.byte	11                              # DW_FORM_data1
261	.byte	58                              # DW_AT_decl_file
262	.byte	11                              # DW_FORM_data1
263	.byte	59                              # DW_AT_decl_line
264	.byte	11                              # DW_FORM_data1
265	.byte	0                               # EOM(1)
266	.byte	0                               # EOM(2)
267	.byte	0                               # EOM(3)
268.Ldebug_tu_abbrev_end:
269.Ldebug_abbrev_dwo_end:
270
271.section .debug_tu_index,"",@progbits
272.short 5  # DWARF version number
273.short 0  # Reserved
274.long  3  # Section count
275.long  1  # Unit count
276.long  2 # Slot count
277
278.quad  -4149699470930386446, 0 # Hash table
279.long  1, 0 # Index table
280
281## Table header
282.long 1   # DW_SECT_INFO
283.long 3   # DW_SECT_ABBREV
284.long 6   # DW_SECT_STR_OFFSETS
285
286## Offsets
287.long 0   # offset into .debug_info.dwo
288.long .Ldebug_tu_abbrev_begin - .debug_abbrev.dwo   # offset into .debug_abbrev.dwo
289.long 0   # offset into .debug_str_offsets.dwo
290
291## Sizes
292.long .Ldebug_info_dwo_end0 - .debug_info.dwo
293.long .Ldebug_tu_abbrev_end - .Ldebug_tu_abbrev_begin
294.long .Lstr_offsets_end - .debug_str_offsets.dwo
295
296
297.section .debug_cu_index,"",@progbits
298.short 5  # DWARF version number
299.short 0  # Reserved
300.long  3  # Section count
301.long  1  # Unit count
302.long  2 # Slot count
303
304.quad  -8218585293556409984, 0 # Hash table
305.long  1, 0 # Index table
306
307## Table header
308.long 1   # DW_SECT_INFO
309.long 3   # DW_SECT_ABBREV
310.long 6   # DW_SECT_STR_OFFSETS
311
312## Offsets
313.long .Ldebug_info_dwo_end0 - .debug_info.dwo   # offset into .debug_info.dwo
314.long .Ldebug_cu_abbrev_begin - .debug_abbrev.dwo  # offset into .debug_abbrev.dwo
315.long 0   # offset into .debug_str_offsets.dwo
316
317## Sizes
318.long .Ldebug_info_dwo_end1 - .Ldebug_info_dwo_end0
319.long .Ldebug_cu_abbrev_end - .Ldebug_cu_abbrev_begin
320.long .Lstr_offsets_end - .debug_str_offsets.dwo
321
322
323.endif
324