On 04.05.10 21:13, Yossi Lev wrote:
No, this->entry-pc is not a user-space pointer --- it is not a pointer at all,
it is an unsigned integer that I would like to convert to a string.
Here is what I'm trying to do:
- I have a structure of type ReadAcqEntry at userspace with various
numeric fields (unsigned long long type).
- I would like to convert a few of these fields to a string (e.g. for
the purpose of concatenating it with other strings), and use the
numerical value of the others.
What I was doing so far is copying the whole structure with:
this->entry =
(ReadAcqEntry*)copyin((uintptr_t)&(this->rAcqArr[this->numEntries-1]) ,
sizeof(ReadAcqEntry));
so now this->entry points to the local copy of the structure. Now I can
access all of the structure's fields as integers (I tested this part and
it works fine), but I am not sure how I can convert some of the fields
to strings. What I really need is the equivalent of sprintf or itoa...
It seems like stringof requires a pointer, so I am not sure that this is
what I need to use here.
no, you don't, regular printf will work:
printf("%d", somenumber);
stringof(p) returns string pointer to character array(p) (strings and
character arrays are not the same in DTrace), but it does not do the
integer->string conversion you're looking for.
I can't think of a way of doing the exact equivalent of "sprintf(s, "%d",
number)" and then continue using 's' within your D script. what do you need
a string for here that the numbers themselves won't solve?
Michael
--
Michael Schuster Oracle
Recursion, n.: see 'Recursion'
_______________________________________________
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org