Print this page
10823 should ignore DW_TAG_subprogram with DW_AT_declaration tags
10824 GCC7-derived CTF can double qualifiers on arrays
10825 ctfdump -c drops last type
10826 ctfdump -c goes off the rails with a missing parent
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Jason King <jason.king@joyent.com>
Approved by: Jerry Jelinek <jerry.jelinek@joyent.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/test/util-tests/tests/ctf/check-reference.c
+++ new/usr/src/test/util-tests/tests/ctf/check-reference.c
1 1 /*
2 2 * This file and its contents are supplied under the terms of the
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
3 3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 4 * You may only use this file in accordance with the terms of version
5 5 * 1.0 of the CDDL.
6 6 *
7 7 * A full copy of the text of the CDDL should have accompanied this
8 8 * source. A copy of the CDDL is also available via the Internet at
9 9 * http://www.illumos.org/license/CDDL.
10 10 */
11 11
12 12 /*
13 - * Copyright (c) 2019, Joyent, Inc.
13 + * Copyright 2019, Joyent, Inc.
14 14 */
15 15
16 16 /*
17 17 * Check that we properly understand reference types and can walk through them
18 18 * as well as generate them.
19 19 */
20 20
21 21 #include "check-common.h"
22 22
23 23 static check_number_t check_base[] = {
24 24 { "char", CTF_K_INTEGER, CTF_INT_SIGNED | CTF_INT_CHAR, 0, 8 },
25 25 { "int", CTF_K_INTEGER, CTF_INT_SIGNED, 0, 32 },
26 26 { "float", CTF_K_FLOAT, CTF_FP_SINGLE, 0, 32 },
27 27 { NULL }
28 28 };
29 29
30 30 static check_symbol_t check_syms[] = {
31 31 { "a", "int" },
32 32 { "aa", "test_int_t" },
33 33 { "b", "const short" },
34 34 { "c", "volatile float" },
35 35 { "d", "int *" },
36 36 { "dd", "int **" },
37 37 { "ddd", "int ***" },
38 38 { "e", "test_int_t *" },
39 39 { "ce", "const test_int_t *" },
40 40 { "ve", "volatile test_int_t *" },
41 41 { "cve", "const volatile test_int_t *" },
42 42 { "f", "int *const *" },
43 43 { "g", "const char *const" },
44 44 { NULL },
45 45 };
46 46
47 47 static check_descent_t check_descent_aa[] = {
48 48 { "test_int_t", CTF_K_TYPEDEF },
49 49 { "int", CTF_K_INTEGER },
50 50 { NULL }
51 51 };
52 52
53 53 static check_descent_t check_descent_b[] = {
54 54 { "const short", CTF_K_CONST },
55 55 { "short", CTF_K_INTEGER },
56 56 { NULL }
57 57 };
58 58
59 59 static check_descent_t check_descent_c[] = {
60 60 { "volatile float", CTF_K_VOLATILE },
61 61 { "float", CTF_K_FLOAT },
62 62 { NULL }
63 63 };
64 64
65 65 static check_descent_t check_descent_d[] = {
66 66 { "int *", CTF_K_POINTER },
67 67 { "int", CTF_K_INTEGER },
68 68 { NULL }
69 69 };
70 70
71 71 static check_descent_t check_descent_dd[] = {
72 72 { "int **", CTF_K_POINTER },
73 73 { "int *", CTF_K_POINTER },
74 74 { "int", CTF_K_INTEGER },
75 75 { NULL }
76 76 };
77 77
78 78 static check_descent_t check_descent_ddd[] = {
79 79 { "int ***", CTF_K_POINTER },
80 80 { "int **", CTF_K_POINTER },
81 81 { "int *", CTF_K_POINTER },
82 82 { "int", CTF_K_INTEGER },
83 83 { NULL }
84 84 };
85 85
86 86 static check_descent_t check_descent_e[] = {
87 87 { "test_int_t *", CTF_K_POINTER },
88 88 { "test_int_t", CTF_K_TYPEDEF },
89 89 { "int", CTF_K_INTEGER },
90 90 { NULL },
91 91 };
92 92
93 93 static check_descent_t check_descent_ce[] = {
94 94 { "const test_int_t *", CTF_K_POINTER },
95 95 { "const test_int_t", CTF_K_CONST },
96 96 { "test_int_t", CTF_K_TYPEDEF },
97 97 { "int", CTF_K_INTEGER },
98 98 { NULL },
99 99 };
100 100
101 101 static check_descent_t check_descent_ve[] = {
102 102 { "volatile test_int_t *", CTF_K_POINTER},
103 103 { "volatile test_int_t", CTF_K_VOLATILE },
104 104 { "test_int_t", CTF_K_TYPEDEF },
105 105 { "int", CTF_K_INTEGER },
106 106 { NULL }
107 107 };
108 108
109 109 static check_descent_t check_descent_cve[] = {
110 110 { "const volatile test_int_t *", CTF_K_POINTER },
111 111 { "const volatile test_int_t", CTF_K_CONST },
112 112 { "volatile test_int_t", CTF_K_VOLATILE },
113 113 { "test_int_t", CTF_K_TYPEDEF },
114 114 { "int", CTF_K_INTEGER },
115 115 { NULL }
116 116 };
117 117
118 118 static check_descent_t check_descent_f[] = {
119 119 { "int *const *", CTF_K_POINTER },
120 120 { "int *const", CTF_K_CONST },
121 121 { "int *", CTF_K_POINTER },
122 122 { "int", CTF_K_INTEGER },
123 123 { NULL }
↓ open down ↓ |
100 lines elided |
↑ open up ↑ |
124 124 };
125 125
126 126 static check_descent_t check_descent_g[] = {
127 127 { "const char *const", CTF_K_CONST },
128 128 { "const char *", CTF_K_POINTER },
129 129 { "const char", CTF_K_CONST },
130 130 { "char", CTF_K_INTEGER },
131 131 { NULL }
132 132 };
133 133
134 -static check_descent_t check_descent_cvh[] = {
135 - { "const volatile foo_t *", CTF_K_POINTER },
136 - { "const volatile foo_t", CTF_K_CONST },
137 - { "volatile foo_t", CTF_K_VOLATILE },
138 - { "foo_t", CTF_K_TYPEDEF },
139 - { "int *const *", CTF_K_POINTER },
140 - { "int *const", CTF_K_CONST },
141 - { "int *", CTF_K_POINTER },
142 - { "int", CTF_K_INTEGER },
143 - { NULL }
144 -};
145 -
146 134 static check_descent_test_t descents[] = {
147 135 { "aa", check_descent_aa },
148 136 { "b", check_descent_b },
149 137 { "c", check_descent_c },
150 138 { "d", check_descent_d },
151 139 { "dd", check_descent_dd },
152 140 { "ddd", check_descent_ddd },
153 141 { "e", check_descent_e },
154 142 { "ce", check_descent_ce },
155 143 { "ve", check_descent_ve },
156 144 { "cve", check_descent_cve },
157 145 { "f", check_descent_f },
158 146 { "g", check_descent_g },
159 - { "cvh", check_descent_cvh },
160 147 { NULL }
161 148 };
162 149
150 +static check_descent_t check_descent_cvh_gcc4[] = {
151 + { "const volatile foo_t *", CTF_K_POINTER },
152 + { "const volatile foo_t", CTF_K_CONST },
153 + { "volatile foo_t", CTF_K_VOLATILE },
154 + { "foo_t", CTF_K_TYPEDEF },
155 + { "int *const *", CTF_K_POINTER },
156 + { "int *const", CTF_K_CONST },
157 + { "int *", CTF_K_POINTER },
158 + { "int", CTF_K_INTEGER },
159 + { NULL }
160 +};
161 +
162 +static check_descent_t check_descent_cvh_gcc7[] = {
163 + { "volatile const foo_t *", CTF_K_POINTER },
164 + { "volatile const foo_t", CTF_K_VOLATILE },
165 + { "const foo_t", CTF_K_CONST },
166 + { "foo_t", CTF_K_TYPEDEF },
167 + { "int *const *", CTF_K_POINTER },
168 + { "int *const", CTF_K_CONST },
169 + { "int *", CTF_K_POINTER },
170 + { "int", CTF_K_INTEGER },
171 + { NULL }
172 +};
173 +
174 +/*
175 + * GCC versions differ in how they order qualifiers, which is a shame for
176 + * round-tripping; but as they're clearly both valid, we should cope. We'll
177 + * just insist that at least one of these checks passes.
178 + */
179 +static check_descent_test_t alt_descents[] = {
180 + { "cvh", check_descent_cvh_gcc4 },
181 + { "cvh", check_descent_cvh_gcc7 },
182 +};
183 +
163 184 int
164 185 main(int argc, char *argv[])
165 186 {
166 187 int i, ret = 0;
167 188
168 189 if (argc < 2) {
169 190 errx(EXIT_FAILURE, "missing test files");
170 191 }
171 192
172 193 for (i = 1; i < argc; i++) {
173 194 ctf_file_t *fp;
195 + int alt_ok = 0;
174 196 uint_t d;
175 197
176 198 if ((fp = ctf_open(argv[i], &ret)) == NULL) {
177 199 warnx("failed to open %s: %s", argv[i],
178 200 ctf_errmsg(ret));
179 201 ret = EXIT_FAILURE;
180 202 continue;
181 203 }
182 204
183 205 if (!ctftest_check_numbers(fp, check_base))
184 206 ret = EXIT_FAILURE;
185 207 if (!ctftest_check_symbols(fp, check_syms))
186 208 ret = EXIT_FAILURE;
187 209 for (d = 0; descents[d].cdt_sym != NULL; d++) {
188 210 if (!ctftest_check_descent(descents[d].cdt_sym, fp,
189 - descents[d].cdt_tests)) {
211 + descents[d].cdt_tests, B_FALSE)) {
190 212 ret = EXIT_FAILURE;
191 213 }
192 214 }
215 +
216 + for (d = 0; alt_descents[d].cdt_sym != NULL; d++) {
217 + if (ctftest_check_descent(alt_descents[d].cdt_sym, fp,
218 + alt_descents[d].cdt_tests, B_TRUE)) {
219 + alt_ok = 1;
220 + break;
221 + }
222 + }
223 +
224 + if (!alt_ok) {
225 + warnx("all descents failed for %s",
226 + alt_descents[0].cdt_sym);
227 + ret = EXIT_FAILURE;
228 + }
229 +
193 230 ctf_close(fp);
194 231 }
195 232
196 233 return (ret);
197 234 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX