zhihui Chen
2008-Jul-20 03:15 UTC
[dtrace-discuss] Error in check value of the in-out parameter of function call
I want to check value of the in-out parameter of one function when it returns, but each time dtrace will report error. Following is the script, anyone can help me correct the error with it? #!/usr/sbin/dtrace -s #pragma D option quiet #pragma D option bufsize=4m fbt::kstrgetmsg:entry /pid==$target/ { self->arg1=arg1; } fbt::kstrgetmsg:return /pid==$target&&self->arg1/ { printf("mp=%x\n",*(uint64_t *)copyin(self->arg1,8)); self->arg1=0; } intel6# ./kstrgetmsg.d -c "rcp intel2-1:/test1000k ." rcp: dropped connection dtrace: error on enabled probe ID 2 (ID 17047: fbt:genunix:kstrgetmsg:return): invalid address (0xffffff001edd9b90) in action #1 at DIF offset 52 dtrace: error on enabled probe ID 2 (ID 17047: fbt:genunix:kstrgetmsg:return): invalid address (0xffffff001edd9b90) in action #1 at DIF offset 52 dtrace: error on enabled probe ID 2 (ID 17047: fbt:genunix:kstrgetmsg:return): invalid address (0xffffff001edd9b90) in action #1 at DIF offset 52 ....... Thanks Zhihui -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20080720/22888305/attachment.html>
James Litchfield
2008-Jul-20 05:52 UTC
[dtrace-discuss] Error in check value of the in-out parameter of function call
Isn''t the second argument to kstrgetmsg a **mblk_t (i.e., a pointer already in the kernel address space)?> *int* > 7191 kstrgetmsg <http://src.opensolaris.org/source/s?refs=kstrgetmsg>( > 7192 *struct* vnode <http://src.opensolaris.org/source/s?defs=vnode> *vp <http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/os/streamio.c#vp>, > 7193 mblk_t <http://src.opensolaris.org/source/s?defs=mblk_t> **mctlp <http://src.opensolaris.org/source/s?defs=mctlp>, > 7194 *struct* uio <http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/os/streamio.c#uio> *uiop, > 7195 *unsigned* *char* *prip <http://src.opensolaris.org/source/s?defs=prip>, > 7196 *int* *flagsp <http://src.opensolaris.org/source/s?defs=flagsp>, > 7197 clock_t <http://src.opensolaris.org/source/s?defs=clock_t> timout <http://src.opensolaris.org/source/s?defs=timout>, > 7198 rval_t <http://src.opensolaris.org/source/s?defs=rval_t> *rvp <http://src.opensolaris.org/source/s?defs=rvp>)You should be just able to do printf("mp=0x%p\n", self->arg1); Jim Litchfield zhihui Chen wrote:> I want to check value of the in-out parameter of one function when it > returns, but each time dtrace will report error. > Following is the script, anyone can help me correct the error with it? > #!/usr/sbin/dtrace -s > #pragma D option quiet > #pragma D option bufsize=4m > > fbt::kstrgetmsg:entry > /pid==$target/ > { > self->arg1=arg1; > } > > fbt::kstrgetmsg:return > /pid==$target&&self->arg1/ > { > printf("mp=%x\n",*(uint64_t *)copyin(self->arg1,8)); > self->arg1=0; > } > > intel6# ./kstrgetmsg.d -c "rcp intel2-1:/test1000k ." > rcp: dropped connection > dtrace: error on enabled probe ID 2 (ID 17047: > fbt:genunix:kstrgetmsg:return): invalid address (0xffffff001edd9b90) > in action #1 at DIF offset 52 > dtrace: error on enabled probe ID 2 (ID 17047: > fbt:genunix:kstrgetmsg:return): invalid address (0xffffff001edd9b90) > in action #1 at DIF offset 52 > dtrace: error on enabled probe ID 2 (ID 17047: > fbt:genunix:kstrgetmsg:return): invalid address (0xffffff001edd9b90) > in action #1 at DIF offset 52 > ....... > > > Thanks > Zhihui > ------------------------------------------------------------------------ > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org >
zhihui Chen
2008-Jul-21 02:19 UTC
[dtrace-discuss] Error in check value of the in-out parameter of function call
Thanks. Does this mean that all data used in Kernel can be accessed directly without using copyin and copyinstr function? I tried to trace its value with following: printf("mp=0x%x\n",*(int *)(self->arg1)); but each time the output value is 0x0, is it right? Thanks Zhihui 2008/7/20, James Litchfield <James.Litchfield at sun.com>:> > Isn''t the second argument to kstrgetmsg a **mblk_t (i.e., a > pointer already in the kernel address space)? > >> *int* >> 7191 kstrgetmsg <http://src.opensolaris.org/source/s?refs=kstrgetmsg>( >> 7192 *struct* vnode < >> http://src.opensolaris.org/source/s?defs=vnode> *vp < >> http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/os/streamio.c#vp >> >, >> 7193 mblk_t <http://src.opensolaris.org/source/s?defs=mblk_t> >> **mctlp <http://src.opensolaris.org/source/s?defs=mctlp>, >> 7194 *struct* uio < >> http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/os/streamio.c#uio> >> *uiop, >> 7195 *unsigned* *char* *prip < >> http://src.opensolaris.org/source/s?defs=prip>, >> 7196 *int* *flagsp < >> http://src.opensolaris.org/source/s?defs=flagsp>, >> 7197 clock_t <http://src.opensolaris.org/source/s?defs=clock_t> >> timout <http://src.opensolaris.org/source/s?defs=timout>, >> 7198 rval_t <http://src.opensolaris.org/source/s?defs=rval_t> >> *rvp <http://src.opensolaris.org/source/s?defs=rvp>) >> > You should be just able to do > > printf("mp=0x%p\n", self->arg1); > > Jim Litchfield > > zhihui Chen wrote: > >> I want to check value of the in-out parameter of one function when it >> returns, but each time dtrace will report error. >> Following is the script, anyone can help me correct the error with it? >> #!/usr/sbin/dtrace -s >> #pragma D option quiet >> #pragma D option bufsize=4m >> >> fbt::kstrgetmsg:entry >> /pid==$target/ >> { >> self->arg1=arg1; >> } >> >> fbt::kstrgetmsg:return >> /pid==$target&&self->arg1/ >> { >> printf("mp=%x\n",*(uint64_t *)copyin(self->arg1,8)); >> self->arg1=0; >> } >> intel6# ./kstrgetmsg.d -c "rcp intel2-1:/test1000k ." >> rcp: dropped connection >> dtrace: error on enabled probe ID 2 (ID 17047: >> fbt:genunix:kstrgetmsg:return): invalid address (0xffffff001edd9b90) in >> action #1 at DIF offset 52 >> dtrace: error on enabled probe ID 2 (ID 17047: >> fbt:genunix:kstrgetmsg:return): invalid address (0xffffff001edd9b90) in >> action #1 at DIF offset 52 >> dtrace: error on enabled probe ID 2 (ID 17047: >> fbt:genunix:kstrgetmsg:return): invalid address (0xffffff001edd9b90) in >> action #1 at DIF offset 52 >> ....... >> >> Thanks >> Zhihui >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> dtrace-discuss mailing list >> dtrace-discuss at opensolaris.org >> >> > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20080721/9cad57cc/attachment.html>
James Litchfield
2008-Jul-21 14:59 UTC
[dtrace-discuss] Error in check value of the in-out parameter of function call
zhihui Chen wrote:> Thanks. Does this mean that all data used in Kernel can be accessed > directly without using copyin and copyinstr function? >Mostly. There are a number of places where addresses are passed around in the kernel that have a flag in another register or structure that indicates this address actually refers to user data and must be copied in before accessing (e.g., the early stages of processing a write system call). Some cases refer to addresses where date will be placed when done (e.g., read system call). It really is important to spend some time following the code through various calls of interest and looking to see how variables are used.> I tried to trace its value with following: > printf("mp=0x%x\n",*(int *)(self->arg1)); > > but each time the output value is 0x0, is it right? >Haven''t any idea without spending more time looking at things. Jim ----> Thanks > Zhihui > > 2008/7/20, James Litchfield <James.Litchfield at sun.com > <mailto:James.Litchfield at sun.com>>: > > Isn''t the second argument to kstrgetmsg a **mblk_t (i.e., a > pointer already in the kernel address space)? > > *int* > 7191 kstrgetmsg > <http://src.opensolaris.org/source/s?refs=kstrgetmsg>( > 7192 *struct* vnode > <http://src.opensolaris.org/source/s?defs=vnode> *vp > <http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/os/streamio.c#vp>, > 7193 mblk_t > <http://src.opensolaris.org/source/s?defs=mblk_t> **mctlp > <http://src.opensolaris.org/source/s?defs=mctlp>, > 7194 *struct* uio > <http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/os/streamio.c#uio> > *uiop, > 7195 *unsigned* *char* *prip > <http://src.opensolaris.org/source/s?defs=prip>, > 7196 *int* *flagsp > <http://src.opensolaris.org/source/s?defs=flagsp>, > 7197 clock_t > <http://src.opensolaris.org/source/s?defs=clock_t> timout > <http://src.opensolaris.org/source/s?defs=timout>, > 7198 rval_t > <http://src.opensolaris.org/source/s?defs=rval_t> *rvp > <http://src.opensolaris.org/source/s?defs=rvp>) > > You should be just able to do > > printf("mp=0x%p\n", self->arg1); > > Jim Litchfield > > zhihui Chen wrote: > > I want to check value of the in-out parameter of one function > when it returns, but each time dtrace will report error. > Following is the script, anyone can help me correct the error > with it? > #!/usr/sbin/dtrace -s > #pragma D option quiet > #pragma D option bufsize=4m > > fbt::kstrgetmsg:entry > /pid==$target/ > { > self->arg1=arg1; > } > > fbt::kstrgetmsg:return > /pid==$target&&self->arg1/ > { > printf("mp=%x\n",*(uint64_t *)copyin(self->arg1,8)); > self->arg1=0; > } > intel6# ./kstrgetmsg.d -c "rcp intel2-1:/test1000k ." > rcp: dropped connection > dtrace: error on enabled probe ID 2 (ID 17047: > fbt:genunix:kstrgetmsg:return): invalid address > (0xffffff001edd9b90) in action #1 at DIF offset 52 > dtrace: error on enabled probe ID 2 (ID 17047: > fbt:genunix:kstrgetmsg:return): invalid address > (0xffffff001edd9b90) in action #1 at DIF offset 52 > dtrace: error on enabled probe ID 2 (ID 17047: > fbt:genunix:kstrgetmsg:return): invalid address > (0xffffff001edd9b90) in action #1 at DIF offset 52 > ....... > > Thanks > Zhihui > ------------------------------------------------------------------------ > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org > <mailto:dtrace-discuss at opensolaris.org> > > >
Jonathan Adams
2008-Jul-24 00:45 UTC
[dtrace-discuss] Error in check value of the in-out parameter of function call
On Sun, Jul 20, 2008 at 11:15:43AM +0800, zhihui Chen wrote:> I want to check value of the in-out parameter of one function when it > returns, but each time dtrace will report error. > Following is the script, anyone can help me correct the error with it? > #!/usr/sbin/dtrace -s > #pragma D option quiet > #pragma D option bufsize=4m > > fbt::kstrgetmsg:entry > /pid==$target/ > { > self->arg1=arg1;This should really be: self->arg1 = args[1]; That way, it will get the correct type automatically.> } > fbt::kstrgetmsg:return > /pid==$target&&self->arg1/ > { > printf("mp=%x\n",*(uint64_t *)copyin(self->arg1,8));And this should be: printf("mp=%x\n", *self->arg1); Cheers, - jonathan> self->arg1=0; > } > > intel6# ./kstrgetmsg.d -c "rcp intel2-1:/test1000k ." > rcp: dropped connection > dtrace: error on enabled probe ID 2 (ID 17047: > fbt:genunix:kstrgetmsg:return): invalid address (0xffffff001edd9b90) in > action #1 at DIF offset 52 > dtrace: error on enabled probe ID 2 (ID 17047: > fbt:genunix:kstrgetmsg:return): invalid address (0xffffff001edd9b90) in > action #1 at DIF offset 52 > dtrace: error on enabled probe ID 2 (ID 17047: > fbt:genunix:kstrgetmsg:return): invalid address (0xffffff001edd9b90) in > action #1 at DIF offset 52 > ....... > > > Thanks > Zhihui> _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org