Brian Utterback
2010-Dec-17 20:44 UTC
[dtrace-discuss] Why can''t I use stack as index to an array but I can for an aggregation?
I am aggregating using the stack function as the index: @s[stack()] = count(); This works great. However, I found that in addition to how many times each stack appears, it would also be useful to know which stacks were called shortly before the script exited. So I thought to make an associative array with the same indexes, and store the timestamp the last time they were set: ts[stack()] = timestamp; This gives me an error: tracing function stack( ) may not be called from a D expression (D program context required) Why can''t I use stack as the index to an associative array when I can use it as the index to an aggregation? Am I doing something wrong? And if I can''t use it, does anyone have a suggestion how to store the time of the last call of each stack? -- blu It''s bad civic hygiene to build technologies that could someday be used to facilitate a police state. - Bruce Schneier -----------------------------------------------------------------------| Brian Utterback - Solaris RPE, Oracle Corporation. Ph:603-262-3916, Em:brian.utterback at oracle.com
Nicolas Williams
2010-Dec-17 20:57 UTC
[dtrace-discuss] Why can''t I use stack as index to an array but I can for an aggregation?
On Fri, Dec 17, 2010 at 03:44:00PM -0500, Brian Utterback wrote:> I am aggregating using the stack function as the index: > > @s[stack()] = count(); > > This works great. However, I found that in addition to how many times > each stack appears, it would also be useful to know which stacks were > called shortly before the script exited. So I thought to make an > associative array with the same indexes, and store the timestamp the > last time they were set: > > ts[stack()] = timestamp; > > This gives me an error: > tracing function stack( ) may not be called from a D expression (D > program context required) > > Why can''t I use stack as the index to an associative array when I can > use it as the index to an aggregation? Am I doing something wrong? And > if I can''t use it, does anyone have a suggestion how to store the time > of the last call of each stack?While I don''t know the answer to your question, a workaround would be to use max() as the aggregation function... Nico --
Adam Leventhal
2010-Dec-18 00:50 UTC
[dtrace-discuss] Why can''t I use stack as index to an array but I can for an aggregation?
> > Why can''t I use stack as the index to an associative array when I can > use it as the index to an aggregation? Am I doing something wrong? And > if I can''t use it, does anyone have a suggestion how to store the time > of the last call of each stack?If Bryan is monitoring this, he can provide a more authoritative answer, but I believe the use of stack() -- normally a data recording action -- as a key to an aggregation was a special case. The stack() action should, perhaps, have produced an object that could then be used as a key for an aggregation or associative array, or recorded with, say, the trace() action (e.g. trace(stack());). Arguably it''s a bug that you can''t use stack() in the way that you described. You should feel free to file it with Oracle or in illumos. Adam -- Adam Leventhal, Delphix http://dtrace.org/blogs/ahl -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20101217/57958613/attachment.html>