[dtrace-discuss] values from a struct

krishnan parthasarathi - Sun Microsystems - Bangalore India
2010-09-17T10:12:05Z

Hi goinsane,


> I''d like to get values from the struct sockaddr_in which is passed
to accept . At the time of entry this struct has still no values. How could I
access the struct at return? The usage of arg0 seems useless, as this is a new
filedesriptor. Does the copyin at entry make sense at all?
>
The copyin at the entry probe does not make sense. Since the address of
the sockaddr_in structure will not be available
in argN builtin variables, you must store the addresses you are
interested in in a thread local variable. On the return probe
you can use copyin builtin method to get the contents of the sockaddr
structure.
The modified script would look like the following,

fbt:sockfs:accept:entry
{
    self->sockaddr_ref = arg1;
    self->sockaddr_len = arg2;
}

fbt:sockfs:accept:return
{
    self->sockaddr_content = (struct sockaddr_in*)
copyin(self->sockaddr_ref, self->sockaddr_len);
    /* whatever your script intends to with the sockaddr structure */
}

cheers,
Krishnan
> fbt:sockfs:accept:entry
> {
>    newsock = (struct sockaddr_in*)copyin(arg1, arg2); */
> }
>
>
> fbt:sockfs:accept:return
> {
>   /* ???  */
> }
>
>
> thank you,
>
> goinsane
>
> Message was edited by: goinsane
>