2 * dataManager.h - exported services of the Data Mgr thread of paradyn.
4 * $Log: dataManager.I,v $
5 * Revision 1.6 1994/03/20 01:48:51 markc
6 * Added support for paradyn daemon name. igen function to store name.
8 * Revision 1.5 1994/03/08 17:39:23 hollings
9 * Added foldCallback and getResourceListName.
11 * Revision 1.4 1994/02/24 04:34:14 markc
12 * Added an upcall to dyninstRPC.I to allow paradynd's to report information at
13 * startup. Added a data member to the class that igen generates.
15 * Revision 1.3 1994/02/03 23:26:50 hollings
16 * Changes to work with g++ version 2.5.2.
18 * Revision 1.2 1994/02/01 18:47:33 hollings
19 * Upgrades for performanceConsultant thread.
21 * Revision 1.1 1994/01/27 00:41:37 hollings
22 * First version of data manager interfaces.
29 #include "util/h/list.h"
30 #include "rtinst/h/trace.h"
31 #include "util/h/hist.h"
32 #include "dyninstRPC.h"
34 /* one or more program working together */
35 class applicationContext;
37 /* sequence of peformance data (trace|sample) */
38 class performanceStream;
41 // typedef double timeStamp;
43 /* something that data can be collected for */
46 /* descriptive information about a resource */
48 char *name; /* name of actual resource */
49 char *fullName; /* full path name of resource */
50 timeStamp creation; /* when did it get created */
53 /* list of resources */
59 /* a list of metrics */
60 typedef metric *metricList;
62 /* a metric/resourceList pair */
65 typedef enum { Trace, Sample } dataType;
68 * error handler call back.
71 typedef (*errorHandler)(int errno, char *message);
74 * Handler that gets called when new sample data is delivered.
76 * ps - a performanceStream from createPerformanceStream
77 * mi - a metricInstance returned by enableDataCollection
78 * startTimeStamp - starting time of the interval covered by this sample.
79 * endTimeStamp - ending time of the interval covered by this sample.
80 * value - the value of this sample
83 typedef (*sampleDataCallbackFunc)(performanceStream *ps,
85 timeStamp startTimeStamp,
86 timeStamp endTimeStamp,
90 * Handler that gets called when new trace data is available.
92 * ps - a performanceStream from createPerformanceStream
93 * mi - a metricInstance returned by enableDataCollection
94 * time - time of the event.
95 * eventSize - size of the event specific data.
96 * eventData - event specific data.
98 typedef (*traceDataCallbackFunc)(performanceStream *ps, metricInstance *mi,
99 timeStamp time, int eventSize, void *eventData);
102 * union to hold two types of data callback.
106 sampleDataCallbackFunc sample;
107 traceDataCallbackFunc trace;
110 typedef union dataCallback dataCallback;
113 * Handler that gets called when a new metric is defined.
115 * performanceStream - a stream returned by createPerformanceStream
119 typedef void (*metricInfoCallback)(performanceStream*, metric*);
122 * Handler that gets called when a new resource is defined.
124 * performanceStream - a stream returned by createPerformanceStream
125 * parent - parent of new resource
126 * newResource - new resource being created
127 * name - name of the new resource
130 typedef void (*resourceInfoCallback)(performanceStream*, resource *parent,
131 resource *newResource, char *name);
133 typedef void (*histFoldCallback)(performanceStream*, timeStamp width);
135 struct controlCallback {
136 metricInfoCallback mFunc;
137 resourceInfoCallback rFunc;
138 histFoldCallback fFunc;
141 typedef struct controlCallback controlCallback;
144 $remote dataManager {
149 // Create an applicationContext (an application to be studied)
151 applicationContext *createApplicationContext(errorHandler foo);
154 // Define a program to run.
156 Boolean addExecutable(applicationContext *app,
164 // Find out if an application has been defined yet.
166 Boolean applicationDefined(applicationContext *app);
169 // Start an application running (This starts the actual execution).
170 // app - an application context from createPerformanceConext.
172 Boolean startApplication(applicationContext *app);
175 // Stop all processes associted with the application.
176 // app - an application context from createPerformanceConext.
178 // Pause an application (I am not sure about this but I think we want it).
179 // - Does this force buffered data to be delivered?
180 // - Does a paused application respond to enable/disable commands?
182 Boolean pauseApplication(applicationContext *app);
185 // Continue a paused application.
186 // app - an application context from createPerformanceConext.
188 Boolean continueApplication(applicationContext *app);
191 // Disconnect the tool from the process.
192 // app - an application context from createPerformanceConext.
193 // pause - leave the process in a stopped state.
195 Boolean detachApplication(applicationContext *app,Boolean pause);
198 // Create a performanceStream. This a flow of performance information
201 // applicationContext - an application context.
202 // dataType - Sample or Trace
203 // dataCallback - Function to call when new data arrives
204 // controlCallback - Function to call when new structure info arrives
205 // sampleInterval - nominal interval between samples (sample only)
207 performanceStream *createPerformanceStream(applicationContext*,
213 void setSampleRate(performanceStream *stream, timeStamp sampleInterval);
216 // Routines to control data collection on a performanceStream.
218 // performanceStream - a stream returned by createPerformanceStream
219 // resourceList - a list of resources
220 // metric - what metric to collect data for
222 metricInstance *enableDataCollection(performanceStream*,
227 // stop collecting data for the named metricInstance.
228 // performanceStream - a stream returned by createPerformanceStream
229 // metricInstance - a metricInstance returned by enableDataCollection.
231 void disableDataCollection(performanceStream*, metricInstance*);
234 // Return the expected cost of collecting performance data for a single
235 // metric at a given focus. The value returned is the fraction of
236 // perturbation expected (i.e. 0.10 == 10% slow down expected).
238 float getPredictedDataCost(applicationContext*, resourceList*, metric*);
241 // Control information arriving about a resource Classes
243 // performanceStream - a stream returned by createPerformanceStream
244 // resource - enable notification of children of this resource
246 void enableResourceCreationNotification(performanceStream*, resource*);
249 // Turn off notification of creation of descendants of this resource.
251 // performanceStream - a stream returned by createPerformanceStream
252 // resource - disable notification of descendants of this resource
255 void disableResourceCreationNotification(performanceStream*, resource*);
258 // Resource utility functions.
260 resource *getRootResource();
262 resourceList *getRootResources();
264 char *getResourceName(resource*);
266 resource *getResourceParent(resource*);
268 resource *newResource(applicationContext *app,
272 resourceList *getResourceChildren(resource*);
274 Boolean isResourceDescendent(resource *parent, resource *child);
276 resource *findChildResource(resource *parent, char *name);
278 int getResourceCount(resourceList*);
280 resource *getNthResource(resourceList*, int n);
282 resourceList *createResourceList();
284 void addResourceList(resourceList*, resource*);
287 // get the canonical name of a resource list.
288 // WARNING: The returned pointer is allocated in the heap via new
289 // and should be freed using delete when the caller is done with it.
291 char *getResourceListName(resourceList*);
293 // Get the static config. information for the passed applicationContext.
295 $array String getAvailableMetrics(applicationContext*);
298 // looks for a specifc metric instance in an application context.
300 metric *findMetric(applicationContext *context, char *name);
303 // Metric utility functions.
305 char *getMetricName(metric*);
308 // get the supporting info about a metric.
309 metricInfo *getMetricInfo(metric*);
312 // Get metric out of a metric instance.
314 metric *getMetric(metricInstance*);
315 char *getMetricNameFromMI(metricInstance*);
318 // Get the value of a metric.
320 sampleValue getMetricValue(metricInstance*);
323 // Debugger style calls.
325 void printResources();
326 void printStatus(applicationContext*);
327 void coreProcess(applicationContext*, int pid);
330 // upcalls for indications of events.
332 $upcall $async void newMetricDefined(metricInfoCallback,
336 $upcall $async void newResourceDefined(resourceInfoCallback,
337 performanceStream *ps,
339 resource *newResource,
342 $upcall $async void newPerfData(sampleDataCallbackFunc,
343 performanceStream *ps,
345 timeStamp startTimeStamp,
346 timeStamp endTimeStamp,
349 $upcall $async void histFold(histFoldCallback,
350 performanceStream *ps,
353 // informs that dataManager server of the name of the paradynd
354 // executable (paradynd, paradyndPVM, ...)
355 void sendParadyndName (String name);
356 $smember applicationContext *appContext;
357 $smember String paradynd_name;
359 $smember int sock_fd;