2 * Copyright 1993 Jeff Hollingsworth. All rights reserved.
7 * mmthread.h - exported services of the mmthread of paradyn.
9 * $Log: dataManager.I,v $
10 * Revision 1.2 1994/02/01 18:47:33 hollings
11 * Upgrades for performanceConsultant thread.
13 # Revision 1.1 1994/01/27 00:41:37 hollings
14 # First version of data manager interfaces.
22 #include "util/h/list.h"
23 #include "rtinst/h/trace.h"
24 #include "util/h/hist.h"
25 #include "dyninstRPC.h"
27 /* one or more program working together */
28 class applicationContext;
30 /* sequence of peformance data (trace|sample) */
31 class performanceStream;
34 // typedef double timeStamp;
36 /* something that data can be collected for */
39 /* descriptive information about a resource */
41 char *name; /* name of actual resource */
42 char *fullName; /* full path name of resource */
43 timeStamp creation; /* when did it get created */
46 /* list of resources */
52 /* a list of metrics */
53 typedef metric *metricList;
55 /* a metric/resourceList pair */
58 typedef enum { Trace, Sample } dataType;
61 * error handler call back.
64 typedef (*errorHandler)(int errno, char *message);
67 * Handler that gets called when new sample data is delivered.
69 * ps - a performanceStream from createPerformanceStream
70 * mi - a metricInstance returned by enableDataCollection
71 * startTimeStamp - starting time of the interval covered by this sample.
72 * endTimeStamp - ending time of the interval covered by this sample.
73 * value - the value of this sample
76 typedef (*sampleDataCallbackFunc)(performanceStream *ps,
78 timeStamp startTimeStamp,
79 timeStamp endTimeStamp,
83 * Handler that gets called when new trace data is available.
85 * ps - a performanceStream from createPerformanceStream
86 * mi - a metricInstance returned by enableDataCollection
87 * time - time of the event.
88 * eventSize - size of the event specific data.
89 * eventData - event specific data.
91 typedef (*traceDataCallbackFunc)(performanceStream *ps, metricInstance *mi,
92 timeStamp time, int eventSize, void *eventData);
95 * union to hold two types of data callback.
99 sampleDataCallbackFunc sample;
100 traceDataCallbackFunc trace;
103 typedef union dataCallback dataCallback;
106 * Handler that gets called when a new metric is defined.
108 * performanceStream - a stream returned by createPerformanceStream
112 typedef void (*metricInfoCallback)(performanceStream*, metric*);
115 * Handler that gets called when a new resource is defined.
117 * performanceStream - a stream returned by createPerformanceStream
118 * parent - parent of new resource
119 * newResource - new resource being created
120 * name - name of the new resource
123 typedef void (*resourceInfoCallback)(performanceStream*, resource *parent,
124 resource *newResource, char *name);
126 struct controlCallback {
127 metricInfoCallback mFunc;
128 resourceInfoCallback rFunc;
131 typedef struct controlCallback controlCallback;
134 $remote dataManager {
139 // Create an applicationContext (an application to be studied)
141 applicationContext *createApplicationContext(errorHandler foo);
144 // Define a program to run.
146 Boolean addExecutable(applicationContext *app,
154 // Find out if an application has been defined yet.
156 Boolean applicationDefined(applicationContext *app);
159 // Start an application running (This starts the actual execution).
160 // app - an application context from createPerformanceConext.
162 Boolean startApplication(applicationContext *app);
165 // Stop all processes associted with the application.
166 // app - an application context from createPerformanceConext.
168 // Pause an application (I am not sure about this but I think we want it).
169 // - Does this force buffered data to be delivered?
170 // - Does a paused application respond to enable/disable commands?
172 Boolean pauseApplication(applicationContext *app);
175 // Continue a paused application.
176 // app - an application context from createPerformanceConext.
178 Boolean continueApplication(applicationContext *app);
181 // Disconnect the tool from the process.
182 // app - an application context from createPerformanceConext.
183 // pause - leave the process in a stopped state.
185 Boolean detachApplication(applicationContext *app,Boolean pause);
188 // Create a performanceStream. This a flow of performance information
191 // applicationContext - an application context.
192 // dataType - Sample or Trace
193 // dataCallback - Function to call when new data arrives
194 // controlCallback - Function to call when new structure info arrives
195 // sampleInterval - nominal interval between samples (sample only)
197 performanceStream *createPerformanceStream(applicationContext*,
203 void setSampleRate(performanceStream *stream, timeStamp sampleInterval);
206 // Routines to control data collection on a performanceStream.
208 // performanceStream - a stream returned by createPerformanceStream
209 // resourceList - a list of resources
210 // metric - what metric to collect data for
212 metricInstance *enableDataCollection(performanceStream*,
217 // stop collecting data for the named metricInstance.
218 // performanceStream - a stream returned by createPerformanceStream
219 // metricInstance - a metricInstance returned by enableDataCollection.
221 void disableDataCollection(performanceStream*, metricInstance*);
224 // Return the expected cost of collecting performance data for a single
225 // metric at a given focus. The value returned is the fraction of
226 // perturbation expected (i.e. 0.10 == 10% slow down expected).
228 float getPredictedDataCost(applicationContext*, resourceList*, metric*);
231 // Control information arriving about a resource Classes
233 // performanceStream - a stream returned by createPerformanceStream
234 // resource - enable notification of children of this resource
236 void enableResourceCreationNotification(performanceStream*, resource*);
239 // Turn off notification of creation of descendants of this resource.
241 // performanceStream - a stream returned by createPerformanceStream
242 // resource - disable notification of descendants of this resource
245 void disableResourceCreationNotification(performanceStream*, resource*);
248 // Resource utility functions.
250 resource *getRootResource();
252 resourceList *getRootResources();
254 char *getResourceName(resource*);
256 resource *getResourceParent(resource*);
258 resource *newResource(applicationContext *app,
262 resourceList *getResourceChildren(resource*);
264 Boolean isResourceDescendent(resource *parent, resource *child);
266 resource *findChildResource(resource *parent, char *name);
268 int getResourceCount(resourceList*);
270 resource *getNthResource(resourceList*, int n);
272 resourceList *createResourceList();
274 void addResourceList(resourceList*, resource*);
276 // Get the static config. information for the passed applicationContext.
278 $array String getAvailableMetrics(applicationContext*);
281 // looks for a specifc metric instance in an application context.
283 metric *findMetric(applicationContext *context, char *name);
286 // Metric utility functions.
288 char *getMetricName(metric*);
291 // get the supporting info about a metric.
292 metricInfo *getMetricInfo(metric*);
295 // Get metric out of a metric instance.
297 metric *getMetric(metricInstance*);
298 char *getMetricNameFromMI(metricInstance*);
301 // Get the value of a metric.
303 sampleValue getMetricValue(metricInstance*);
306 // Debugger style calls.
308 void printResources();
309 void printStatus(applicationContext*);
310 void coreProcess(applicationContext*, int pid);
313 // upcalls for indications of events.
315 $upcall $async void newMetricDefined(metricInfoCallback,
319 $upcall $async void newPerfData(sampleDataCallbackFunc,
320 performanceStream *ps,
322 timeStamp startTimeStamp,
323 timeStamp endTimeStamp,