liujun
2007-Aug-03 01:32 UTC
[dtrace-discuss] how to access elemets of an arry in dtrace actions
I want to access some elelmets in an array acoording indexs. But,If and While are reserverd keys.How to achieve it? for example: fbt:::entry { index = 0; for (index;index<10;index++) { printf("%d",g_arry[index]); } } the only way to add predicate in //. -- This message posted from opensolaris.org
Angelo Rajadurai
2007-Aug-03 03:20 UTC
[dtrace-discuss] how to access elemets of an arry in dtrace actions
Hi Liujun: Just curious why you are using arrays instead of aggregates. Aggregates are a much better choice in almost all cases, they have better performance and of course you have printa() that can print the aggregate without any fancy loop or tricky predicates. Also be careful with fbt:::entry - this is over 30,000 probes Rgds, Angelo liujun wrote:> I want to access some elelmets in an array acoording indexs. > But,If and While are reserverd keys.How to achieve it? > for example: > fbt:::entry > { > index = 0; > for (index;index<10;index++) > { > printf("%d",g_arry[index]); > } > } > > the only way to add predicate in //. > > > -- > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org >
liujun
2007-Aug-03 04:52 UTC
[dtrace-discuss] how to access elemets of an arry in dtrace actions
Thanks Angelo. I want to trace my kernel module''s global variable''s infomation named g_ModuleArray .It''s an array. now,My dtrace script is like: tick-1sec { RdacInfo = upper`g_ModuleArray[0]; printf("%s,%d,%d",RdacInfo->name,RdacInfo->count,RdacInfo->ref); RdacInfo = upper`g_ModuleArray[1]; printf("%s,%d,%d",RdacInfo->name,RdacInfo->count,RdacInfo->ref); RdacInfo = upper`g_ModuleArray[2]; printf("%s,%d,%d",RdacInfo->name,RdacInfo->count,RdacInfo->ref); ................... RdacInfo = upper`g_ModuleArray[n]; printf("%s,%d,%d",RdacInfo->name,RdacInfo->count,RdacInfo->ref); } The n index maybe so large that like above to do. -- This message posted from opensolaris.org
michael schuster
2007-Aug-03 06:01 UTC
[dtrace-discuss] how to access elemets of an arry in dtrace actions
liujun wrote:> Thanks Angelo. > I want to trace my kernel module''s global variable''s infomation named g_ModuleArray .It''s an array.I can''t think of a simple solution to this (I''m assuming that by "The n index maybe so large that like above to do" you mean "I don''t know the upper bound of *n*"). There''s a good reason that loops aren''t allowed in DTrace: you can''t tell at compile-time how often they''re going to run, and this is not acceptable by the high standards DTrace adheres to. The consequence of this is that you need to decide on the upper "bound" of your "loop" when you write your script by explicitly putting in statements for every "iteration". (I guess the DTrace native speakers can say this much more scientifically ;-) HTH Michael> > now,My dtrace script is like: > > tick-1sec > { > > RdacInfo = upper`g_ModuleArray[0]; > printf("%s,%d,%d",RdacInfo->name,RdacInfo->count,RdacInfo->ref); > > RdacInfo = upper`g_ModuleArray[1]; > printf("%s,%d,%d",RdacInfo->name,RdacInfo->count,RdacInfo->ref); > > RdacInfo = upper`g_ModuleArray[2]; > printf("%s,%d,%d",RdacInfo->name,RdacInfo->count,RdacInfo->ref); > ................... > RdacInfo = upper`g_ModuleArray[n]; > printf("%s,%d,%d",RdacInfo->name,RdacInfo->count,RdacInfo->ref); > > } > > The n index maybe so large that like above to do. > > > -- > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Michael Schuster Sun Microsystems, Inc. recursion, n: see ''recursion''