2 * Copyright 1993 Jeff Hollingsworth. All rights reserved.
9 * $Log: metricFocusNode.h,v $
10 * Revision 1.2 1994/03/24 16:42:01 hollings
11 * Moved sample aggregation to lib/util (so paradyn could use it).
13 * Revision 1.1 1994/01/27 20:31:29 hollings
14 * Iinital version of paradynd speaking dynRPC igend protocol.
16 * Revision 1.9 1994/01/20 17:48:13 hollings
17 * dataReqNode overcome by events.
19 * Revision 1.8 1993/10/19 15:27:54 hollings
20 * AST based mini-tramp code generator.
22 * Revision 1.7 1993/10/01 21:29:41 hollings
23 * Added resource discovery and filters.
25 * Revision 1.6 1993/08/20 22:01:51 hollings
26 * added getMetricValue and returnCounterInstance.
28 * Revision 1.5 1993/08/11 01:52:55 hollings
29 * new build before use metrics.
31 * Revision 1.4 1993/06/22 19:00:01 hollings
34 * Revision 1.3 1993/06/08 20:14:34 hollings
35 * state prior to bc net ptrace replacement.
37 * Revision 1.2 1993/04/27 14:39:21 hollings
38 * signal forwarding and args tramp.
40 * Revision 1.1 1993/03/19 22:51:05 hollings
46 #include "dyninstRPC.h"
47 #include "util/h/aggregateSample.h"
50 * internal representation of an inst. request.
53 typedef enum { intCounter, timer } dataObjectType;
56 class metricDefinitionNode;
60 dataReqNode(dataObjectType, process*, int, Boolean iReport, timerType);
62 float getMetricValue();
64 void insertInstrumentation(metricDefinitionNode *mi);
67 // return a pointer in the inferrior address space of this data object.
68 void *getInferriorPtr();
69 intCounterHandle *returnCounterInstance() {
70 return((intCounterHandle *) instance);
72 int getSampleId() { return(id.id); }
73 dataObjectType getType() { return(type); }
76 timerHandle *createTimerInstance();
77 intCounterHandle *createCounterInstance();
84 sampleId id; // unique id for this sample
91 instReqNode(process*, instPoint*, AstNode*, callWhen, callOrder order);
94 Boolean insertInstrumentation();
104 instInstance *instance;
109 Boolean firstSampleReceived; /* has first sample been recoreded */
110 sampleValue value; /* cumlative value */
111 timeStamp lastSampleStart; /* start time for last sample */
112 timeStamp lastSampleEnd; /* end time for last sample */
113 sampleValue lastSample; /* what was the last sample increment */
117 class metricDefinitionNode {
119 metricDefinitionNode(process *p);
120 metricDefinitionNode(metric m, List<metricDefinitionNode*> parts);
121 ~metricDefinitionNode();
123 void updateValue(time64, sampleValue);
125 Boolean match(resourceList l, metric m) {
126 return(resList == l && met == m);
128 Boolean insertInstrumentation();
130 // used by controller.
131 float getMetricValue();
132 dataReqNode *addIntCounter(int inititalValue, Boolean report) {
135 tp = new dataReqNode(intCounter, proc, inititalValue,
140 dataReqNode *addTimer(timerType type) {
142 tp = new dataReqNode(timer,proc,0,True,type);
146 void addInst(instPoint *point,AstNode *ast, callWhen when, callOrder o){
148 temp = new instReqNode(proc, point, ast, when, o);
152 int id; // unique id for this one
153 metric met; // what type of metric
154 resourceList resList; // what resource list is this for.
156 // is this a final value or a component of a larger metric.
161 void updateAggregateComponent(metricDefinitionNode *,
162 time64 time, sampleValue value);
167 /* for aggregate metrics */
168 List<metricDefinitionNode*> components;
170 /* for non-aggregate metrics */
171 List<dataReqNode*> data;
172 List<instReqNode*> requests;
174 // which metricDefinitionNode depend on this value.
175 List<metricDefinitionNode*> aggregators;
178 struct sampleInfo sampleData; /* actual data */
180 List<sampleInfo*> valueList; // actual data for comp.
184 typedef AstNode *(*createPredicateFunc)(metricDefinitionNode *mn,
185 char *resource, AstNode *trigger);
187 typedef void (*createMetricFunc)(metricDefinitionNode*, AstNode *trigger);
190 createPredicateFunc creator;
191 } predicateDefinition;
193 typedef enum { invalidPredicate,
196 replaceBase } predicateType;
199 char *namePrefix; /* leading part of resource path */
201 createPredicateFunc creator; /* create a metric */
205 createMetricFunc baseFunc; /* base definition */
206 resourcePredicate *predicates; /* how to handle where refinements */
211 metricDefinition definition;
214 extern List<metricDefinitionNode*> allMIs;