[prev in list] [next in list] [prev in thread] [next in thread] 

List:       opensolaris-dtrace-discuss
Subject:    Re: [dtrace-discuss] dtracing a forked process OR dynamic library
From:       Ray Hassan <Ray.Hassan () Sun ! COM>
Date:       2009-11-20 14:37:17
Message-ID: 4B06A99D.2030500 () sun ! com
[Download RAW message or body]

Angelo Rajadurai wrote:
> Hey Pete:
> 
> If you need to look at processes that are in the process tree of a given process. \
> (ie) child of a child process etc, then you can use the progenyof() action.  
> You would replace the predicate /ppid == $target/ by /progenyof($target)/
> 
> HTHs
> 
> Angelo
> 
> 
> 
An example of which might be :

$ more rac1.d
#pragma D option destructive

syscall::*fork*:return
/progenyof($target) && pid!=$target/
{
    stop();
    printf("%s, %d, %d", execname, pid, curpsinfo->pr_ppid);
    system("/rayh/t_open.d %d &", pid);
    exit(0);
}

and t_open.d looks like:

$ more t_open.d
#!/usr/sbin/dtrace -Fs

#pragma D option destructive
#pragma D option flowindent

BEGIN
{
        printf("prun'ing process %d\n", $1);
        system("prun %d\n", $1);
}

pid$1::mdmn_resume:entry
{
    self->follow = 1;
}

pid$1::_tx_open:entry
/self->follow/
{
    self->path = arg0;
    printf("%s\n", stringof(copyinstr(self->path)));
}

pid$1::_tx_open:return
/self->follow && (int)arg0 == -1/
{
    printf("errno : %d\n", errno);
    ustack();
}

pid$1::mdmn_resume:return
{
    self->follow = 0;
}

I would also advise taking a look at the Sun Developer pages on sunsolve 
or bigadmin if you have such access.

Hope this is what you are looking for
ray
> On Nov 19, 2009, at 3:15 PM, Peter Shoults wrote:
> 
> 
> > On 11/19/09 15:00, michael schuster wrote:
> > 
> > > Peter Shoults wrote:
> > > 
> > > > I suspect it is to stop the child process before it goes and does
> > > > whatever it is that we might want to capture. 
> > > > 
> > > right - not everything "in" dtrace happens synchronously (ie not all
> > > actions are executed at the time the probe fires - an example for that
> > > are the repeated reports of "I see hex numbers instead of symbols
> > > reported"), and stop makes sure the child process doesn't go and do
> > > all the interesting work before dtrace gets instrumentation in place -
> > > or so I understand it.
> > > 
> > > Michael
> > > 
> > Ok - but how does one get that going again.....
> > 
> > Here is what I believe is my scenario....
> > 
> > PROC1 forks PROC2
> > 
> > PROC2 forks several other procs (I believe I am not interested in any of
> > these, but not 100% certain)
> > 
> > meanwhile...
> > 
> > PROC1 forks PROC3 (this I believe is the proc I am interested in)
> > 
> > What I want to be able to do is trace all the forked processes, but
> > especially PROC3.  I have found I can not use the self-> thread local
> > variable.  Wondering about setting an array to store ppid to predicate
> > on, but then I can't think of how to get to predicate on an array of
> > unknown number of variables.
> > 
> > Pete
> > _______________________________________________
> > dtrace-discuss mailing list
> > dtrace-discuss@opensolaris.org
> > 
> 
> _______________________________________________
> dtrace-discuss mailing list
> dtrace-discuss@opensolaris.org
> 

_______________________________________________
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic