Page MenuHomeFreeBSD

dtrace: allow predicate with no acts

Authored by christos on Sat, Mar 18, 10:52 PM.




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

rG FreeBSD src repository
Lint Skipped
Tests Skipped

Event Timeline

christos added a reviewer:

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

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.