Ryan Johnson
2009-Jul-13 16:36 UTC
[dtrace-discuss] Can''t print stack traces if printa has a format string?
Hi all, Is there a way to print stack traces as part of an aggregation key in dtrace? I''m trying to count occurrences of different stack traces, but my program has lots of indirect function calls and the output of stack() often doesn''t contain the current function. Aggregating on @who[caller,stack()] should fix this in theory, but I can''t get the printing to work right. printa(@who) shows the stack but just an address for caller, and neither %a nor %s allows me to print a stack trace if I give printa a format string:> printa("%40a %40s %@d", @who) > dtrace: failed to compile script who.d: line 30: printa( ) argument #3 > is incompatible with conversion #2 prototype: > conversion: %s > prototype: char [] or string (or use stringof) > argument: stack > > printa("%40a %40a %@d", @who) > dtrace: failed to compile script who.d: line 30: printa( ) argument #3 > is incompatible with conversion #2 prototype: > conversion: %a > prototype: pointer or integer > argument: stackOn a related note, it seems that "%A" can translate user-level addresses to symbols in a printf/printa, which is not documented AFAICT and has caused me pain in the past (see http://kr.sun.com/developers/solaris/techdocs/dtrace_tips_public.pdf) Ideas? Ryan
Ryan Johnson
2009-Jul-13 17:00 UTC
[dtrace-discuss] Can''t print stack traces if printa has a format string?
Ryan Johnson wrote:> Is there a way to print stack traces as part of an aggregation key in > dtrace? I''m trying to count occurrences of different stack traces, but > my program has lots of indirect function calls and the output of > stack() often doesn''t contain the current function. Aggregating on > @who[caller,stack()] should fix this in theory, but I can''t get the > printing to work right.Ah! Turns out this question was already asked in 2005, and the answer is "%k"> On a related note, it seems that "%A" can translate user-level > addresses to symbols in a printf/printa, which is not documented > AFAICT and has caused me pain in the past (see > http://kr.sun.com/developers/solaris/techdocs/dtrace_tips_public.pdf)I''ve updated the printf/printa wiki page to mention both %A and %k. Ryan