I have a probe: pid111::myfunc:entry { self->arg = arg0; } pid111::myfunc:return /self->arg/ { @[self->arg] = quantize(); } works great, but i''d like arg0 to be printed in hex. I''ve tried numerous approaches to do this but i''ve hit a wall every time. I''ve tried: 1) self->arg = sprintf(arg0); no, cuz dtrace has no sprintf 2) self->arg = string((void*)arg0); no, cuz it tried to dereference arg0, but it''s a value Then I wrote a translator: struct byhex { string hex; }; translator struct byhex <uint64_t arg> { hex = ... }; .... self->arg = xlate<struct byhex>(arg).hex; BUT there''s nothing i can do to populate hex! Even if i do conversion myself, by doing stuff like: arg&0xF < 10 ? (arg&0xF) + ''0'' : (arg&0xF) - 10 + ''A'' this yeields characters, and there''s no way to convert characters to strings!!!!!!!! STUPID!!! Even if i try printa() of my quantize array, there''s no way to specify the format for the tuple (i.e. the key of the aggregate)... SEEMS LIKE SOMEONE FORGOT A VERY IMPORTANT FEATURE OF DTRACE!!! Any help ? ____________________________________________________________________________________ Got a little couch potato? Check out fun summer activities for kids. http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz
Hey Dan,> pid111::myfunc:entry > { > self->arg = arg0; > } > > pid111::myfunc:return > /self->arg/ > { > @[self->arg] = quantize(); > } > > works great, but i''d like arg0 to be printed in hex. I''ve tried numerous approaches to do this but i''ve hit a wall every time. I''ve tried:This pertains to printing out an aggregation, not how the data is stored. So you want to use printa() in an END action, e.g.: END { printa("%x %@d\n", @); }> BUT there''s nothing i can do to populate hex! Even if i do conversion myself, by doing stuff like: > arg&0xF < 10 ? (arg&0xF) + ''0'' : (arg&0xF) - 10 + ''A'' > > this yeields characters, and there''s no way to convert characters to strings!!!!!!!! STUPID!!! > > > Even if i try printa() of my quantize array, there''s no way to specify the format for the tuple (i.e. the key of the aggregate)...Yes, there is. See above.> SEEMS LIKE SOMEONE FORGOT A VERY IMPORTANT FEATURE OF DTRACE!!!SEEMS LIKE SOMEONE FORGOT TO READ THE MANUAL!! ;) - Bryan -------------------------------------------------------------------------- Bryan Cantrill, Solaris Kernel Development. http://blogs.sun.com/bmc
Dan Akselrod wrote:> I have a probe: > > pid111::myfunc:entry > { > self->arg = arg0; > } > > pid111::myfunc:return > /self->arg/ > { > @[self->arg] = quantize(); > } > > works great, but i''d like arg0 to be printed in hex. I''ve tried numerous approaches to do this but i''ve hit a wall every time. I''ve tried: > > 1) self->arg = sprintf(arg0); > > no, cuz dtrace has no sprintf > > 2) self->arg = string((void*)arg0); > > no, cuz it tried to dereference arg0, but it''s a value > > Then I wrote a translator: > > struct byhex { > string hex; > }; > > translator struct byhex <uint64_t arg> { > hex = ... > }; > > .... > self->arg = xlate<struct byhex>(arg).hex; > > > BUT there''s nothing i can do to populate hex! Even if i do conversion myself, by doing stuff like: > arg&0xF < 10 ? (arg&0xF) + ''0'' : (arg&0xF) - 10 + ''A'' > > this yeields characters, and there''s no way to convert characters to strings!!!!!!!! STUPID!!! > > > Even if i try printa() of my quantize array, there''s no way to specify the format for the tuple (i.e. the key of the aggregate)... > > SEEMS LIKE SOMEONE FORGOT A VERY IMPORTANT FEATURE OF DTRACE!!!Hi Dan, I don''t think that the DTrace Iron Chefs forgot this. Did you think to try something such as pid111::myfunc:return /self->arg/ { @[self->arg] = quantize(); printf("arg0: 0x%x\n", arg0); } James C. McPherson -- Solaris kernel software engineer Sun Microsystems