xref: /llvm-project/llvm/test/tools/llvm-dwarfdump/X86/verify_debug_info.s (revision 09f43c107fc7688639346d3beead72472cdadbdb)
1# RUN: llvm-mc %s -filetype obj -triple x86_64-apple-darwin -o - \
2# RUN: | not llvm-dwarfdump -v -verify - \
3# RUN: | FileCheck %s
4
5# CHECK: Verifying .debug_info Unit Header Chain...
6# CHECK-NEXT: error: Units[2] - start offset: 0x00000068
7# CHECK-NEXT: note: The length for this unit is too large for the .debug_info provided.
8# CHECK-NEXT: note: The unit type encoding is not valid.
9
10# CHECK: Verifying non-dwo Units...
11# CHECK: error: DIE has invalid DW_AT_stmt_list encoding:{{[[:space:]]}}
12# CHECK-NEXT: 0x0000000c: DW_TAG_compile_unit [1] *
13# CHECK-NEXT: DW_AT_producer [DW_FORM_strp]	( .debug_str[0x00000000] = "clang version 5.0.0 (trunk 308185) (llvm/trunk 308186)")
14# CHECK-NEXT: DW_AT_language [DW_FORM_data2]	(DW_LANG_C99)
15# CHECK-NEXT: DW_AT_name [DW_FORM_strp]	( .debug_str[0x00000037] = "basic.c")
16# CHECK-NEXT: DW_AT_stmt_list [DW_FORM_block4]
17# CHECK-NEXT: DW_AT_comp_dir [DW_FORM_strp]	( .debug_str[0x0000003f] = "/Users/sgravani/Development/tests")
18# CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]	(0x0000000000000000)
19# CHECK-NEXT: DW_AT_high_pc [DW_FORM_data4]	(0x00000016){{[[:space:]]}}
20# CHECK-NEXT: error: DIE has DW_AT_decl_file that references a file with index 1 and the compile unit has no line table{{[[:space:]]}}
21# CHECK-NEXT: 0x0000002b: DW_TAG_subprogram [2] *
22# CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]	(0x0000000000000000)
23# CHECK-NEXT: DW_AT_high_pc [DW_FORM_data4]	(0x00000016)
24# CHECK-NEXT: DW_AT_frame_base [DW_FORM_exprloc]	(DW_OP_reg6)
25# CHECK-NEXT: DW_AT_name [DW_FORM_strp]	( .debug_str[0x00000061] = "main")
26# CHECK-NEXT: DW_AT_decl_file [DW_FORM_data1]	(0x01)
27# CHECK-NEXT: DW_AT_decl_line [DW_FORM_data1]	(1)
28# CHECK-NEXT: DW_AT_prototyped [DW_FORM_flag_present]	(true)
29# CHECK-NEXT: DW_AT_type [DW_FORM_ref4]	(cu + 0x0052 => {0x00000052})
30# CHECK-NEXT: DW_AT_external [DW_FORM_flag_present]	(true){{[[:space:]]}}
31# CHECK-NEXT: error: DIE has DW_AT_type with incompatible tag DW_TAG_null{{[[:space:]]}}
32# CHECK-NEXT: 0x0000002b: DW_TAG_subprogram [2] *
33# CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]       (0x0000000000000000)
34# CHECK-NEXT: DW_AT_high_pc [DW_FORM_data4]     (0x00000016)
35# CHECK-NEXT: DW_AT_frame_base [DW_FORM_exprloc]        (DW_OP_reg6)
36# CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000061] = "main")
37# CHECK-NEXT: DW_AT_decl_file [DW_FORM_data1]   (0x01)
38# CHECK-NEXT: DW_AT_decl_line [DW_FORM_data1]   (1)
39# CHECK-NEXT: DW_AT_prototyped [DW_FORM_flag_present]   (true)
40# CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + 0x0052 => {0x00000052})
41# CHECK-NEXT: DW_AT_external [DW_FORM_flag_present]     (true){{[[:space:]]}}
42# CHECK-NEXT: error: DIE has DW_AT_decl_file that references a file with index 1 and the compile unit has no line table{{[[:space:]]}}
43# CHECK-NEXT: 0x00000044: DW_TAG_variable [3]
44# CHECK-NEXT: DW_AT_location [DW_FORM_exprloc]	(DW_OP_fbreg -8)
45# CHECK-NEXT: DW_AT_name [DW_FORM_strp]	( .debug_str[0x0000006a] = "a")
46# CHECK-NEXT: DW_AT_decl_file [DW_FORM_data1]	(0x01)
47# CHECK-NEXT: DW_AT_decl_line [DW_FORM_data1]	(2)
48# CHECK-NEXT: DW_AT_use_location [DW_FORM_ref4]	(cu + 0x0053 => {0x00000053}){{[[:space:]]}}
49# CHECK-NEXT: Verifying unit: 2 / 2
50# CHECK-NEXT: error: Compilation unit root DIE is not a unit DIE: DW_TAG_null.
51# CHECK-NEXT: error: Compilation unit type (DW_UT_compile) and root DIE (DW_TAG_null) do not match.
52
53
54	.section	__TEXT,__text,regular,pure_instructions
55	.globl	_main                   ## -- Begin function main
56	.p2align	4, 0x90
57_main:                                  ## @main
58Lfunc_begin0:
59	.file	1 "basic.c"
60	.loc	1 1 0                   ## basic.c:1:0
61	.cfi_startproc
62## %bb.0:                               ## %entry
63	pushq	%rbp
64	.cfi_def_cfa_offset 16
65	.cfi_offset %rbp, -16
66	movq	%rsp, %rbp
67	.cfi_def_cfa_register %rbp
68	xorl	%eax, %eax
69	movl	$0, -4(%rbp)
70Ltmp0:
71	.loc	1 2 7 prologue_end      ## basic.c:2:7
72	movl	$1, -8(%rbp)
73	.loc	1 3 3                   ## basic.c:3:3
74	popq	%rbp
75	retq
76Ltmp1:
77Lfunc_end0:
78	.cfi_endproc
79                                        ## -- End function
80	.section	__DWARF,__debug_str,regular,debug
81Linfo_string:
82	.asciz	"clang version 5.0.0 (trunk 308185) (llvm/trunk 308186)" ## string offset=0
83	.asciz	"basic.c"               ## string offset=55
84	.asciz	"/Users/sgravani/Development/tests" ## string offset=63
85	.asciz	"main"                  ## string offset=97
86	.asciz	"int"                   ## string offset=102
87	.asciz	"a"                     ## string offset=106
88	.section	__DWARF,__debug_abbrev,regular,debug
89Lsection_abbrev:
90	.byte	1                       ## Abbreviation Code
91	.byte	17                      ## DW_TAG_compile_unit
92	.byte	1                       ## DW_CHILDREN_yes
93	.byte	37                      ## DW_AT_producer
94	.byte	14                      ## DW_FORM_strp
95	.byte	19                      ## DW_AT_language
96	.byte	5                       ## DW_FORM_data2
97	.byte	3                       ## DW_AT_name
98	.byte	14                      ## DW_FORM_strp
99	.byte	16                      ## DW_AT_stmt_list
100	.byte	4                       ## DW_FORM_sec_offset -- error: DIE has invalid DW_AT_stmt_list encoding:
101	.byte	27                      ## DW_AT_comp_dir
102	.byte	14                      ## DW_FORM_strp
103	.byte	17                      ## DW_AT_low_pc
104	.byte	1                       ## DW_FORM_addr
105	.byte	18                      ## DW_AT_high_pc
106	.byte	6                       ## DW_FORM_data4
107	.byte	0                       ## EOM(1)
108	.byte	0                       ## EOM(2)
109	.byte	2                       ## Abbreviation Code
110	.byte	46                      ## DW_TAG_subprogram
111	.byte	1                       ## DW_CHILDREN_yes
112	.byte	17                      ## DW_AT_low_pc
113	.byte	1                       ## DW_FORM_addr
114	.byte	18                      ## DW_AT_high_pc
115	.byte	6                       ## DW_FORM_data4
116	.byte	64                      ## DW_AT_frame_base
117	.byte	24                      ## DW_FORM_exprloc
118	.byte	3                       ## DW_AT_name
119	.byte	14                      ## DW_FORM_strp
120	.byte	58                      ## DW_AT_decl_file
121	.byte	11                      ## DW_FORM_data1
122	.byte	59                      ## DW_AT_decl_line
123	.byte	11                      ## DW_FORM_data1
124	.byte	39                      ## DW_AT_prototyped
125	.byte	25                      ## DW_FORM_flag_present
126	.byte	73                      ## DW_AT_type
127	.byte	19                      ## DW_FORM_ref4
128	.byte	63                      ## DW_AT_external
129	.byte	25                      ## DW_FORM_flag_present
130	.byte	0                       ## EOM(1)
131	.byte	0                       ## EOM(2)
132	.byte	3                       ## Abbreviation Code
133	.byte	52                      ## DW_TAG_variable
134	.byte	0                       ## DW_CHILDREN_no
135	.byte	2                       ## DW_AT_location
136	.byte	24                      ## DW_FORM_exprloc
137	.byte	3                       ## DW_AT_name
138	.byte	14                      ## DW_FORM_strp
139	.byte	58                      ## DW_AT_decl_file
140	.byte	11                      ## DW_FORM_data1
141	.byte	59                      ## DW_AT_decl_line
142	.byte	11                      ## DW_FORM_data1
143	.byte	74                      ## DW_AT_type
144	.byte	19                      ## DW_FORM_ref4
145	.byte	0                       ## EOM(1)
146	.byte	0                       ## EOM(2)
147	.byte	4                       ## Abbreviation Code
148	.byte	36                      ## DW_TAG_base_type
149	.byte	0                       ## DW_CHILDREN_no
150	.byte	3                       ## DW_AT_name
151	.byte	14                      ## DW_FORM_strp
152	.byte	62                      ## DW_AT_encoding
153	.byte	11                      ## DW_FORM_data1
154	.byte	11                      ## DW_AT_byte_size
155	.byte	11                      ## DW_FORM_data1
156	.byte	0                       ## EOM(1)
157	.byte	0                       ## EOM(2)
158	.byte	0                       ## EOM(3)
159	.section	__DWARF,__debug_info,regular,debug
160Lsection_info:
161Lcu_begin0:
162	.long	87                      ## Length of Unit
163	.short	5                       ## DWARF version number
164	.byte	1                       ## DWARF Unit Type
165	.byte	8                       ## Address Size (in bytes)
166Lset0 = Lsection_abbrev-Lsection_abbrev ## Offset Into Abbrev. Section
167	.long	Lset0
168	.byte	1                       ## Abbrev [1] 0xc:0x4f DW_TAG_compile_unit
169	.long	0                       ## DW_AT_producer
170	.short	12                      ## DW_AT_language
171	.long	55                      ## DW_AT_name
172Lset1 = Lline_table_start0-Lsection_line ## DW_AT_stmt_list
173	.long	Lset1
174	.long	63                      ## DW_AT_comp_dir
175	.quad	Lfunc_begin0            ## DW_AT_low_pc
176Lset2 = Lfunc_end0-Lfunc_begin0         ## DW_AT_high_pc
177	.long	Lset2
178	.byte	2                       ## Abbrev [2] 0x2b:0x28 DW_TAG_subprogram
179	.quad	Lfunc_begin0            ## DW_AT_low_pc
180Lset3 = Lfunc_end0-Lfunc_begin0         ## DW_AT_high_pc
181	.long	Lset3
182	.byte	1                       ## DW_AT_frame_base
183	.byte	86
184	.long	97                      ## DW_AT_name
185	.byte	1                       ## DW_AT_decl_file
186	.byte	1                       ## DW_AT_decl_line
187                                        ## DW_AT_prototyped
188	.long	82                      ## DW_AT_type
189                                        ## DW_AT_external
190	.byte	3                       ## Abbrev [3] 0x44:0xe DW_TAG_variable
191	.byte	2                       ## DW_AT_location
192	.byte	145
193	.byte	120
194	.long	106                     ## DW_AT_name
195	.byte	1                       ## DW_AT_decl_file
196	.byte	2                       ## DW_AT_decl_line
197	.long	83                      ## DW_AT_type
198	.byte	0                       ## End Of Children Mark
199	.byte	4                       ## Abbrev [4] 0x53:0x7 DW_TAG_base_type
200	.long	102                     ## DW_AT_name
201	.byte	5                       ## DW_AT_encoding
202	.byte	4                       ## DW_AT_byte_size
203	.byte	0                       ## End Of Children Mark
204Lcu_begin1:
205	.long	9                      ## Length of Unit
206	.short	5                       ## DWARF version number
207	.byte	1                       ## DWARF Unit Type
208	.byte	4                       ## Address Size (in bytes)
209	.long	0						## Abbrev offset
210	.byte 	0
211Ltu_begin0:
212	.long	26                      ## Length of Unit -- Error: The length for this unit is too large for the .debug_info provided.
213	.short	5                       ## DWARF version number
214	.byte	0                       ## DWARF Unit Type
215	.byte	4                       ## Address Size (in bytes)
216	.long	0
217	.quad	0
218	.long   0
219	.byte 	0
220
221.subsections_via_symbols
222	.section	__DWARF,__debug_line,regular,debug
223Lsection_line:
224Lline_table_start0:
225