Commit f00bb75
selftests/bpf: fix to avoid __msg tag de-duplication by clang
__msg, __regex and __xlated tags are based on
__attribute__((btf_decl_tag("..."))) annotations.
Clang de-duplicates such annotations, e.g. the following
two sequences of tags are identical in final BTF:
/* seq A */ /* seq B */
__tag("foo") __tag("foo")
__tag("bar") __tag("bar")
__tag("foo")
Fix this by adding a unique suffix for each tag using __COUNTER__
pre-processor macro. E.g. here is a new definition for __msg:
#define __msg(msg) \
__attribute__((btf_decl_tag("comment:test_expect_msg=" XSTR(__COUNTER__) "=" msg)))
Using this definition the "seq A" from example above is translated to
BTF as follows:
[..] DECL_TAG 'comment:test_expect_msg=0=foo' type_id=X component_idx=-1
[..] DECL_TAG 'comment:test_expect_msg=1=bar' type_id=X component_idx=-1
[..] DECL_TAG 'comment:test_expect_msg=2=foo' type_id=X component_idx=-1
Surprisingly, this bug affects a single existing test:
verifier_spill_fill/old_stack_misc_vs_cur_ctx_ptr,
where sequence of identical messages was expected in the log.
Fixes: 537c3f6 ("selftests/bpf: add generic BPF program tester-loader")
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20240820102357.3372779-4-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>1 parent d0a29cd commit f00bb75
File tree
3 files changed
+48
-22
lines changed- tools/testing/selftests/bpf
- progs
3 files changed
+48
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
| |||
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
71 | | - | |
72 | | - | |
73 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
77 | | - | |
78 | | - | |
79 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
80 | 83 | | |
81 | 84 | | |
82 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1213 | 1213 | | |
1214 | 1214 | | |
1215 | 1215 | | |
1216 | | - | |
1217 | | - | |
1218 | | - | |
1219 | | - | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
1220 | 1220 | | |
1221 | 1221 | | |
1222 | 1222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
218 | 247 | | |
219 | 248 | | |
220 | 249 | | |
| |||
290 | 319 | | |
291 | 320 | | |
292 | 321 | | |
293 | | - | |
294 | | - | |
| 322 | + | |
295 | 323 | | |
296 | 324 | | |
297 | 325 | | |
298 | 326 | | |
299 | | - | |
300 | | - | |
| 327 | + | |
301 | 328 | | |
302 | 329 | | |
303 | 330 | | |
304 | 331 | | |
305 | | - | |
306 | | - | |
| 332 | + | |
307 | 333 | | |
308 | 334 | | |
309 | 335 | | |
310 | 336 | | |
311 | | - | |
312 | | - | |
| 337 | + | |
313 | 338 | | |
314 | 339 | | |
315 | 340 | | |
316 | 341 | | |
317 | | - | |
318 | | - | |
| 342 | + | |
319 | 343 | | |
320 | 344 | | |
321 | 345 | | |
322 | 346 | | |
323 | | - | |
324 | | - | |
| 347 | + | |
325 | 348 | | |
326 | 349 | | |
327 | 350 | | |
| |||
0 commit comments