Page MenuHomeFreeBSD

dtrace(1): add -d flag to dump D script post-dt_sugar
ClosedPublic

Authored by christos on Feb 22 2023, 4:42 PM.
Tags
Referenced Files
Unknown Object (File)
Sun, Apr 14, 5:29 PM
Unknown Object (File)
Mon, Apr 8, 1:58 PM
Unknown Object (File)
Mar 4 2024, 1:13 AM
Unknown Object (File)
Mar 4 2024, 1:13 AM
Unknown Object (File)
Mar 4 2024, 1:13 AM
Unknown Object (File)
Mar 4 2024, 1:13 AM
Unknown Object (File)
Mar 4 2024, 1:13 AM
Unknown Object (File)
Mar 4 2024, 1:13 AM
Subscribers

Details

Summary

By specifying the -d flag, libdtrace will dump the D script after it has applied
syntactical sugar transformations (e.g if/else). This is useful for both understanding
what dt_sugar does, as well as debugging it.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

cddl/contrib/opensolaris/cmd/dtrace/dtrace.1
199

Probably clarify that it dumps to stdout.

cddl/contrib/opensolaris/lib/libdtrace/common/dt_sugar.c
521 ↗(On Diff #117771)

Do we actually need to do this here? Why not have the compiler dump the output script after calling dt_compile_sugar()? That seems somewhat simpler.

christos marked an inline comment as done.

Move dump code to dt_cc.c.

Would it be wiser to implement this as an extension to the -x flag?

markj added inline comments.
cddl/contrib/opensolaris/cmd/dtrace/dtrace.1
199
cddl/contrib/opensolaris/cmd/dtrace/dtrace.c
155
This revision is now accepted and ready to land.Feb 23 2023, 5:56 PM
In D38732#881808, @0mp wrote:

Would it be wiser to implement this as an extension to the -x flag?

This option is in the same vein as -S, whereas -x is used to set runtime parameters for the dtrace script. So, -x feels like the wrong place to me, but maybe I'm missing something?

In D38732#881808, @0mp wrote:

Would it be wiser to implement this as an extension to the -x flag?

This option is in the same vein as -S, whereas -x is used to set runtime parameters for the dtrace script. So, -x feels like the wrong place to me, but maybe I'm missing something?

I don't think you are missing anything :) I just wonder if there is a way to avoid taking up a whole flag for a debug feature.

OTOH, I checked macOS DTrace implementation and they are not using -d for anything, so it seems it is fine if we dedicate -d to dumping D scripts post dt_sugar.

christos marked an inline comment as done.

s/stdout/standard output/

This revision now requires review to proceed.Feb 24 2023, 12:03 AM
christos marked 2 inline comments as done.

Typo fixes.

This revision is now accepted and ready to land.Feb 24 2023, 4:10 PM

remove if/else comment in dt_cc as dt_sugar now also performs transformations
on kinst probes.

This revision now requires review to proceed.Mar 4 2023, 1:32 PM

I don't think there are any pending changes for this PR, it can get through.

I don't think there are any pending changes for this PR, it can get through.

Sorry for the delay. One last comment, and then I think it's ok.

cddl/contrib/opensolaris/cmd/dtrace/dtrace.1
200

It would be helpful to expand on this a bit: mention the example of if/else statements being implemented using syntactic transformations.

cddl/contrib/opensolaris/cmd/dtrace/dtrace.1
200

Will "...have been applied, such as if/else statements" suffice?

cddl/contrib/opensolaris/cmd/dtrace/dtrace.1
200

I'd suggest: "... have been applied. For example, if-statements in D are implemented using such transformations: a conditional clause in a probe body is replaced at compile-time by a separate probe predicated on the original condition."

christos added inline comments.
cddl/contrib/opensolaris/cmd/dtrace/dtrace.1
200

That's way better indeed. Thanks.

This revision was not accepted when it landed; it landed in state Needs Review.May 23 2023, 2:20 PM
This revision was automatically updated to reflect the committed changes.
christos marked an inline comment as done.