Hi, All I have run onto inability to trace (long long) return values - please see details below. Is there a way to get it correctly ? Thanks in advance inline unsigned long long ret_ll(void){ return (unsigned long long)(-1); } int main( int argc, char* argv[] ){ while( 1 ){ ret_ll(); sleep(1); } } Here is what I am getting: # isainfo -b 64 # dtrace -n "pid`pgrep ret_ll`::ret_ll:return{trace(arg1)}" dtrace: description ''pid5633::ret_ll:return'' matched 1 probe CPU ID FUNCTION:NAME 0 47874 ret_ll:return 4294967295 <-- it is definately not a (long long) PS: have tried as well: # dtrace -n "pid`pgrep ret_ll`::ret_ll:return{printf(\"%lld\", (long long)arg1)}" dtrace: description ''pid13837::ret_ll:return'' matched 1 probe CPU ID FUNCTION:NAME 1 47874 ret_ll:return 4294967295 <-- more like just (int) -- This message posted from opensolaris.org
Chip Bennett
2008-Oct-14 19:46 UTC
[dtrace-discuss] printing (long long) arg1 on :::return
Anatoli, I think your C executable is 32 bit. I recompiled it into a 64 bit binary, and it worked correctly. However, a long long in a 32 bit binary should be 64 bits, so I also tried the -32 option with dtrace, and that didn''t seem to make any difference. If you look at the assembly code for each compilation (32 bit and 64 bit), there is a distinct difference in the way the return value is processed. (I used gcc.) 32-bit snipit... sethi %hi(4294966272), %i4 or %i4, 1023, %i4 sethi %hi(4294966272), %i5 or %i5, 1023, %i5 mov %i4, %i0 mov %i5, %i1 ret restore 64-bit snipit... mov -1, %g1 mov %g1, %i0 return %i7+8>From the value you are getting (actually a 32 bit -1), I suspect thatDTrace is only grabbing %i0 and putting it arg0, which is sufficient for a 64 bit app, but for a 32 bit app returning a long long, the return value comes back in %i0 _and_ %i1. I don''t know why DTrace is not picking up %i1. I was hoping the -32 option would have triggered that. Anybody else got any thoughts? Chip> -----Original Message----- > From: dtrace-discuss-bounces at opensolaris.org [mailto:dtrace-discuss- > bounces at opensolaris.org] On Behalf Of Anatoli > Sent: Tuesday, October 14, 2008 12:10 PM > To: dtrace-discuss at opensolaris.org > Subject: [dtrace-discuss] printing (long long) arg1 on :::return > > Hi, All > I have run onto inability to trace (long long) return values - please > see details below. > Is there a way to get it correctly ? > Thanks in advance > > inline unsigned long long ret_ll(void){ > return (unsigned long long)(-1); > } > > int main( int argc, char* argv[] ){ > while( 1 ){ > ret_ll(); > sleep(1); > } > } > > Here is what I am getting: > > # isainfo -b > 64 > # dtrace -n "pid`pgrep ret_ll`::ret_ll:return{trace(arg1)}" > dtrace: description ''pid5633::ret_ll:return'' matched 1 probe > CPU ID FUNCTION:NAME > 0 47874 ret_ll:return 4294967295 <-- it > is definately not a (long long) > > PS: have tried as well: > # dtrace -n "pid`pgrep ret_ll`::ret_ll:return{printf(\"%lld\", (long > long)arg1)}" > dtrace: description ''pid13837::ret_ll:return'' matched 1 probe > CPU ID FUNCTION:NAME > 1 47874 ret_ll:return 4294967295 <-- > more like just (int) > -- > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org
Jonathan Adams
2008-Oct-14 19:56 UTC
[dtrace-discuss] printing (long long) arg1 on :::return
On Tue, Oct 14, 2008 at 10:10:20AM -0700, Anatoli wrote:> Hi, All > I have run onto inability to trace (long long) return values - please > see details below. Is there a way to get it correctly ?> Thanks in advance >...> Here is what I am getting: > > # isainfo -b > 64 > # dtrace -n "pid`pgrep ret_ll`::ret_ll:return{trace(arg1)}" > dtrace: description ''pid5633::ret_ll:return'' matched 1 probe > CPU ID FUNCTION:NAME > 0 47874 ret_ll:return 4294967295 <-- it is definately not a (long long) > > PS: have tried as well: > # dtrace -n "pid`pgrep ret_ll`::ret_ll:return{printf(\"%lld\", (long long)arg1)}" > dtrace: description ''pid13837::ret_ll:return'' matched 1 probe > CPU ID FUNCTION:NAME > 1 47874 ret_ll:return 4294967295 <-- more like just (int)With 32-bit userland binaries, the pid provider''s argn probes are only 32-bits wide. The bits are available in arg2; modifying your code: % cat > tmpc.c <<\EOF #include <unistd.h> unsigned long long ret_ll(void) { return (0x0123456789abcdefULL); } int main(int argc, char *argv[]) { while (1) { ret_ll(); sleep(1); } } EOF % cc -o tmpc tmpc.c % On SPARC: #dtrace -qn ''pid$target::ret_ll:return{printf("%08x %08x\n", arg1, arg2)}'' \ -c ./tmpc 01234567 89abcdef 01234567 89abcdef 01234567 89abcdef ^C 89abcdef 01234567 # On x86: #dtrace -qn ''pid$target::ret_ll:return{printf("%08x %08x\n", arg1, arg2)}'' -c ./tmpc-s 89abcdef 01234567 89abcdef 01234567 ^C 89abcdef 01234567 # So unfortunately, endianness does matter. Cheers, - jonathan
Chip Bennett
2008-Oct-14 20:09 UTC
[dtrace-discuss] printing (long long) arg1 on :::return
I don''t think that''s documented. We should probably add that to the wiki''s pid provider doc. Chip> -----Original Message----- > From: dtrace-discuss-bounces at opensolaris.org [mailto:dtrace-discuss- > bounces at opensolaris.org] On Behalf Of Jonathan Adams > Sent: Tuesday, October 14, 2008 2:57 PM > To: Anatoli > Cc: dtrace-discuss at opensolaris.org > Subject: Re: [dtrace-discuss] printing (long long) arg1 on :::return > > On Tue, Oct 14, 2008 at 10:10:20AM -0700, Anatoli wrote: > > Hi, All > > I have run onto inability to trace (long long) return values -please> > see details below. Is there a way to get it correctly ? > > > Thanks in advance > > > ... > > Here is what I am getting: > > > > # isainfo -b > > 64 > > # dtrace -n "pid`pgrep ret_ll`::ret_ll:return{trace(arg1)}" > > dtrace: description ''pid5633::ret_ll:return'' matched 1 probe > > CPU ID FUNCTION:NAME > > 0 47874 ret_ll:return 4294967295 <-- > it is definately not a (long long) > > > > PS: have tried as well: > > # dtrace -n "pid`pgrep ret_ll`::ret_ll:return{printf(\"%lld\", (long > long)arg1)}" > > dtrace: description ''pid13837::ret_ll:return'' matched 1 probe > > CPU ID FUNCTION:NAME > > 1 47874 ret_ll:return 4294967295 <-- > more like just (int) > > With 32-bit userland binaries, the pid provider''s argn probes are only > 32-bits > wide. The bits are available in arg2; modifying your code: > > % cat > tmpc.c <<\EOF > #include <unistd.h> > > unsigned long long ret_ll(void) > { > return (0x0123456789abcdefULL); > } > > int > main(int argc, char *argv[]) > { > while (1) { > ret_ll(); > sleep(1); > } > } > EOF > % cc -o tmpc tmpc.c > % > > On SPARC: > > #dtrace -qn ''pid$target::ret_ll:return{printf("%08x %08x\n", arg1, > arg2)}'' \ > -c ./tmpc > 01234567 89abcdef > 01234567 89abcdef > 01234567 89abcdef > ^C > 89abcdef 01234567 > > # > > On x86: > #dtrace -qn ''pid$target::ret_ll:return{printf("%08x %08x\n", arg1, > arg2)}'' -c > ./tmpc-s > 89abcdef 01234567 > 89abcdef 01234567 > ^C > 89abcdef 01234567 > > # > > > So unfortunately, endianness does matter. > > Cheers, > - jonathan > > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org
Many thanks to all! I have not read about arg2 as a *continuation* of arg1 in the doc (may be just missed the note...) And if it is not there - should it be mentioned as well ? PS: the whole number may be converted back as: dtrace -n "pid`pgrep gettimeofday`::ret_ll:return{trace(arg2*0x100000000ULL+arg1)}" Thanks again -- This message posted from opensolaris.org
Jonathan Adams
2008-Oct-14 21:14 UTC
[dtrace-discuss] printing (long long) arg1 on :::return
On Tue, Oct 14, 2008 at 02:11:09PM -0700, Anatoli wrote:> Many thanks to all! > I have not read about arg2 as a *continuation* of arg1 in the doc (may be just missed the note...) > And if it is not there - should it be mentioned as well ? > PS: the whole number may be converted back as: > dtrace -n "pid`pgrep gettimeofday`::ret_ll:return{trace(arg2*0x100000000ULL+arg1)}"Only on x86; on sparc, you''d have to swap arg2 and arg1. Cheers, - jonathan