Janice Chang
2007-Nov-20 15:52 UTC
[dtrace-discuss] How to dereference a pointer to a pointer
Hi. I would like to print out a field of a vnode, but the argument to the function is of type vnode_t **. If I set "this->vpp" to arg2 in an entry function to zfs_lookup(), I''d like to retrieve the value of one of the fields of *(this->vpp) in the return function. Something like the below (but the syntax below is not right): printf("zfs_lookup: %d", (*((vnode_t **)this->vpp))->v_count); Would appreciate any tips on how to do this. Thanks, Janice
James Carlson
2007-Nov-20 16:06 UTC
[dtrace-discuss] How to dereference a pointer to a pointer
Janice Chang writes:> If I set "this->vpp" to arg2 in an entry function to zfs_lookup(), I''dDo you really mean "this" or do you mean "self?" The latter is the one that is tied to a thread and spans action blocks. The former gets discarded at the end of the current action (and wouldn''t be useful for saving data between function entry and return, for example).> like to retrieve the value of one of the fields of *(this->vpp) in the > return function. Something like the below (but the syntax below is not > right): > > printf("zfs_lookup: %d", (*((vnode_t **)this->vpp))->v_count);Typically, when I assign a variable in dtrace, I cast it first, like this: fbt::foo:entry { self->vpp = (vnode_t **)arg0; } fbt::foo:return /self->vpp/ { printf("zfs_lookup: %d", (*self->vpp)->v_count); self->vpp = 0; } -- James Carlson, Solaris Networking <james.d.carlson at sun.com> Sun Microsystems / 35 Network Drive 71.232W Vox +1 781 442 2084 MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677
-----Original Message----- From: dtrace-discuss-bounces at opensolaris.org [mailto:dtrace-discuss-bounces at opensolaris.org] On Behalf Of James Carlson Sent: Tuesday, November 20, 2007 11:07 AM To: Janice Chang Cc: dtrace-discuss at opensolaris.org Subject: Re: [dtrace-discuss] How to dereference a pointer to a pointer Janice Chang writes:> If I set "this->vpp" to arg2 in an entry function to zfs_lookup(), I''dDo you really mean "this" or do you mean "self?" The latter is the one that is tied to a thread and spans action blocks. The former gets discarded at the end of the current action (and wouldn''t be useful for saving data between function entry and return, for example).> like to retrieve the value of one of the fields of *(this->vpp) in the> return function. Something like the below (but the syntax below isnot> right): > > printf("zfs_lookup: %d", (*((vnode_t **)this->vpp))->v_count);Typically, when I assign a variable in dtrace, I cast it first, like this: fbt::foo:entry { self->vpp = (vnode_t **)arg0; } fbt::foo:return /self->vpp/ { printf("zfs_lookup: %d", (*self->vpp)->v_count); self->vpp = 0; } -- James Carlson, Solaris Networking <james.d.carlson at sun.com> Sun Microsystems / 35 Network Drive 71.232W Vox +1 781 442 2084 MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677 _______________________________________________ dtrace-discuss mailing list dtrace-discuss at opensolaris.org
Jon Haslam
2007-Nov-20 17:15 UTC
[dtrace-discuss] How to dereference a pointer to a pointer
> Typically, when I assign a variable in dtrace, I cast it first, like > this: > > fbt::foo:entry > { > self->vpp = (vnode_t **)arg0; > }There''s no need to cast in this situation though as, with the fbt provider, you can just access typed arguments through the args[] array. Just use args[2] for zfs_lookup:entry in this case. Jon.
James Carlson
2007-Nov-20 17:30 UTC
[dtrace-discuss] How to dereference a pointer to a pointer
Jon Haslam writes:> > > Typically, when I assign a variable in dtrace, I cast it first, like > > this: > > > > fbt::foo:entry > > { > > self->vpp = (vnode_t **)arg0; > > } > > There''s no need to cast in this situation though as, with > the fbt provider, you can just access typed arguments through > the args[] array. Just use args[2] for zfs_lookup:entry in > this case.Yes; you''re right about that. I was trying to make it a little more generic ... The issue I was pointing out was that the automatic creation process for "self->" variables saves off the data type, and that can be a handy property to simplify a mass of casts later in the code. -- James Carlson, Solaris Networking <james.d.carlson at sun.com> Sun Microsystems / 35 Network Drive 71.232W Vox +1 781 442 2084 MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677
Janice Chang
2008-Jan-18 17:50 UTC
[dtrace-discuss] How to dereference a pointer to a pointer
Hello. I would like to ask for some help on a dtrace script I am writing. The following set of dtrace functions seems not to work....I see output for the entry function as expected, but I do not see a corresponding return value being returned. Actually the return function was more complicated but it was not working. When I decided to simply test using a return value I realized that that did not work either. When I remove the predicate from the entry function, I see output for every entry (including those with the "SUNW..." string), but only return values for the calls whose args[2] do not correspond to the "SUNW" string. Using an entry predicate where args[2] corresponds to a more standard name seems to fare better. I am not sure if the problem is the ''$'' or if it might be something else. Thank you very much for your help. Janice =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-fbt::zap_lookup_norm:entry / args[2] == "SUNWsmb:stream4.txt:$DATA" / { self->path = args[7]; printf("zap_lookup_norm entry: %s\n", stringof(args[2])); } fbt::zap_lookup_norm:return /self->path/ { trace(arg1); } =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Janice Chang
2008-Jan-18 17:53 UTC
[dtrace-discuss] How to dereference a pointer to a pointer
Ok--I may have found the problem (easy)--I had assumed self->path was always non-NULL. Thanks anyway!! Janice Janice Chang wrote:> Hello. I would like to ask for some help on a dtrace script I am writing. > > The following set of dtrace functions seems not to work....I see output > for the entry function as expected, but I do not see a corresponding > return value being returned. Actually the return function was more > complicated but it was not working. When I decided to simply test using > a return value I realized that that did not work either. > > When I remove the predicate from the entry function, I see output for > every entry (including those with the "SUNW..." string), but only return > values for the calls whose args[2] do not correspond to the "SUNW" string. > > Using an entry predicate where args[2] corresponds to a more standard > name seems to fare better. > > I am not sure if the problem is the ''$'' or if it might be something else. > > Thank you very much for your help. > > Janice > > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> fbt::zap_lookup_norm:entry > / args[2] == "SUNWsmb:stream4.txt:$DATA" / > { > self->path = args[7]; > printf("zap_lookup_norm entry: %s\n", stringof(args[2])); > } > > fbt::zap_lookup_norm:return > /self->path/ > { > trace(arg1); > } > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org >
Seemingly Similar Threads
- kernel vhost demands an interrupt from guest when the ring is full in order to enable guest to submit new packets to the queue
- kernel vhost demands an interrupt from guest when the ring is full in order to enable guest to submit new packets to the queue
- kernel vhost demands an interrupt from guest when the ring is full in order to enable guest to submit new packets to the queue
- kernel panic caused by zfs/sa.c
- grid.layout?