On Fri, Aug 28, 2009 at 03:52:01PM -0400, Chad Mynhier wrote:
> You can do this with two separate DTrace invocations. The first
> catches the exec of firefox-bin and fires off the second. Something
> like this for the first one:
>
> proc:::exec-success
> / execname == "firefox-bin" /
> {
> stop();
> system("/tmp/trace-firefox.d -p %d", pid);
> }
>
> This will stop firefox-bin just after the exec. (Note that it needs
> the destructive option, -w or "#pragma D option destructive".)
> /tmp/trace-firefox.d does the tracing you want using the USDT probes
> in firefox-bin.
Don't forget to have a system("prun $pid"); action in the BEGIN probe of
the second script...
This is such a common idiom... Yet there's no obvious, safe way to
provide syntactic sugar, is there? Hmmm, maybe there is. Imagine a
pre-processor that separates probes for each process from a larger
script, generates the proc:::exec-success probe actions, and the BEGIN {
system("prun ..."); } probes. Something like:
/*
* Declare interest in doing some PID provider tracing of firefox-bin
* progeny.
*/
#pragma trace-exec second /execname == "firefox-bin" && progenyof(pid)/
/* This probe will be used for the first process */
pid$pid:...
/* This probe will be used in the firefox-bin proc(s) */
pid$second:...
Could be handy. Ideally only one instance of dtrace would be needed,
though one might ask for a separate instance in the trace-exec pragma.
Nico
--
_______________________________________________
dtrace-discuss mailing list
[email protected]