Skip to content

Commit f8efb44

Browse files
youngd007github-actions[bot]
authored andcommitted
Automerge: Add back deleted test for llvm-dwarfdump JSON output (#127685)
Looks like llvm/llvm-project#124936 was reverted (for modifying JSON output), but the test for JSON output with errors was deleted in llvm/llvm-project#126587 (to attempt to fix failing build) This will add back a test and a new one for llvm-dwarfdump to validate the JSON for errors. One case where the sub-categories will eventually appear and another where not. test plan: ninja check-llvm-tools-llvm-dwarfdump
2 parents 7a63588 + 5622f22 commit f8efb44

File tree

2 files changed

+283
-0
lines changed

2 files changed

+283
-0
lines changed
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj -o - | not llvm-dwarfdump -verify --verify-json=%t.json -
2+
# RUN: FileCheck %s --input-file %t.json
3+
4+
# CHECK: {"error-categories":{"Name Index DIE entry missing name":{"count":10}},"error-count":10}
5+
# CHECK-NOT: error: Name Index @ 0x0: Entry for DIE @ {{.*}} (DW_TAG_variable) with name var_block_addr missing.
6+
7+
.section .debug_loc,"",@progbits
8+
.Ldebug_loc0:
9+
.quad 0
10+
.quad 1
11+
.short .Lloc0_end-.Lloc0_start # Loc expr size
12+
.Lloc0_start:
13+
.byte 3 # DW_OP_addr
14+
.quad 0x47
15+
.Lloc0_end:
16+
.quad 0
17+
.quad 0
18+
19+
.section .debug_abbrev,"",@progbits
20+
.byte 1 # Abbreviation Code
21+
.byte 17 # DW_TAG_compile_unit
22+
.byte 1 # DW_CHILDREN_yes
23+
.byte 37 # DW_AT_producer
24+
.byte 8 # DW_FORM_string
25+
.byte 17 # DW_AT_low_pc
26+
.byte 1 # DW_FORM_addr
27+
.byte 18 # DW_AT_high_pc
28+
.byte 6 # DW_FORM_data4
29+
.byte 0 # EOM(1)
30+
.byte 0 # EOM(2)
31+
32+
.byte 2 # Abbreviation Code
33+
.byte 52 # DW_TAG_variable
34+
.byte 0 # DW_CHILDREN_no
35+
.byte 3 # DW_AT_name
36+
.byte 8 # DW_FORM_string
37+
.byte 2 # DW_AT_location
38+
.byte 24 # DW_FORM_exprloc
39+
.byte 0 # EOM(1)
40+
.byte 0 # EOM(2)
41+
42+
.byte 3 # Abbreviation Code
43+
.byte 46 # DW_TAG_subprogram
44+
.byte 1 # DW_CHILDREN_yes
45+
.byte 3 # DW_AT_name
46+
.byte 8 # DW_FORM_string
47+
.byte 110 # DW_AT_linkage_name
48+
.byte 8 # DW_FORM_string
49+
.byte 82 # DW_AT_entry_pc
50+
.byte 1 # DW_FORM_addr
51+
.byte 0 # EOM(1)
52+
.byte 0 # EOM(2)
53+
54+
.byte 4 # Abbreviation Code
55+
.byte 57 # DW_TAG_namespace
56+
.byte 1 # DW_CHILDREN_yes
57+
.byte 3 # DW_AT_name
58+
.byte 8 # DW_FORM_string
59+
.byte 0 # EOM(1)
60+
.byte 0 # EOM(2)
61+
62+
.byte 5 # Abbreviation Code
63+
.byte 52 # DW_TAG_variable
64+
.byte 0 # DW_CHILDREN_no
65+
.byte 3 # DW_AT_name
66+
.byte 8 # DW_FORM_string
67+
.byte 2 # DW_AT_location
68+
.byte 23 # DW_FORM_sec_offset
69+
.byte 0 # EOM(1)
70+
.byte 0 # EOM(2)
71+
72+
.byte 6 # Abbreviation Code
73+
.byte 57 # DW_TAG_namespace
74+
.byte 1 # DW_CHILDREN_yes
75+
.byte 0 # EOM(1)
76+
.byte 0 # EOM(2)
77+
78+
.byte 7 # Abbreviation Code
79+
.byte 29 # DW_TAG_inlined_subroutine
80+
.byte 0 # DW_CHILDREN_no
81+
.byte 3 # DW_AT_name
82+
.byte 8 # DW_FORM_string
83+
.byte 17 # DW_AT_low_pc
84+
.byte 1 # DW_FORM_addr
85+
.byte 18 # DW_AT_high_pc
86+
.byte 1 # DW_FORM_addr
87+
.byte 0 # EOM(1)
88+
.byte 0 # EOM(2)
89+
90+
.byte 8 # Abbreviation Code
91+
.byte 10 # DW_TAG_label
92+
.byte 0 # DW_CHILDREN_no
93+
.byte 3 # DW_AT_name
94+
.byte 8 # DW_FORM_string
95+
.byte 82 # DW_AT_entry_pc
96+
.byte 1 # DW_FORM_addr
97+
.byte 0 # EOM(1)
98+
.byte 0 # EOM(2)
99+
100+
.byte 0 # EOM(3)
101+
.section .debug_info,"",@progbits
102+
103+
.Lcu_begin0:
104+
.long .Lcu_end0-.Lcu_start0 # Length of Unit
105+
.Lcu_start0:
106+
.short 4 # DWARF version number
107+
.long .debug_abbrev # Offset Into Abbrev. Section
108+
.byte 8 # Address Size (in bytes)
109+
.byte 1 # Abbrev [1] DW_TAG_compile_unit
110+
.asciz "hand-written DWARF" # DW_AT_producer
111+
.quad 0x0 # DW_AT_low_pc
112+
.long 0x100 # DW_AT_high_pc
113+
114+
.byte 4 # Abbrev [4] DW_TAG_namespace
115+
.asciz "namesp" # DW_AT_name
116+
.byte 2 # Abbrev [2] DW_TAG_variable
117+
.asciz "var_block_addr" # DW_AT_name
118+
.byte 9 # DW_AT_location
119+
.byte 3 # DW_OP_addr
120+
.quad 0x47
121+
.byte 0 # End Of Children Mark
122+
123+
.byte 6 # Abbrev [6] DW_TAG_namespace
124+
.byte 5 # Abbrev [5] DW_TAG_variable
125+
.asciz "var_loc_addr" # DW_AT_name
126+
.long .Ldebug_loc0 # DW_AT_location
127+
.byte 0 # End Of Children Mark
128+
129+
.byte 2 # Abbrev [2] DW_TAG_variable
130+
.asciz "var_loc_tls" # DW_AT_name
131+
.byte 1 # DW_AT_location
132+
.byte 0x9b # DW_OP_form_tls_address
133+
134+
.byte 2 # Abbrev [2] DW_TAG_variable
135+
.asciz "var_loc_gnu_tls" # DW_AT_name
136+
.byte 1 # DW_AT_location
137+
.byte 0xe0 # DW_OP_GNU_push_tls_address
138+
139+
.byte 3 # Abbrev [3] DW_TAG_subprogram
140+
.asciz "fun_name" # DW_AT_name
141+
.asciz "_Z8fun_name" # DW_AT_linkage_name
142+
.quad 0x47 # DW_AT_entry_pc
143+
.byte 7 # Abbrev [7] DW_TAG_inlined_subroutine
144+
.asciz "fun_inline" # DW_AT_name
145+
.quad 0x48 # DW_AT_low_pc
146+
.quad 0x49 # DW_AT_high_pc
147+
.byte 8 # Abbrev [8] DW_TAG_label
148+
.asciz "label" # DW_AT_name
149+
.quad 0x4a # DW_AT_entry_pc
150+
.byte 0 # End Of Children Mark
151+
152+
.byte 0 # End Of Children Mark
153+
.Lcu_end0:
154+
155+
.section .debug_names,"",@progbits
156+
.long .Lnames_end0-.Lnames_start0 # Header: contribution length
157+
.Lnames_start0:
158+
.short 5 # Header: version
159+
.short 0 # Header: padding
160+
.long 1 # Header: compilation unit count
161+
.long 0 # Header: local type unit count
162+
.long 0 # Header: foreign type unit count
163+
.long 0 # Header: bucket count
164+
.long 0 # Header: name count
165+
.long .Lnames_abbrev_end0-.Lnames_abbrev_start0 # Header: abbreviation table size
166+
.long 0 # Header: augmentation length
167+
.long .Lcu_begin0 # Compilation unit 0
168+
.Lnames_abbrev_start0:
169+
.byte 0 # End of abbrev list
170+
.Lnames_abbrev_end0:
171+
.Lnames_entries0:
172+
.Lnames_end0:
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj | \
2+
# RUN: not llvm-dwarfdump -verify -verify-json=%t.json -
3+
# RUN: FileCheck %s --input-file %t.json
4+
5+
# CHECK: {"error-categories":{"Duplicate Name Index":{"count":1},"Name Index doesn't index any CU":{"count":1},"Name Index references non-existing CU":{"count":1}},"error-count":3}
6+
# CHECK-NOT : error: Name Index @ 0x58 references a CU @ 0x0, but this CU is already indexed by Name Index @ 0x28
7+
# CHECK-NOT: warning: CU @ 0x13 not covered by any Name Index
8+
9+
10+
.section .debug_str,"MS",@progbits,1
11+
.Lstring_foo:
12+
.asciz "foo"
13+
.Lstring_foo_mangled:
14+
.asciz "_Z3foov"
15+
.Lstring_bar:
16+
.asciz "bar"
17+
.Lstring_producer:
18+
.asciz "Hand-written dwarf"
19+
20+
.section .debug_abbrev,"",@progbits
21+
.Lsection_abbrev:
22+
.byte 1 # Abbreviation Code
23+
.byte 17 # DW_TAG_compile_unit
24+
.byte 1 # DW_CHILDREN_yes
25+
.byte 37 # DW_AT_producer
26+
.byte 14 # DW_FORM_strp
27+
.byte 19 # DW_AT_language
28+
.byte 5 # DW_FORM_data2
29+
.byte 0 # EOM(1)
30+
.byte 0 # EOM(2)
31+
.byte 0 # EOM(3)
32+
33+
.section .debug_info,"",@progbits
34+
.Lcu_begin0:
35+
.long .Lcu_end0-.Lcu_start0 # Length of Unit
36+
.Lcu_start0:
37+
.short 4 # DWARF version number
38+
.long .Lsection_abbrev # Offset Into Abbrev. Section
39+
.byte 8 # Address Size (in bytes)
40+
.byte 1 # Abbrev [1] DW_TAG_compile_unit
41+
.long .Lstring_producer # DW_AT_producer
42+
.short 12 # DW_AT_language
43+
.byte 0 # End Of Children Mark
44+
.Lcu_end0:
45+
46+
.Lcu_begin1:
47+
.long .Lcu_end1-.Lcu_start1 # Length of Unit
48+
.Lcu_start1:
49+
.short 4 # DWARF version number
50+
.long .Lsection_abbrev # Offset Into Abbrev. Section
51+
.byte 8 # Address Size (in bytes)
52+
.byte 1 # Abbrev [1] DW_TAG_compile_unit
53+
.long .Lstring_producer # DW_AT_producer
54+
.short 12 # DW_AT_language
55+
.byte 0 # End Of Children Mark
56+
.Lcu_end1:
57+
58+
.section .debug_names,"",@progbits
59+
.long .Lnames_end0-.Lnames_start0 # Header: contribution length
60+
.Lnames_start0:
61+
.short 5 # Header: version
62+
.short 0 # Header: padding
63+
.long 0 # Header: compilation unit count
64+
.long 0 # Header: local type unit count
65+
.long 0 # Header: foreign type unit count
66+
.long 0 # Header: bucket count
67+
.long 0 # Header: name count
68+
.long .Lnames_abbrev_end0-.Lnames_abbrev_start0 # Header: abbreviation table size
69+
.long 0 # Header: augmentation length
70+
.Lnames_abbrev_start0:
71+
.byte 0 # End of abbrev list
72+
.Lnames_abbrev_end0:
73+
.p2align 2
74+
.Lnames_end0:
75+
76+
.long .Lnames_end1-.Lnames_start1 # Header: contribution length
77+
.Lnames_start1:
78+
.short 5 # Header: version
79+
.short 0 # Header: padding
80+
.long 2 # Header: compilation unit count
81+
.long 0 # Header: local type unit count
82+
.long 0 # Header: foreign type unit count
83+
.long 0 # Header: bucket count
84+
.long 0 # Header: name count
85+
.long .Lnames_abbrev_end1-.Lnames_abbrev_start1 # Header: abbreviation table size
86+
.long 0 # Header: augmentation length
87+
.long .Lcu_begin0 # Compilation unit 0
88+
.long .Lcu_begin0+1 # Compilation unit 0
89+
.Lnames_abbrev_start1:
90+
.byte 0 # End of abbrev list
91+
.Lnames_abbrev_end1:
92+
.p2align 2
93+
.Lnames_end1:
94+
95+
.long .Lnames_end2-.Lnames_start2 # Header: contribution length
96+
.Lnames_start2:
97+
.short 5 # Header: version
98+
.short 0 # Header: padding
99+
.long 1 # Header: compilation unit count
100+
.long 0 # Header: local type unit count
101+
.long 0 # Header: foreign type unit count
102+
.long 0 # Header: bucket count
103+
.long 0 # Header: name count
104+
.long .Lnames_abbrev_end2-.Lnames_abbrev_start2 # Header: abbreviation table size
105+
.long 0 # Header: augmentation length
106+
.long .Lcu_begin0 # Compilation unit 0
107+
.Lnames_abbrev_start2:
108+
.byte 0 # End of abbrev list
109+
.Lnames_abbrev_end2:
110+
.p2align 2
111+
.Lnames_end2:

0 commit comments

Comments
 (0)