added pause/continue Process.
[dyninst.git] / paradyn / h / dataManager.I
1 /*
2  * dataManager.h - exported services of the Data Mgr thread of paradyn.
3  *
4  * $Log: dataManager.I,v $
5  * Revision 1.7  1994/03/31 01:37:21  markc
6  * added pause/continue Process.
7  *
8  * Revision 1.6  1994/03/20  01:48:51  markc
9  * Added support for paradyn daemon name.  igen function to store name.
10  *
11  * Revision 1.5  1994/03/08  17:39:23  hollings
12  * Added foldCallback and getResourceListName.
13  *
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.
17  *
18  * Revision 1.3  1994/02/03  23:26:50  hollings
19  * Changes to work with g++ version 2.5.2.
20  *
21  * Revision 1.2  1994/02/01  18:47:33  hollings
22  * Upgrades for performanceConsultant thread.
23  *
24  * Revision 1.1  1994/01/27  00:41:37  hollings
25  * First version of data manager interfaces.
26  *
27  */
28
29 #ifndef MMTHREAD_H
30 #define MMTHREAD_H
31
32 #include "util/h/list.h"
33 #include "rtinst/h/trace.h"
34 #include "util/h/hist.h"
35 #include "dyninstRPC.h"
36
37 /* one or more program working together */
38 class applicationContext;       
39
40 /* sequence of peformance data (trace|sample) */
41 class performanceStream;        
42
43 /* time */
44 // typedef double timeStamp;            
45
46 /* something that data can be collected for */
47 class resource;         
48
49 /* descriptive information about a resource */
50 typedef struct {
51     char *name;                 /* name of actual resource */
52     char *fullName;             /* full path name of resource */
53     timeStamp creation;         /* when did it get created */
54 } resourceInfo;         
55
56 /* list of resources */
57 class resourceList;             
58
59 /* a metric */
60 class metric;                   
61
62 /* a list of metrics */
63 typedef metric *metricList;             
64
65 /* a metric/resourceList pair */
66 class metricInstance;           
67
68 typedef enum { Trace, Sample } dataType;
69
70 /*
71  * error handler call back.
72  *
73  */
74 typedef (*errorHandler)(int errno, char *message);
75
76 /*
77  * Handler that gets called when new sample data is delivered.
78  *
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
84  *    
85  */
86 typedef (*sampleDataCallbackFunc)(performanceStream *ps, 
87                                   metricInstance *mi,
88                                   timeStamp startTimeStamp, 
89                                   timeStamp endTimeStamp, 
90                                   sampleValue value);
91
92 /*
93  * Handler that gets called when new trace data is available.
94  *   
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.
100  */
101 typedef (*traceDataCallbackFunc)(performanceStream *ps, metricInstance *mi,
102     timeStamp time, int eventSize, void *eventData);
103
104 /*
105  * union to hold two types of data callback.
106  *
107  */
108 union dataCallback {
109     sampleDataCallbackFunc      sample;
110     traceDataCallbackFunc       trace;
111 };
112
113 typedef union dataCallback dataCallback;
114
115 /*
116  * Handler that gets called when a new metric is defined.
117  *
118  * performanceStream    - a stream returned by createPerformanceStream
119  * metric               - a metric
120  *
121  */
122 typedef void (*metricInfoCallback)(performanceStream*, metric*);
123
124 /*
125  * Handler that gets called when a new resource is defined.
126  *
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
131  *
132  */
133 typedef void (*resourceInfoCallback)(performanceStream*, resource *parent, 
134     resource *newResource, char *name);
135
136 typedef void (*histFoldCallback)(performanceStream*, timeStamp width);
137
138 struct controlCallback {
139     metricInfoCallback          mFunc;
140     resourceInfoCallback        rFunc;
141     histFoldCallback            fFunc;
142 };
143
144 typedef struct controlCallback controlCallback;
145
146
147 $remote dataManager {
148     $base 2000;
149     $version 3;
150
151     //
152     // Create an applicationContext (an application to be studied)
153     //
154     applicationContext *createApplicationContext(errorHandler foo);
155
156     //
157     // Define a program to run. 
158     //
159     Boolean addExecutable(applicationContext *app,
160                           char  *machine, 
161                           char *login, 
162                           char *name, 
163                           int argc,
164                           char **argv);
165
166     //
167     // Find out if an application has been defined yet.
168     //
169     Boolean applicationDefined(applicationContext *app);
170
171     //
172     // Start an application running (This starts the actual execution).
173     //   app - an application context from createPerformanceConext.
174     // 
175     Boolean startApplication(applicationContext *app);
176
177     //
178     //   Stop all processes associted with the application.
179     //      app - an application context from createPerformanceConext.
180     //
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?
184     //
185     Boolean pauseApplication(applicationContext *app);
186
187     //
188     //   Stop all processes associted with the application.
189     //      app - an application context from createPerformanceConext.
190     //
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?
194     //
195     Boolean pauseProcess(applicationContext *app, int pid);
196
197     //
198     //
199     // Continue a paused application.
200     //    app - an application context from createPerformanceConext.
201     //
202     Boolean continueApplication(applicationContext *app);
203
204     //
205     // Continue a paused process in an application.
206     //    app - an application context from createPerformanceConext.
207     //
208     Boolean continueProcess(applicationContext *app, int pid);
209
210     //
211     // Disconnect the tool from the process.
212     //    app - an application context from createPerformanceConext.
213     //    pause - leave the process in a stopped state.
214     //
215     Boolean detachApplication(applicationContext *app,Boolean pause);
216
217     // 
218     // Create a performanceStream.  This a flow of performance information
219     //   to a destination. 
220     //
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)
226     //
227     performanceStream *createPerformanceStream(applicationContext*, 
228                                                dataType, 
229                                                dataCallback, 
230                                                controlCallback);
231         
232
233     void setSampleRate(performanceStream *stream, timeStamp sampleInterval);
234
235     //
236     // Routines to control data collection on a performanceStream.
237     //
238     // performanceStream        - a stream returned by createPerformanceStream
239     // resourceList             - a list of resources
240     // metric           - what metric to collect data for
241     //
242     metricInstance *enableDataCollection(performanceStream*,
243                                          resourceList*,
244                                          metric*);
245
246     //
247     // stop collecting data for the named metricInstance.
248     // performanceStream        - a stream returned by createPerformanceStream
249     // metricInstance   - a metricInstance returned by enableDataCollection.
250     //
251     void disableDataCollection(performanceStream*, metricInstance*);
252
253     //
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).
257     //
258     float getPredictedDataCost(applicationContext*, resourceList*, metric*);
259
260     //
261     // Control information arriving about a resource Classes
262     //
263     // performanceStream        - a stream returned by createPerformanceStream
264     // resource         - enable notification of children of this resource
265     //
266     void enableResourceCreationNotification(performanceStream*, resource*);
267
268     //
269     // Turn off notification of creation of descendants of this resource.
270     // 
271     // performanceStream        - a stream returned by createPerformanceStream
272     // resource         - disable notification of descendants of this resource
273     //
274     //
275     void disableResourceCreationNotification(performanceStream*, resource*);
276
277     //
278     // Resource utility functions.
279     //
280     resource *getRootResource();
281
282     resourceList *getRootResources();
283
284     char *getResourceName(resource*);
285
286     resource *getResourceParent(resource*);
287
288     resource *newResource(applicationContext *app,
289                           resource *parent, 
290                           char *name);
291
292     resourceList *getResourceChildren(resource*);
293
294     Boolean isResourceDescendent(resource *parent, resource *child);
295
296     resource *findChildResource(resource *parent, char *name);
297
298     int getResourceCount(resourceList*);
299
300     resource *getNthResource(resourceList*, int n);
301
302     resourceList *createResourceList();
303
304     void addResourceList(resourceList*, resource*);
305
306     //
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.
310     //   
311     char *getResourceListName(resourceList*);
312
313     // Get the static config. information for the passed applicationContext.
314     //
315     $array String getAvailableMetrics(applicationContext*);
316
317     //
318     // looks for a specifc metric instance in an application context.
319     //
320     metric *findMetric(applicationContext *context, char *name);
321
322     //
323     // Metric utility functions.
324     //
325     char *getMetricName(metric*);
326
327     //
328     // get the supporting info about a metric.
329     metricInfo *getMetricInfo(metric*);
330
331     //
332     // Get metric out of a metric instance.
333     //
334     metric *getMetric(metricInstance*);
335     char *getMetricNameFromMI(metricInstance*);
336
337     //
338     // Get the value of a metric.
339     //
340     sampleValue getMetricValue(metricInstance*);
341
342     //
343     // Debugger style calls.
344     //
345     void printResources();
346     void printStatus(applicationContext*);
347     void coreProcess(applicationContext*, int pid);
348
349     //
350     // upcalls for indications of events.
351     //
352     $upcall $async void newMetricDefined(metricInfoCallback, 
353                                          performanceStream*, 
354                                          metric*);
355
356     $upcall $async void newResourceDefined(resourceInfoCallback,
357                                            performanceStream *ps, 
358                                            resource *parent,
359                                            resource *newResource, 
360                                            char *name);
361
362     $upcall $async void newPerfData(sampleDataCallbackFunc, 
363                                     performanceStream *ps,
364                                     metricInstance *mi,
365                                     timeStamp startTimeStamp, 
366                                     timeStamp endTimeStamp, 
367                                     sampleValue value);
368
369     $upcall $async void histFold(histFoldCallback, 
370                                  performanceStream *ps, 
371                                  timeStamp width);
372
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;
378     $smember int socket;
379     $smember int sock_fd;
380 };
381
382 #endif