Does DTrace script only support "#pragma D option ..", not "-x option"?

Matthew Ahrens mahrens at delphix.com
Fri Jul 21 04:27:28 UTC 2017


On Thu, Jul 20, 2017 at 8:03 PM, Nan Xiao <xiaonan830818 at gmail.com> wrote:

> Hi all,
>
> My FreeBSD version is 11.0, and I write a simple DTrace script:
>
> #!/usr/sbin/dtrace -s -x dynvarsize=64m
>
> dtrace:::BEGIN
> {
>         printf("Hello FreeBSD!\n");
> }
>
> Running it will generate following error:
>
> dtrace: failed to open  -x dynvarsize=64m: No such file or directory
>
>
> So does DTrace only support using "#pragma D option dynvarsize=64m" format
> in script? I remembered Solaris can support both formats.
>

This doesn't work on Solaris, because (at least on Solaris/illumos) shebang
binaries only support one argument; further arguments are silently
ignored.  So your script does execute on Solaris, but the "-x
dynvarsize=64m" is ignored.

And as Mark said, the -s needs to be last.  But (on Solaris) then it'll be
ignored because it isn't the first argument.  You can combine multiple
no-argument flags in the shebang line, e.g.:

#!/usr/sbin/dtrace -vZs
...

--matt


>
> Thanks!
>
> Best Regards
> Nan Xiao
> _______________________________________________
> freebsd-dtrace at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace
> To unsubscribe, send any mail to "freebsd-dtrace-unsubscribe at freebsd.org"
>


More information about the freebsd-dtrace mailing list