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
[email protected]

Reply via email to