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)
Fri, Oct 17, 11:30 AM
Unknown Object (File)
Tue, Sep 30, 9:08 AM
Unknown Object (File)
Wed, Sep 24, 12:47 AM
Unknown Object (File)
Sep 16 2025, 12:24 AM
Unknown Object (File)
Aug 26 2025, 6:17 PM
Unknown Object (File)
Jun 15 2025, 9:21 AM
Unknown Object (File)
Jun 13 2025, 5:13 PM
Unknown Object (File)
Jun 2 2025, 2:04 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.