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

Mark Johnston markj at FreeBSD.org
Fri Jul 21 05:09:13 UTC 2017


On Fri, Jul 21, 2017 at 12:56:28PM +0800, Nan Xiao wrote:
> Hi Matt & Mark,
> 
> Firstly, thanks very much for your responses!
> 
> I change my script as this:
> 
> #!/usr/sbin/dtrace -x dynvarsize=64m -s
> 
> dtrace:::BEGIN
> {
> printf("Hello FreeBSD!\n");
> }
> 
> It still generates errors:
> 
> dtrace: failed to set -x  dynvarsize: Invalid option name
> 
> 
> But dynvarsize should be a valid option name.

It turns out that this won't work on FreeBSD: on a shebang line, the
tokens following the interpreter path are passed to the interpreter as a
single argument, so dtrace(1)'s option parser won't handle your example.
I think it follows that you have no choice but to specify the option
with a pragma. See the two block comments here:
https://svnweb.freebsd.org/base/head/sys/kern/imgact_shell.c?view=markup#l61


More information about the freebsd-dtrace mailing list