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.1 1994/01/27 00:41:37 hollings
11 * First version of data manager interfaces.
19 #include "util/h/list.h"
20 #include "rtinst/h/trace.h"
21 #include "util/h/hist.h"
22 #include "dyninstRPC.h"
24 /* one or more program working together */
25 class applicationContext;
27 /* sequence of peformance data (trace|sample) */
28 class performanceStream;
31 // typedef double timeStamp;
33 /* something that data can be collected for */
36 /* descriptive information about a resource */
38 char *name; /* name of actual resource */
39 char *fullName; /* full path name of resource */
40 timeStamp creation; /* when did it get created */
43 /* list of resources */
49 /* a list of metrics */
50 typedef metric *metricList;
52 /* a metric/resourceList pair */
55 typedef enum { Trace, Sample } dataType;
58 * error handler call back.
61 typedef (*errorHandler)(int errno, char *message);
64 * Handler that gets called when new sample data is delivered.
66 * ps - a performanceStream from createPerformanceStream
67 * mi - a metricInstance returned by enableDataCollection
68 * startTimeStamp - starting time of the interval covered by this sample.
69 * endTimeStamp - ending time of the interval covered by this sample.
70 * value - the value of this sample
73 typedef (*sampleDataCallbackFunc)(performanceStream *ps,
75 timeStamp startTimeStamp,
76 timeStamp endTimeStamp,
80 * Handler that gets called when new trace data is available.
82 * ps - a performanceStream from createPerformanceStream
83 * mi - a metricInstance returned by enableDataCollection
84 * time - time of the event.
85 * eventSize - size of the event specific data.
86 * eventData - event specific data.
88 typedef (*traceDataCallbackFunc)(performanceStream *ps, metricInstance *mi,
89 timeStamp time, int eventSize, void *eventData);
92 * union to hold two types of data callback.
96 sampleDataCallbackFunc sample;
97 traceDataCallbackFunc trace;
102 * Handler that gets called when a new metric is defined.
104 * performanceStream - a stream returned by createPerformanceStream
108 typedef void (*metricInfoCallback)(performanceStream*, metric*);
111 * Handler that gets called when a new resource is defined.
113 * performanceStream - a stream returned by createPerformanceStream
114 * parent - parent of new resource
115 * newResource - new resource being created
116 * name - name of the new resource
119 typedef void (*resourceInfoCallback)(performanceStream*, resource *parent,
120 resource *newResource, char *name);
123 metricInfoCallback mFunc;
124 resourceInfoCallback rFunc;
128 $remote dataManager {
133 // Create an applicationContext (an application to be studied)
135 applicationContext *createApplicationContext(errorHandler foo);
138 // Define a program to run.
140 Boolean addExecutable(applicationContext *app,
148 // Find out if an application has been defined yet.
150 Boolean applicationDefined(applicationContext *app);
153 // Start an application running (This starts the actual execution).
154 // app - an application context from createPerformanceConext.
156 Boolean startApplication(applicationContext *app);
159 // Stop all processes associted with the application.
160 // app - an application context from createPerformanceConext.
162 // Pause an application (I am not sure about this but I think we want it).
163 // - Does this force buffered data to be delivered?
164 // - Does a paused application respond to enable/disable commands?
166 Boolean pauseApplication(applicationContext *app);
169 // Continue a paused application.
170 // app - an application context from createPerformanceConext.
172 Boolean continueApplication(applicationContext *app);
175 // Disconnect the tool from the process.
176 // app - an application context from createPerformanceConext.
177 // pause - leave the process in a stopped state.
179 Boolean detachApplication(applicationContext *app,Boolean pause);
182 // Create a performanceStream. This a flow of performance information
185 // applicationContext - an application context.
186 // dataType - Sample or Trace
187 // dataCallback - Function to call when new data arrives
188 // controlCallback - Function to call when new structure info arrives
189 // sampleInterval - nominal interval between samples (sample only)
191 performanceStream *createPerformanceStream(applicationContext*,
197 void setSampleRate(performanceStream *stream, timeStamp sampleInterval);
200 // Routines to control data collection on a performanceStream.
202 // performanceStream - a stream returned by createPerformanceStream
203 // resourceList - a list of resources
204 // metric - what metric to collect data for
206 metricInstance *enableDataCollection(performanceStream*,
211 // stop collecting data for the named metricInstance.
212 // performanceStream - a stream returned by createPerformanceStream
213 // metricInstance - a metricInstance returned by enableDataCollection.
215 void disableDataCollection(performanceStream*, metricInstance*);
218 // Return the expected cost of collecting performance data for a single
219 // metric at a given focus. The value returned is the fraction of
220 // perturbation expected (i.e. 0.10 == 10% slow down expected).
222 float getPredictedDataCost(applicationContext*, resourceList*, metric*);
225 // Control information arriving about a resource Classes
227 // performanceStream - a stream returned by createPerformanceStream
228 // resource - enable notification of children of this resource
230 void enableResourceCreationNotification(performanceStream*, resource*);
233 // Turn off notification of creation of descendants of this resource.
235 // performanceStream - a stream returned by createPerformanceStream
236 // resource - disable notification of descendants of this resource
239 void disableResourceCreationNotification(performanceStream*, resource*);
242 // Resource utility functions.
244 resource *getRootResource();
246 resourceList *getRootResources();
248 char *getResourceName(resource*);
250 resource *getResourceParent(resource*);
252 resourceList *getResourceChildren(resource*);
254 Boolean isResourceDescendent(resource *parent, resource *child);
256 resource *findChildResource(resource *parent, char *name);
258 int getResourceCount(resourceList*);
260 resource *getNthResource(resourceList*, int n);
262 resourceList *createResourceList();
264 void addResourceList(resourceList*, resource*);
266 resource *newResource(resource *parent, char *name);
268 // Get the static config. information for the passed applicationContext.
270 $array String getAvailableMetrics(applicationContext*);
273 // looks for a specifc metric instance in an application context.
275 metric *findMetric(applicationContext *context, char *name);
278 // Metric utility functions.
280 char *getMetricName(metric*);
283 // Get metric out of a metric instance.
285 metric *getMetric(metricInstance*);
288 // Get the value of a metric.
290 sampleValue getMetricValue(metricInstance*);
293 // Debugger style calls.
295 void printResources();
296 void printStatus(applicationContext*);
297 void coreProcess(applicationContext*, int pid);
300 // upcalls for indications of events.
302 $upcall $async void newMetricDefined(metricInfoCallback,
306 $upcall $async void newPerfData(sampleDataCallbackFunc,
307 performanceStream *ps,
309 timeStamp startTimeStamp,
310 timeStamp endTimeStamp,