When using the %ws conversion in printf i get:
dtrace: failed to compile script script.d: line 9: printf( ) argument #2 is
incompatible with conversion #1 prototype:
conversion: %ws
prototype: wchar_t []
argument: char *
However, the wchar_t type does not seem to exist. What''s wrong in my
script?
This message posted from opensolaris.org
Here is the (edited) script:
#!/usr/sbin/dtrace -s
this char * p;
pid$target::mystery_function:entry
{
printf("%a\n", arg1);
this->p = copyin(arg1,64);
printf("inarg1: %ws", this->p);
}
This message posted from opensolaris.org
Gonzalo Siero Humet
2005-Aug-23 12:59 UTC
[dtrace-discuss] Re: printf and the %ws conversion
Hi,
which is the type of arg1 for your "mystery_function"??
you''re defining "this->p" as (char *) but printing with
%ws ("..The
argument must be a pointer to an array of wchar_t.." hence the error.
if arg1 is (char *) you must use %s in printf...
HTH,
Gonzalo.
Simon Marechal wrote:> Here is the (edited) script:
>
> #!/usr/sbin/dtrace -s
>
> this char * p;
>
> pid$target::mystery_function:entry
> {
> printf("%a\n", arg1);
> this->p = copyin(arg1,64);
> printf("inarg1: %ws", this->p);
> }
> This message posted from opensolaris.org
> _______________________________________________
> dtrace-discuss mailing list
> dtrace-discuss at opensolaris.org
It is an unicode string. I guess the closest type is short *. Using %s wont work
because of the interleaved 0''s.
I right now use something like:
printf("%c%c%c%c ...", this->p[0], this->p[2], this->p[4],
...);
which is not good since i cannot predict the string length
This message posted from opensolaris.org