andrew rutz
2007-Apr-18 21:04 UTC
[dtrace-discuss] dtrace-discuss: cannot get a ''string'' to print...
hi, I''m using the PID provider to trace a 32-bit app, prtdiag. I''m trying to print the value of "propname" (arg1) in the following func: int picl_get_propval_by_name(picl_nodehdl_t nodeh, const char *propname, void *valbuf, size_t nbytes) ... i''ve tried many versions, but this is a representative one: 53 this string propname; 54 55 pid$target:libpicl.so.1:picl_get_propval_by_name:entry 56 / self->trace / 57 { 58 this->propname = (string) arg2; 59 trace(this->propname); ''arg2'' is used because this is a 32-bit app, and the first formal-argument is 64-bits, and so the compiled code has the 64 bits in %i0 and %i1. when i run this, all i get is: dtrace: error on enabled probe ID 4 (ID 52196: pid960:libpicl.so.1:picl_get_propval_by_name:entry): invalid address (0xff1d77c4) in predicate at DIF offset 20 i''ve single-stepped w/ mdb and printed the string using mdb''s "/s". I boundary-checked the alleged bad-addr using "::mappings". how do i print the string ???? (I''ve printed strings before ! ;-) tnx ps - is there some problem because my arg2 is a "const char *" ?
Adam Leventhal
2007-Apr-18 21:11 UTC
[dtrace-discuss] dtrace-discuss: cannot get a ''string'' to print...
You need to use copyinstr(): http://docs.sun.com/app/docs/doc/817-6223/6mlkidlmf?a=view Adam On Wed, Apr 18, 2007 at 04:04:30PM -0500, andrew rutz wrote:> hi, > I''m using the PID provider to trace a 32-bit app, prtdiag. > > I''m trying to print the value of "propname" (arg1) in the > following func: > > int > picl_get_propval_by_name(picl_nodehdl_t nodeh, const char *propname, > void *valbuf, size_t nbytes) > ... > > > i''ve tried many versions, but this is a representative one: > > 53 this string propname; > 54 > 55 pid$target:libpicl.so.1:picl_get_propval_by_name:entry > 56 / self->trace / > 57 { > 58 this->propname = (string) arg2; > 59 trace(this->propname); > > ''arg2'' is used because this is a 32-bit app, and the first > formal-argument is 64-bits, and so the compiled code has the > 64 bits in %i0 and %i1. > > when i run this, all i get is: > > dtrace: error on enabled probe ID 4 (ID 52196: > pid960:libpicl.so.1:picl_get_propval_by_name:entry): invalid address > (0xff1d77c4) in predicate at DIF offset 20 > > > i''ve single-stepped w/ mdb and printed the string using mdb''s "/s". > I boundary-checked the alleged bad-addr using "::mappings". > > how do i print the string ???? > > (I''ve printed strings before ! ;-) > > tnx > > ps - is there some problem because my arg2 is a "const char *" ? > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Adam Leventhal, Solaris Kernel Development http://blogs.sun.com/ahl
Pat Pinchera
2007-Apr-19 20:00 UTC
[dtrace-discuss] dtrace-discuss: cannot get a ''string'' to print...
Adam, Does the same thing apply if you wanted the value of arg3, in this case, an "size_t" type rather than a char* ? Would I use copyin(arg2) ? I was trying to do this sort of thing yesterday and although my simple test program gave me the correct and expected results, the output from my customer''s code was suspect. Thanks, Pat Adam Leventhal wrote:>You need to use copyinstr(): > >http://docs.sun.com/app/docs/doc/817-6223/6mlkidlmf?a=view > >Adam > >On Wed, Apr 18, 2007 at 04:04:30PM -0500, andrew rutz wrote: > > >>hi, >> I''m using the PID provider to trace a 32-bit app, prtdiag. >> >> I''m trying to print the value of "propname" (arg1) in the >>following func: >> >>int >>picl_get_propval_by_name(picl_nodehdl_t nodeh, const char *propname, >> void *valbuf, size_t nbytes) >>... >> >> >>i''ve tried many versions, but this is a representative one: >> >> 53 this string propname; >> 54 >> 55 pid$target:libpicl.so.1:picl_get_propval_by_name:entry >> 56 / self->trace / >> 57 { >> 58 this->propname = (string) arg2; >> 59 trace(this->propname); >> >>''arg2'' is used because this is a 32-bit app, and the first >>formal-argument is 64-bits, and so the compiled code has the >>64 bits in %i0 and %i1. >> >>when i run this, all i get is: >> >>dtrace: error on enabled probe ID 4 (ID 52196: >>pid960:libpicl.so.1:picl_get_propval_by_name:entry): invalid address >>(0xff1d77c4) in predicate at DIF offset 20 >> >> >>i''ve single-stepped w/ mdb and printed the string using mdb''s "/s". >>I boundary-checked the alleged bad-addr using "::mappings". >> >>how do i print the string ???? >> >>(I''ve printed strings before ! ;-) >> >>tnx >> >>ps - is there some problem because my arg2 is a "const char *" ? >> >>_______________________________________________ >>dtrace-discuss mailing list >>dtrace-discuss at opensolaris.org >> >> > > >
Dan Mick
2007-Apr-19 20:53 UTC
[dtrace-discuss] dtrace-discuss: cannot get a ''string'' to print...
No; copyin is used to copy memory from userland to kernel, so that kernel DTrace probes can access it. In the case of a size_t, that value is passed to the function directly; it doesn''t refer to user memory. Strings, however, are passed as pointers-to-memory, so the actual string value is still in user memory. copyin would be useful for arguments passed as pointers to structures, as the third argument to ioctl() often is, for example. Pat Pinchera wrote:> Adam, > > Does the same thing apply if you wanted the value of arg3, in this case, > an "size_t" type rather than a char* ? Would I use copyin(arg2) ? > > I was trying to do this sort of thing yesterday and although my simple > test program gave me the correct and expected results, the output from > my customer''s code was suspect. > > Thanks, > Pat > > > > Adam Leventhal wrote: > >> You need to use copyinstr(): >> >> http://docs.sun.com/app/docs/doc/817-6223/6mlkidlmf?a=view >> >> Adam >> >> On Wed, Apr 18, 2007 at 04:04:30PM -0500, andrew rutz wrote: >> >> >>> hi, >>> I''m using the PID provider to trace a 32-bit app, prtdiag. >>> >>> I''m trying to print the value of "propname" (arg1) in the >>> following func: >>> >>> int >>> picl_get_propval_by_name(picl_nodehdl_t nodeh, const char *propname, >>> void *valbuf, size_t nbytes) >>> ... >>> >>> >>> i''ve tried many versions, but this is a representative one: >>> >>> 53 this string propname; >>> 54 >>> 55 pid$target:libpicl.so.1:picl_get_propval_by_name:entry >>> 56 / self->trace / >>> 57 { >>> 58 this->propname = (string) arg2; >>> 59 trace(this->propname); >>> >>> ''arg2'' is used because this is a 32-bit app, and the first >>> formal-argument is 64-bits, and so the compiled code has the >>> 64 bits in %i0 and %i1. >>> >>> when i run this, all i get is: >>> >>> dtrace: error on enabled probe ID 4 (ID 52196: >>> pid960:libpicl.so.1:picl_get_propval_by_name:entry): invalid address >>> (0xff1d77c4) in predicate at DIF offset 20 >>> >>> >>> i''ve single-stepped w/ mdb and printed the string using mdb''s "/s". >>> I boundary-checked the alleged bad-addr using "::mappings". >>> >>> how do i print the string ???? >>> >>> (I''ve printed strings before ! ;-) >>> >>> tnx >>> >>> ps - is there some problem because my arg2 is a "const char *" ? >>> >>> _______________________________________________ >>> dtrace-discuss mailing list >>> dtrace-discuss at opensolaris.org >>> >> >> >> > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org
Maybe Matching Threads
- [PATCH 7/7] [v6] drivers/virt: introduce Freescale hypervisor management driver
- [PATCH 7/7] [v6] drivers/virt: introduce Freescale hypervisor management driver
- [PATCH 7/7] [v5] drivers/virt: introduce Freescale hypervisor management driver
- [PATCH 7/7] [v5] drivers/virt: introduce Freescale hypervisor management driver
- [PATCH][RFC][12+2][v3] A expanded CFQ scheduler for cgroups