Hi, I''m a nub in dtrace, could you please help me to find the mistake? I need to implement the logic: - if PID and TID are defined, fire the probe for the particular thread of particular process; - if only PID is defined, fire the probe for the process including all threads. The predicat [i]syscall:::entry / (pid == PID && tid == TID )[/i] / works ok and return syscall for PID/TID process only. Then I set a predicat: [i] syscall:::entry /(pid == PID && tid == TID) || pid == PID/[/i] and it works for the whole process, as if I set only / pid == PID/. What am I missing? Thanks in advance. -- This message posted from opensolaris.org
On Thu, Sep 17, 2009 at 9:17 AM, Eugenias <redtigrareg at gmail.com> wrote:> Hi, > > I''m a nub in dtrace, could you please help me to find the mistake? > > I need to implement the logic: > > - if PID and TID are defined, fire the probe for the particular thread of particular process; > - if only PID is defined, fire the probe for the process including all threads. > > The predicat ?[i]syscall:::entry / (pid == PID && tid == TID )[/i] / works ok and return syscall for PID/TID process only. > > Then I set a predicat: > > [i] syscall:::entry > ?/(pid == PID && tid == TID) || > ?pid == PID/[/i] > > and it works for the whole process, as if I set only / pid == PID/. > What am I missing?I''m a little bit confused about what you want to do. If you want to perform one set of actions if the tid matches and a different set of actions if it doesn''t, you want this: syscall:::entry / pid == PID && tid == TID / { [ one set of actions ] } syscall:::entry / pid == PID && tid != TID / { [ a different set of actions ] } If you want to perform one set of actions no matter the tid and an additional set of actions if the tid matches, you want this: syscall:::entry / pid == PID / { [ one set of actions ] } syscall:::entry / pid == PID && tid == TID / { [ additional set of actions ] } (It''s probably worth noting that "/ (pid == PID && tid == TID) || pid == PID /" is logically equivalent to "/ pid == PID /".) Chad
Thanks a lot! You gave me an idea I needed. I tried to enhance the dtruss tool (http://www.brendangregg.com/DTrace/dtruss) to be possible to monitor the particular thread of the process. The final predicat looks in that way: syscall:::entry /(OPT_command && pid == $target) || (OPT_tid && (pid == PID && tid == TID)) || ((OPT_pid && pid == PID) && OPT_tid == 0) || (OPT_name && execname == NAME) || (self->child)/ So now the command like: ./dtruss.d -a -l -p 5506 -w 28 Returns me syscolls for the pid=5506, tid=28 THANKS A LOT! -- This message posted from opensolaris.org
Thanks for spelling that out what you were working with. As a matter of style, splitting the test logic across probe declarations sure would be easier to read (and reread). All that opt_* test logic in one predicate requires the maintainer to understand the preamble. For example, when is OPT_command set? When opt_pid and opt_name are not, which means a command should be given instead (otherwise the help option triggers). If there is a command, it is read from $* which, judging by the documented comment may throw off a reader from time to time. While I trust there isn''t a substantively cleaner way to add so many options, in this case I would opt for separating concerns and choosing clarity of expression over economy. Just a US$0.02 observation based on the time it took me to unravel your solution... Regards, Michael -- This message posted from opensolaris.org
Possibly Parallel Threads
- Using dapptrace. Can't seem to trace user functions with defaults or specifying -u<lib>
- OSX 10.6.4 error with -R option
- Oracle 9 process on Sol 10 container, doing a pollsys, using high CPU
- Why does it appear that dovecot is deleting messages after migration?
- Dovecot-2.1.14 - pop3 processes always hangs forever - another follow-up