xref: /llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/static_scope.s (revision 8a64d80a959bf2844df33f9112e456f33de7b468)
1# Test that the DWARF parser assigns the right scope to the
2# variable `b`, which is `local` and not `static`.
3
4# Original test case (for future reference), compiled with:
5# $ clang-10 -g -Og test.c -o test
6# $ cat test.c
7# volatile int a;
8# main() {
9#   int b = 3;
10#   a;
11# }
12
13# RUN: llvm-mc -triple=x86_64-apple-macosx10.15.0 -filetype=obj %s > %t.o
14# RUN: lldb-test symbols %t.o | FileCheck %s
15
16# CHECK: Variable{{.*}}, name = "b", type = {{.*}} (int), scope = local
17
18	.section	__TEXT,__text,regular,pure_instructions
19	.macosx_version_min 10, 15
20	.file	1 "/Users/davide/work/build/bin" "a.c"
21	.globl	_main                   ## -- Begin function main
22	.p2align	4, 0x90
23_main:                                  ## @main
24Lfunc_begin0:
25	.loc	1 2 0                   ## a.c:2:0
26	.cfi_startproc
27## %bb.0:
28	pushq	%rbp
29	.cfi_def_cfa_offset 16
30	.cfi_offset %rbp, -16
31	movq	%rsp, %rbp
32	.cfi_def_cfa_register %rbp
33Ltmp0:
34	##DEBUG_VALUE: b <- 3
35	.loc	1 5 9 prologue_end      ## a.c:5:9
36	movl	_a(%rip), %eax
37Ltmp1:
38	.loc	1 7 5                   ## a.c:7:5
39	xorl	%eax, %eax
40	popq	%rbp
41	retq
42Ltmp2:
43Lfunc_end0:
44	.cfi_endproc
45                                        ## -- End function
46	.globl	_a                      ## @a
47.zerofill __DATA,__common,_a,4,2
48	.section	__DWARF,__debug_abbrev,regular,debug
49Lsection_abbrev:
50	.byte	1                       ## Abbreviation Code
51	.byte	17                      ## DW_TAG_compile_unit
52	.byte	1                       ## DW_CHILDREN_yes
53	.byte	37                      ## DW_AT_producer
54	.byte	14                      ## DW_FORM_strp
55	.byte	19                      ## DW_AT_language
56	.byte	5                       ## DW_FORM_data2
57	.byte	3                       ## DW_AT_name
58	.byte	14                      ## DW_FORM_strp
59	.ascii	"\202|"                 ## DW_AT_LLVM_sysroot
60	.byte	14                      ## DW_FORM_strp
61	.byte	16                      ## DW_AT_stmt_list
62	.byte	23                      ## DW_FORM_sec_offset
63	.byte	27                      ## DW_AT_comp_dir
64	.byte	14                      ## DW_FORM_strp
65	.ascii	"\341\177"              ## DW_AT_APPLE_optimized
66	.byte	25                      ## DW_FORM_flag_present
67	.byte	17                      ## DW_AT_low_pc
68	.byte	1                       ## DW_FORM_addr
69	.byte	18                      ## DW_AT_high_pc
70	.byte	6                       ## DW_FORM_data4
71	.byte	0                       ## EOM(1)
72	.byte	0                       ## EOM(2)
73	.byte	2                       ## Abbreviation Code
74	.byte	52                      ## DW_TAG_variable
75	.byte	0                       ## DW_CHILDREN_no
76	.byte	3                       ## DW_AT_name
77	.byte	14                      ## DW_FORM_strp
78	.byte	73                      ## DW_AT_type
79	.byte	19                      ## DW_FORM_ref4
80	.byte	63                      ## DW_AT_external
81	.byte	25                      ## DW_FORM_flag_present
82	.byte	58                      ## DW_AT_decl_file
83	.byte	11                      ## DW_FORM_data1
84	.byte	59                      ## DW_AT_decl_line
85	.byte	11                      ## DW_FORM_data1
86	.byte	2                       ## DW_AT_location
87	.byte	24                      ## DW_FORM_exprloc
88	.byte	0                       ## EOM(1)
89	.byte	0                       ## EOM(2)
90	.byte	3                       ## Abbreviation Code
91	.byte	53                      ## DW_TAG_volatile_type
92	.byte	0                       ## DW_CHILDREN_no
93	.byte	73                      ## DW_AT_type
94	.byte	19                      ## DW_FORM_ref4
95	.byte	0                       ## EOM(1)
96	.byte	0                       ## EOM(2)
97	.byte	4                       ## Abbreviation Code
98	.byte	36                      ## DW_TAG_base_type
99	.byte	0                       ## DW_CHILDREN_no
100	.byte	3                       ## DW_AT_name
101	.byte	14                      ## DW_FORM_strp
102	.byte	62                      ## DW_AT_encoding
103	.byte	11                      ## DW_FORM_data1
104	.byte	11                      ## DW_AT_byte_size
105	.byte	11                      ## DW_FORM_data1
106	.byte	0                       ## EOM(1)
107	.byte	0                       ## EOM(2)
108	.byte	5                       ## Abbreviation Code
109	.byte	46                      ## DW_TAG_subprogram
110	.byte	1                       ## DW_CHILDREN_yes
111	.byte	17                      ## DW_AT_low_pc
112	.byte	1                       ## DW_FORM_addr
113	.byte	18                      ## DW_AT_high_pc
114	.byte	6                       ## DW_FORM_data4
115	.byte	64                      ## DW_AT_frame_base
116	.byte	24                      ## DW_FORM_exprloc
117	.byte	122                     ## DW_AT_call_all_calls
118	.byte	25                      ## DW_FORM_flag_present
119	.byte	3                       ## DW_AT_name
120	.byte	14                      ## DW_FORM_strp
121	.byte	58                      ## DW_AT_decl_file
122	.byte	11                      ## DW_FORM_data1
123	.byte	59                      ## DW_AT_decl_line
124	.byte	11                      ## DW_FORM_data1
125	.byte	73                      ## DW_AT_type
126	.byte	19                      ## DW_FORM_ref4
127	.byte	63                      ## DW_AT_external
128	.byte	25                      ## DW_FORM_flag_present
129	.ascii	"\341\177"              ## DW_AT_APPLE_optimized
130	.byte	25                      ## DW_FORM_flag_present
131	.byte	0                       ## EOM(1)
132	.byte	0                       ## EOM(2)
133	.byte	6                       ## Abbreviation Code
134	.byte	11                      ## DW_TAG_lexical_block
135	.byte	1                       ## DW_CHILDREN_yes
136	.byte	17                      ## DW_AT_low_pc
137	.byte	1                       ## DW_FORM_addr
138	.byte	18                      ## DW_AT_high_pc
139	.byte	6                       ## DW_FORM_data4
140	.byte	0                       ## EOM(1)
141	.byte	0                       ## EOM(2)
142	.byte	7                       ## Abbreviation Code
143	.byte	52                      ## DW_TAG_variable
144	.byte	0                       ## DW_CHILDREN_no
145	.byte	28                      ## DW_AT_const_value
146	.byte	13                      ## DW_FORM_sdata
147	.byte	3                       ## DW_AT_name
148	.byte	14                      ## DW_FORM_strp
149	.byte	58                      ## DW_AT_decl_file
150	.byte	11                      ## DW_FORM_data1
151	.byte	59                      ## DW_AT_decl_line
152	.byte	11                      ## DW_FORM_data1
153	.byte	73                      ## DW_AT_type
154	.byte	19                      ## DW_FORM_ref4
155	.byte	0                       ## EOM(1)
156	.byte	0                       ## EOM(2)
157	.byte	0                       ## EOM(3)
158	.section	__DWARF,__debug_info,regular,debug
159Lsection_info:
160Lcu_begin0:
161.set Lset0, Ldebug_info_end0-Ldebug_info_start0 ## Length of Unit
162	.long	Lset0
163Ldebug_info_start0:
164	.short	4                       ## DWARF version number
165.set Lset1, Lsection_abbrev-Lsection_abbrev ## Offset Into Abbrev. Section
166	.long	Lset1
167	.byte	8                       ## Address Size (in bytes)
168	.byte	1                       ## Abbrev [1] 0xb:0x79 DW_TAG_compile_unit
169	.long	0                       ## DW_AT_producer
170	.short	12                      ## DW_AT_language
171	.long	101                     ## DW_AT_name
172	.long	105                     ## DW_AT_LLVM_sysroot
173.set Lset2, Lline_table_start0-Lsection_line ## DW_AT_stmt_list
174	.long	Lset2
175	.long	107                     ## DW_AT_comp_dir
176                                        ## DW_AT_APPLE_optimized
177	.quad	Lfunc_begin0            ## DW_AT_low_pc
178.set Lset3, Lfunc_end0-Lfunc_begin0     ## DW_AT_high_pc
179	.long	Lset3
180	.byte	2                       ## Abbrev [2] 0x2e:0x15 DW_TAG_variable
181	.long	136                     ## DW_AT_name
182	.long	67                      ## DW_AT_type
183                                        ## DW_AT_external
184	.byte	1                       ## DW_AT_decl_file
185	.byte	1                       ## DW_AT_decl_line
186	.byte	9                       ## DW_AT_location
187	.byte	3
188	.quad	_a
189	.byte	3                       ## Abbrev [3] 0x43:0x5 DW_TAG_volatile_type
190	.long	72                      ## DW_AT_type
191	.byte	4                       ## Abbrev [4] 0x48:0x7 DW_TAG_base_type
192	.long	138                     ## DW_AT_name
193	.byte	5                       ## DW_AT_encoding
194	.byte	4                       ## DW_AT_byte_size
195	.byte	5                       ## Abbrev [5] 0x4f:0x34 DW_TAG_subprogram
196	.quad	Lfunc_begin0            ## DW_AT_low_pc
197.set Lset4, Lfunc_end0-Lfunc_begin0     ## DW_AT_high_pc
198	.long	Lset4
199	.byte	1                       ## DW_AT_frame_base
200	.byte	86
201                                        ## DW_AT_call_all_calls
202	.long	142                     ## DW_AT_name
203	.byte	1                       ## DW_AT_decl_file
204	.byte	2                       ## DW_AT_decl_line
205	.long	72                      ## DW_AT_type
206                                        ## DW_AT_external
207                                        ## DW_AT_APPLE_optimized
208	.byte	6                       ## Abbrev [6] 0x68:0x1a DW_TAG_lexical_block
209	.quad	Ltmp0                   ## DW_AT_low_pc
210.set Lset5, Ltmp1-Ltmp0                 ## DW_AT_high_pc
211	.long	Lset5
212	.byte	7                       ## Abbrev [7] 0x75:0xc DW_TAG_variable
213	.byte	3                       ## DW_AT_const_value
214	.long	147                     ## DW_AT_name
215	.byte	1                       ## DW_AT_decl_file
216	.byte	4                       ## DW_AT_decl_line
217	.long	72                      ## DW_AT_type
218	.byte	0                       ## End Of Children Mark
219	.byte	0                       ## End Of Children Mark
220	.byte	0                       ## End Of Children Mark
221Ldebug_info_end0:
222	.section	__DWARF,__debug_str,regular,debug
223Linfo_string:
224	.asciz	"clang version 11.0.0 (https://github.com/llvm/llvm-project f30ebf437851d3c68fd0eee82afbc0cef7373c00)" ## string offset=0
225	.asciz	"a.c"                   ## string offset=101
226	.asciz	"/"                     ## string offset=105
227	.asciz	"/Users/davide/work/build/bin" ## string offset=107
228	.asciz	"a"                     ## string offset=136
229	.asciz	"int"                   ## string offset=138
230	.asciz	"main"                  ## string offset=142
231	.asciz	"b"                     ## string offset=147
232	.section	__DWARF,__apple_names,regular,debug
233Lnames_begin:
234	.long	1212240712              ## Header Magic
235	.short	1                       ## Header Version
236	.short	0                       ## Header Hash Function
237	.long	2                       ## Header Bucket Count
238	.long	2                       ## Header Hash Count
239	.long	12                      ## Header Data Length
240	.long	0                       ## HeaderData Die Offset Base
241	.long	1                       ## HeaderData Atom Count
242	.short	1                       ## DW_ATOM_die_offset
243	.short	6                       ## DW_FORM_data4
244	.long	0                       ## Bucket 0
245	.long	-1                      ## Bucket 1
246	.long	177670                  ## Hash in Bucket 0
247	.long	2090499946              ## Hash in Bucket 0
248.set Lset6, LNames0-Lnames_begin        ## Offset in Bucket 0
249	.long	Lset6
250.set Lset7, LNames1-Lnames_begin        ## Offset in Bucket 0
251	.long	Lset7
252LNames0:
253	.long	136                     ## a
254	.long	1                       ## Num DIEs
255	.long	46
256	.long	0
257LNames1:
258	.long	142                     ## main
259	.long	1                       ## Num DIEs
260	.long	79
261	.long	0
262	.section	__DWARF,__apple_objc,regular,debug
263Lobjc_begin:
264	.long	1212240712              ## Header Magic
265	.short	1                       ## Header Version
266	.short	0                       ## Header Hash Function
267	.long	1                       ## Header Bucket Count
268	.long	0                       ## Header Hash Count
269	.long	12                      ## Header Data Length
270	.long	0                       ## HeaderData Die Offset Base
271	.long	1                       ## HeaderData Atom Count
272	.short	1                       ## DW_ATOM_die_offset
273	.short	6                       ## DW_FORM_data4
274	.long	-1                      ## Bucket 0
275	.section	__DWARF,__apple_namespac,regular,debug
276Lnamespac_begin:
277	.long	1212240712              ## Header Magic
278	.short	1                       ## Header Version
279	.short	0                       ## Header Hash Function
280	.long	1                       ## Header Bucket Count
281	.long	0                       ## Header Hash Count
282	.long	12                      ## Header Data Length
283	.long	0                       ## HeaderData Die Offset Base
284	.long	1                       ## HeaderData Atom Count
285	.short	1                       ## DW_ATOM_die_offset
286	.short	6                       ## DW_FORM_data4
287	.long	-1                      ## Bucket 0
288	.section	__DWARF,__apple_types,regular,debug
289Ltypes_begin:
290	.long	1212240712              ## Header Magic
291	.short	1                       ## Header Version
292	.short	0                       ## Header Hash Function
293	.long	1                       ## Header Bucket Count
294	.long	1                       ## Header Hash Count
295	.long	20                      ## Header Data Length
296	.long	0                       ## HeaderData Die Offset Base
297	.long	3                       ## HeaderData Atom Count
298	.short	1                       ## DW_ATOM_die_offset
299	.short	6                       ## DW_FORM_data4
300	.short	3                       ## DW_ATOM_die_tag
301	.short	5                       ## DW_FORM_data2
302	.short	4                       ## DW_ATOM_type_flags
303	.short	11                      ## DW_FORM_data1
304	.long	0                       ## Bucket 0
305	.long	193495088               ## Hash in Bucket 0
306.set Lset8, Ltypes0-Ltypes_begin        ## Offset in Bucket 0
307	.long	Lset8
308Ltypes0:
309	.long	138                     ## int
310	.long	1                       ## Num DIEs
311	.long	72
312	.short	36
313	.byte	0
314	.long	0
315.subsections_via_symbols
316	.section	__DWARF,__debug_line,regular,debug
317Lsection_line:
318Lline_table_start0:
319