Page MenuHomeFreeBSD

dtrace: allow predicate with no acts
AbandonedPublic

Authored by christos on Mar 18 2023, 10:52 PM.
Tags
Referenced Files
Unknown Object (File)
Mar 13 2024, 12:01 PM
Unknown Object (File)
Dec 22 2023, 11:18 PM
Unknown Object (File)
Dec 13 2023, 4:25 PM
Unknown Object (File)
Nov 9 2023, 7:29 PM
Unknown Object (File)
Nov 7 2023, 7:26 PM
Unknown Object (File)
Oct 6 2023, 6:22 PM
Unknown Object (File)
Sep 14 2023, 5:37 PM
Unknown Object (File)
Aug 15 2023, 12:25 PM
Subscribers

Details

Summary

Fixes: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269906

I get the following warnings when building libdtrace with this patch:

/usr/src/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l:410: warning, trailing context made variable due to preceding '|' action
/usr/src/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l:409: warning, dangerous trailing context
/usr/src/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l:409: warning, dangerous trailing context
yacc: 1 shift/reduce conflict.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

christos added a reviewer: freebsd_igalic.co.

I see those warnings when building libdtrace without the patch.

Could you please write some simple regression tests for this? They can be standalone scripts if you like, in which case I'll help integrate them into the dtrace regression test suite.

Apparently, this patch doesn't really work and, in fact, allowing a predicate
with no acts is probably impossible in D without introducing a significant
amount of complexity. awk can do that just fine because awk's predicates cannot
contain unescaped "/", since it searches for regexes. D on the other hand
allows normal computation inside the predicate, meaning one can do division
inside it:

kinst::vm_fault: /(cpu / 2) == 1/

This is a problem because the D lexer considers "/" to be a division token (and
not a start/end of predicate token) when the next non-whitespace character
coming after it is anything other than EOF, 0, ;, { and }, so if we try and
run:

kinst::vm_fault: /cpu == 1/ fbt::malloc:entry

The lexer will think the end of predicate is actually a division token because
the succeeding non-whitespace character "f" doesn't match the character set
that indicate the end of predicate.

We're abandoning this revision.