goinsane
2010-Oct-26 13:32 UTC
[dtrace-discuss] save and recall more than one value of the same thread
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] = ... ? And how could I evaluate them in a predicate of another probe? thank you, goinsane -- This message posted from opensolaris.org
Michael Schuster
2010-Oct-26 13:38 UTC
[dtrace-discuss] save and recall more than one value of the same thread
On 26.10.10 15:32, 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] = ... ? > And how could I evaluate them in a predicate of another probe?how about storing what interests you about this fd in self->stuff[self->fd] (where I assume self->fd is the "current" fd being opened)? would that work for your app? Michael -- michael.schuster at oracle.com http://blogs.sun.com/recursion Recursion, n.: see ''Recursion''
James Carlson
2010-Oct-26 13:43 UTC
[dtrace-discuss] save and recall more than one value of the same thread
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 <carlsonj at workingcode.com>
goinsane
2010-Oct-28 07:44 UTC
[dtrace-discuss] save and recall more than one value of the same thread
yes, it does. thank you! -- This message posted from opensolaris.org