goinsane wrote:
> Hi,
> 
> I'd like to know if D enables to save and recall values of the same thread in 
> a way like self->... does.
> 
> Let's say a thread fires syscall::open:entry two times and gets 2 
> filedescriptors. How could I save those in syscall::open:return for later 
> reuse?
> The use of just 1 variable (e.g.self->fd) only would overwrite the value at 
> the 2nd call. Maybe an associative array would tend to a solution, like 
> self->fd[port] = ...  ?

Yep; that's how you'd do it.

Note that this might not work quite the way you want for multi-threaded
programs that use the same fd in more than one thread.  To handle that
case (which is a superset of the case you're looking at), I think you'd
need a global array indexed on pid and fd, because fds are allocated to
a process, not a thread, and D doesn't seem to have a per-process
storage mechanism.

> And how could I evaluate them in a predicate of another probe?

self->fd[port] -- where "port" needs to be the fd.  Depending on the
definition of the probe and the way you write your code, "port" might be
argv0, or it might be self->port, or perhaps something else.

-- 
James Carlson         42.703N 71.076W         <carls...@workingcode.com>
_______________________________________________
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org

Reply via email to