On Fri, Aug 28, 2009 at 4:44 PM, Nicolas
Williams<[email protected]> wrote:
> 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...
>
Nope, DTrace will actually take care of that for you. Consider this
script, /tmp/foo.d:
#!/usr/sbin/dtrace -qws
proc:::exec-success
/ execname == "ls" /
{
stop();
system("%s -p %d", $1, pid);
}
and this script, /tmp/bar.d:
#!/usr/sbin/dtrace -qs
pid$target::main:entry
{
printf("Entered main()\n");
exit(0);
}
When I run these and run ls a couple of times in another shell, I see this:
x2200# /tmp/foo.d /tmp/bar.d
Entered main()
Entered main()
^C
x2200#
And the ls's complete normally in the other shell.
Chad
_______________________________________________
dtrace-discuss mailing list
[email protected]