Skip to content

Commit 5d32648

Browse files
youngd007davidayoung
authored andcommitted
Add test for dwarf verification JSON output
Summary: 6244dfe LLVM commit added the ability for llvm-dwarfdump to specify --verify-json and get a JSON aggregation of t he DWARF errors. This diff improves the testing by ensuring we validate th e expected JSON shape. A follow up diff will modify the JSON and this ensures we can verify. he DWARF errors. This diff improves the testing by ensuring we validate th e expected JSON shape. A follow up diff will modify the JSON and this ensures we can verify. Test Plan: ninja check-llvm-tools-llvm-dwarfdump
1 parent e9c2e0a commit 5d32648

File tree

2 files changed

+172
-1
lines changed

2 files changed

+172
-1
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:

llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-completeness.s

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,3 @@
177177
.Lnames_abbrev_end0:
178178
.Lnames_entries0:
179179
.Lnames_end0:
180-

0 commit comments

Comments
 (0)