2 * dataManager.h - exported services of the Data Mgr thread of paradyn.
4 * $Log: dataManager.I,v $
5 * Revision 1.7 1994/03/31 01:37:21 markc
6 * added pause/continue Process.
8 * Revision 1.6 1994/03/20 01:48:51 markc
9 * Added support for paradyn daemon name. igen function to store name.
11 * Revision 1.5 1994/03/08 17:39:23 hollings
12 * Added foldCallback and getResourceListName.
14 * Revision 1.4 1994/02/24 04:34:14 markc
15 * Added an upcall to dyninstRPC.I to allow paradynd's to report information at
16 * startup. Added a data member to the class that igen generates.
18 * Revision 1.3 1994/02/03 23:26:50 hollings
19 * Changes to work with g++ version 2.5.2.
21 * Revision 1.2 1994/02/01 18:47:33 hollings
22 * Upgrades for performanceConsultant thread.
24 * Revision 1.1 1994/01/27 00:41:37 hollings
25 * First version of data manager interfaces.
32 #include "util/h/list.h"
33 #include "rtinst/h/trace.h"
34 #include "util/h/hist.h"
35 #include "dyninstRPC.h"
37 /* one or more program working together */
38 class applicationContext;
40 /* sequence of peformance data (trace|sample) */
41 class performanceStream;
44 // typedef double timeStamp;
46 /* something that data can be collected for */
49 /* descriptive information about a resource */
51 char *name; /* name of actual resource */
52 char *fullName; /* full path name of resource */
53 timeStamp creation; /* when did it get created */
56 /* list of resources */
62 /* a list of metrics */
63 typedef metric *metricList;
65 /* a metric/resourceList pair */
68 typedef enum { Trace, Sample } dataType;
71 * error handler call back.
74 typedef (*errorHandler)(int errno, char *message);
77 * Handler that gets called when new sample data is delivered.
79 * ps - a performanceStream from createPerformanceStream
80 * mi - a metricInstance returned by enableDataCollection
81 * startTimeStamp - starting time of the interval covered by this sample.
82 * endTimeStamp - ending time of the interval covered by this sample.
83 * value - the value of this sample
86 typedef (*sampleDataCallbackFunc)(performanceStream *ps,
88 timeStamp startTimeStamp,
89 timeStamp endTimeStamp,
93 * Handler that gets called when new trace data is available.
95 * ps - a performanceStream from createPerformanceStream
96 * mi - a metricInstance returned by enableDataCollection
97 * time - time of the event.
98 * eventSize - size of the event specific data.
99 * eventData - event specific data.
101 typedef (*traceDataCallbackFunc)(performanceStream *ps, metricInstance *mi,
102 timeStamp time, int eventSize, void *eventData);
105 * union to hold two types of data callback.
109 sampleDataCallbackFunc sample;
110 traceDataCallbackFunc trace;
113 typedef union dataCallback dataCallback;
116 * Handler that gets called when a new metric is defined.
118 * performanceStream - a stream returned by createPerformanceStream
122 typedef void (*metricInfoCallback)(performanceStream*, metric*);
125 * Handler that gets called when a new resource is defined.
127 * performanceStream - a stream returned by createPerformanceStream
128 * parent - parent of new resource
129 * newResource - new resource being created
130 * name - name of the new resource
133 typedef void (*resourceInfoCallback)(performanceStream*, resource *parent,
134 resource *newResource, char *name);
136 typedef void (*histFoldCallback)(performanceStream*, timeStamp width);
138 struct controlCallback {
139 metricInfoCallback mFunc;
140 resourceInfoCallback rFunc;
141 histFoldCallback fFunc;
144 typedef struct controlCallback controlCallback;
147 $remote dataManager {
152 // Create an applicationContext (an application to be studied)
154 applicationContext *createApplicationContext(errorHandler foo);
157 // Define a program to run.
159 Boolean addExecutable(applicationContext *app,
167 // Find out if an application has been defined yet.
169 Boolean applicationDefined(applicationContext *app);
172 // Start an application running (This starts the actual execution).
173 // app - an application context from createPerformanceConext.
175 Boolean startApplication(applicationContext *app);
178 // Stop all processes associted with the application.
179 // app - an application context from createPerformanceConext.
181 // Pause an application (I am not sure about this but I think we want it).
182 // - Does this force buffered data to be delivered?
183 // - Does a paused application respond to enable/disable commands?
185 Boolean pauseApplication(applicationContext *app);
188 // Stop all processes associted with the application.
189 // app - an application context from createPerformanceConext.
191 // Pause a process in an application
192 // - Does this force buffered data to be delivered?
193 // - Does a paused application respond to enable/disable commands?
195 Boolean pauseProcess(applicationContext *app, int pid);
199 // Continue a paused application.
200 // app - an application context from createPerformanceConext.
202 Boolean continueApplication(applicationContext *app);
205 // Continue a paused process in an application.
206 // app - an application context from createPerformanceConext.
208 Boolean continueProcess(applicationContext *app, int pid);
211 // Disconnect the tool from the process.
212 // app - an application context from createPerformanceConext.
213 // pause - leave the process in a stopped state.
215 Boolean detachApplication(applicationContext *app,Boolean pause);
218 // Create a performanceStream. This a flow of performance information
221 // applicationContext - an application context.
222 // dataType - Sample or Trace
223 // dataCallback - Function to call when new data arrives
224 // controlCallback - Function to call when new structure info arrives
225 // sampleInterval - nominal interval between samples (sample only)
227 performanceStream *createPerformanceStream(applicationContext*,
233 void setSampleRate(performanceStream *stream, timeStamp sampleInterval);
236 // Routines to control data collection on a performanceStream.
238 // performanceStream - a stream returned by createPerformanceStream
239 // resourceList - a list of resources
240 // metric - what metric to collect data for
242 metricInstance *enableDataCollection(performanceStream*,
247 // stop collecting data for the named metricInstance.
248 // performanceStream - a stream returned by createPerformanceStream
249 // metricInstance - a metricInstance returned by enableDataCollection.
251 void disableDataCollection(performanceStream*, metricInstance*);
254 // Return the expected cost of collecting performance data for a single
255 // metric at a given focus. The value returned is the fraction of
256 // perturbation expected (i.e. 0.10 == 10% slow down expected).
258 float getPredictedDataCost(applicationContext*, resourceList*, metric*);
261 // Control information arriving about a resource Classes
263 // performanceStream - a stream returned by createPerformanceStream
264 // resource - enable notification of children of this resource
266 void enableResourceCreationNotification(performanceStream*, resource*);
269 // Turn off notification of creation of descendants of this resource.
271 // performanceStream - a stream returned by createPerformanceStream
272 // resource - disable notification of descendants of this resource
275 void disableResourceCreationNotification(performanceStream*, resource*);
278 // Resource utility functions.
280 resource *getRootResource();
282 resourceList *getRootResources();
284 char *getResourceName(resource*);
286 resource *getResourceParent(resource*);
288 resource *newResource(applicationContext *app,
292 resourceList *getResourceChildren(resource*);
294 Boolean isResourceDescendent(resource *parent, resource *child);
296 resource *findChildResource(resource *parent, char *name);
298 int getResourceCount(resourceList*);
300 resource *getNthResource(resourceList*, int n);
302 resourceList *createResourceList();
304 void addResourceList(resourceList*, resource*);
307 // get the canonical name of a resource list.
308 // WARNING: The returned pointer is allocated in the heap via new
309 // and should be freed using delete when the caller is done with it.
311 char *getResourceListName(resourceList*);
313 // Get the static config. information for the passed applicationContext.
315 $array String getAvailableMetrics(applicationContext*);
318 // looks for a specifc metric instance in an application context.
320 metric *findMetric(applicationContext *context, char *name);
323 // Metric utility functions.
325 char *getMetricName(metric*);
328 // get the supporting info about a metric.
329 metricInfo *getMetricInfo(metric*);
332 // Get metric out of a metric instance.
334 metric *getMetric(metricInstance*);
335 char *getMetricNameFromMI(metricInstance*);
338 // Get the value of a metric.
340 sampleValue getMetricValue(metricInstance*);
343 // Debugger style calls.
345 void printResources();
346 void printStatus(applicationContext*);
347 void coreProcess(applicationContext*, int pid);
350 // upcalls for indications of events.
352 $upcall $async void newMetricDefined(metricInfoCallback,
356 $upcall $async void newResourceDefined(resourceInfoCallback,
357 performanceStream *ps,
359 resource *newResource,
362 $upcall $async void newPerfData(sampleDataCallbackFunc,
363 performanceStream *ps,
365 timeStamp startTimeStamp,
366 timeStamp endTimeStamp,
369 $upcall $async void histFold(histFoldCallback,
370 performanceStream *ps,
373 // informs that dataManager server of the name of the paradynd
374 // executable (paradynd, paradyndPVM, ...)
375 void sendParadyndName (String name);
376 $smember applicationContext *appContext;
377 $smember String paradynd_name;
379 $smember int sock_fd;