Hi Joel,
> I''m running dtrace with multiple scripts, e.g. -s foo.d -s bar.d
-s baz.d.
>
> It looks like variables in one script overwrite variables in another. I
> was expecting, perhaps wrongfully, that variables would be per-script
> and not per dtrace run.
I guess it may not be too obvious from the docs. Basically, globals
and thread locals are shared across all the separate compilation
units you specify on the command line (across foo.d, bar.d and
baz.d in your case). We evaluate left to right on the command
line so anything declared in foo.d will be available for use
in bar.d and baz.d.
The above doesn''t apply to clause local variables as the
scope of a clause local is just for the compilation unit.
> Am I correct that dtrace "merges" all the scripts into a single
one
> before running, e.g. that I could have pasted all the scripts into a
> single one for exactly the same result?
It kind of looks like that from a user experience apart from the
difference in how clause locals behave as noted above. Under the hood
we compile them individually, collecting state as we go. When all the
scripts have been compiled the system is then instrumented accordingly
as each blob of byte code is sent down into the kernel (which is
where instrumentation actually takes place).
Jon.