Keith McGuigan
2007-Sep-10 18:31 UTC
[dtrace-discuss] Question about ''long long'' and USDT probes
Hello, Someone provided me with an example of USDT usage that doesn''t appear to work right. Namely, ''long long'' arguments get truncated when read into the DTrace script. Here is a quick example and the output: > cat probetest.c #include <stdio.h> #include <sys/time.h> #include <sys/sdt.h> int main() { long long v = 0x0FFFFFFF00000001LL; printf("In the user process value = %llx\n",v); DTRACE_PROBE1(testprov,getvalue,v); return 0; } > cc -c probetest.c > cat testprov.d provider testprov { probe getvalue(long long); }; #pragma D attributes Evolving/Evolving/Common provider testprov provider #pragma D attributes Private/Private/Unknown provider testprov module #pragma D attributes Private/Private/Unknown provider testprov function #pragma D attributes Evolving/Evolving/Common provider testprov name #pragma D attributes Evolving/Evolving/Common provider testprov args > dtrace -G -32 -s testprov.d probetest.o > cc -o probetest testprov.o probetest.o > cat test.d testprov$target:::getvalue { printf("In the D script value = %llx\n",arg0); } > dtrace -s test.d -c ./probetest dtrace: script ''test.d'' matched 1 probe In the user process value = fffffff00000001 dtrace: pid 22849 has exited CPU ID FUNCTION:NAME 20 46997 main:getvalue In the D script value = 1 Anyone have any idea what I''m doing wrong here (if anything)? -- - Keith
Adam Leventhal
2007-Sep-10 19:56 UTC
[dtrace-discuss] Question about ''long long'' and USDT probes
Hi Keith, If you look at the definitions for the DTRACE_PROBE*() macros, you''ll see that the expected arguments are of type unsigned long. I''m surprised your compiler isn''t flagging that error. If you use the newer USDT methodology, the generated header file will include the appropriate types in the probe prototypes. http://blogs.sun.com/ahl/entry/user_land_tracing_gets_better You may encounter the (long-standing) issue where 64-bit arguments on 32-bit ISAs are split between two D arguments. Adam On Mon, Sep 10, 2007 at 02:31:43PM -0400, Keith McGuigan wrote:> Hello, > > Someone provided me with an example of USDT usage that doesn''t appear to work > right. Namely, ''long long'' arguments get truncated when read into the DTrace > script. > > Here is a quick example and the output: > > > cat probetest.c > #include <stdio.h> > #include <sys/time.h> > #include <sys/sdt.h> > > int main() { > long long v = 0x0FFFFFFF00000001LL; > > printf("In the user process value = %llx\n",v); > DTRACE_PROBE1(testprov,getvalue,v); > return 0; > } > > > cc -c probetest.c > > cat testprov.d > provider testprov { > probe getvalue(long long); > }; > > #pragma D attributes Evolving/Evolving/Common provider testprov provider > #pragma D attributes Private/Private/Unknown provider testprov module > #pragma D attributes Private/Private/Unknown provider testprov function > #pragma D attributes Evolving/Evolving/Common provider testprov name > #pragma D attributes Evolving/Evolving/Common provider testprov args > > dtrace -G -32 -s testprov.d probetest.o > > cc -o probetest testprov.o probetest.o > > cat test.d > testprov$target:::getvalue > { > printf("In the D script value = %llx\n",arg0); > } > > dtrace -s test.d -c ./probetest > dtrace: script ''test.d'' matched 1 probe > In the user process value = fffffff00000001 > dtrace: pid 22849 has exited > CPU ID FUNCTION:NAME > 20 46997 main:getvalue In the D script value = 1 > > > Anyone have any idea what I''m doing wrong here (if anything)? > > -- > - Keith > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Adam Leventhal, FishWorks http://blogs.sun.com/ahl