I''ve run into some potential oddness when trying to use USDT probes. I''ve boiled it down into a small test case, which I''ve included below. Here is some sample output: /home/ovrskeek> ./usdt floatArg: 1.000000 doubleArg: 1.500000 longLongArg: feeaadd00000001 floatArg: 2.000000 doubleArg: 2.500000 longLongArg: feeaadd00000002 floatArg: 3.000000 doubleArg: 3.500000 longLongArg: feeaadd00000003 floatArg: 4.000000 doubleArg: 4.500000 longLongArg: feeaadd00000004 /home/ovrskeek# dtrace -n ''fooProvider*:::longLongProbe { trace(args[0]); }'' dtrace: description ''fooProvider*:::longLongProbe '' matched 1 probe CPU ID FUNCTION:NAME 1 52718 main:longLongProbe 2 1 52718 main:longLongProbe 3 1 52718 main:longLongProbe 4 /home/ovrskeek# dtrace -n ''fooProvider*:::floatProbe { trace(args[0]); }'' dtrace: invalid probe specifier fooProvider*:::floatProbe { trace(args[0]); }: in action list: translator for args[0] from float to float is not defined /home/ovrskeek# dtrace -n ''fooProvider*:::doubleProbe { trace(args[0]); }'' dtrace: invalid probe specifier fooProvider*:::doubleProbe { trace(args[0]); }: in action list: translator for args[0] from double to double is not defined From poking around in the source code, it appears the first problem is related to how USDT arguments are read from the stack. I wasn''t certain if the second two were an oversight, or an intentional guard against using floats/doubles (which may take ABI groveling to find). Doctor, doctor, it hurts when I use long long''s in my USDT probes :-). Any advice? James McIlree ----------- fooProvider.d ------------------- provider fooProvider { probe floatProbe(float); probe doubleProbe(double); probe longLongProbe(long long); }; ------------ usdt.c ------------------------ #include <stdio.h> #include "fooProvider.h" int main() { float floatArg = 1.0f; double doubleArg = 1.5; long long longLongArg = 0x0FEEAADD00000001LL; while (1) { FOOPROVIDER_FLOATPROBE(floatArg); FOOPROVIDER_DOUBLEPROBE(doubleArg); FOOPROVIDER_LONGLONGPROBE(longLongArg); printf("floatArg: %f doubleArg: %f longLongArg: %llx \n", (double)floatArg, doubleArg, (unsigned long long)longLongArg); floatArg++; doubleArg++; longLongArg++; sleep(1); } return 0; }
Hi James, The "long long"s seem like the ought to work. The manual says you can initialize data structures with float constants, but no float expressions. My bet is that floats aren''t allowed as SDT probe args, because the translation is some kind of expression (that''s a guess). However, I''ve never even figured out how to get floating point constants to initialize a data structure. BTW, would something like this work for you? union { double x; long long i; } u; BEGIN { u.i = arg0; printf ("%f", u.x); exit(0); } Well, of course BEGIN doesn''t have arguments, but you get the idea. Chip James McIlree wrote:> /home/ovrskeek# dtrace -n ''fooProvider*:::floatProbe { trace(args[0]); }'' > dtrace: invalid probe specifier fooProvider*:::floatProbe { > trace(args[0]); }: in action list: translator for args[0] from float > to float is not defined > > /home/ovrskeek# dtrace -n ''fooProvider*:::doubleProbe { > trace(args[0]); }'' > dtrace: invalid probe specifier fooProvider*:::doubleProbe { > trace(args[0]); }: in action list: translator for args[0] from double > to double is not defined
Hey James, Glad you finally made it onto the discussion list. Unfortunately, here isn''t any support for floating point arguments with USDT or any other probes for that matter. There''s a long-standing RFE to build true floating-point support for DTrace. It''s not a small project and the DTrace team doesn''t have the cycles to work on it. If anyone''s interested in picking it up, feel free to mail the list or send me mail privately. Adam On Thu, Dec 07, 2006 at 01:14:10PM -0800, James McIlree wrote:> > I''ve run into some potential oddness when trying to use > USDT probes. I''ve boiled it down into a small test case, which I''ve > included below. > > Here is some sample output: > > /home/ovrskeek> ./usdt > floatArg: 1.000000 doubleArg: 1.500000 longLongArg: feeaadd00000001 > floatArg: 2.000000 doubleArg: 2.500000 longLongArg: feeaadd00000002 > floatArg: 3.000000 doubleArg: 3.500000 longLongArg: feeaadd00000003 > floatArg: 4.000000 doubleArg: 4.500000 longLongArg: feeaadd00000004 > > /home/ovrskeek# dtrace -n ''fooProvider*:::longLongProbe > { trace(args[0]); }'' > dtrace: description ''fooProvider*:::longLongProbe '' matched 1 probe > CPU ID FUNCTION:NAME > 1 52718 main:longLongProbe 2 > 1 52718 main:longLongProbe 3 > 1 52718 main:longLongProbe 4 > > /home/ovrskeek# dtrace -n ''fooProvider*:::floatProbe > { trace(args[0]); }'' > dtrace: invalid probe specifier fooProvider*:::floatProbe > { trace(args[0]); }: in action list: translator for args[0] from float > to float is not defined > > /home/ovrskeek# dtrace -n ''fooProvider*:::doubleProbe > { trace(args[0]); }'' > dtrace: invalid probe specifier fooProvider*:::doubleProbe > { trace(args[0]); }: in action list: translator for args[0] from > double to double is not defined > > From poking around in the source code, it appears the > first problem is related to how USDT arguments are read from the stack. > > I wasn''t certain if the second two were an oversight, > or an intentional guard against using floats/doubles (which may > take ABI groveling to find). > > Doctor, doctor, it hurts when I use long long''s in my > USDT probes :-). Any advice? > > James McIlree > > > ----------- fooProvider.d ------------------- > > provider fooProvider { > probe floatProbe(float); > probe doubleProbe(double); > probe longLongProbe(long long); > }; > > ------------ usdt.c ------------------------ > > #include <stdio.h> > #include "fooProvider.h" > > int main() { > float floatArg = 1.0f; > double doubleArg = 1.5; > long long longLongArg = 0x0FEEAADD00000001LL; > > while (1) { > FOOPROVIDER_FLOATPROBE(floatArg); > FOOPROVIDER_DOUBLEPROBE(doubleArg); > FOOPROVIDER_LONGLONGPROBE(longLongArg); > > printf("floatArg: %f doubleArg: %f longLongArg: %llx > \n", (double)floatArg, doubleArg, (unsigned long long)longLongArg); > floatArg++; > doubleArg++; > longLongArg++; > > sleep(1); > } > > return 0; > } > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Adam Leventhal, Solaris Kernel Development http://blogs.sun.com/ahl