Adding bucket_width metric - naim
[dyninst.git] / paradynd / src / init.C
1
2 /*
3  * $Log: init.C,v $
4  * Revision 1.15  1995/11/30 16:53:50  naim
5  * Adding bucket_width metric - naim
6  *
7  * Revision 1.14  1995/11/28  15:55:24  naim
8  * Changing metrics observed_cost, predicted_cost and pause_time back to
9  * normal mode - naim
10  *
11  * Revision 1.13  1995/11/17  17:24:21  newhall
12  * support for MDL "unitsType" option, added normalized member to metric class
13  *
14  * Revision 1.12  1995/11/13  16:28:24  naim
15  * Making observed_cost, predicted_cost, active_processes and pause_time "normal"
16  * metrics and not "developer" mode metrics - naim
17  *
18  * Revision 1.11  1995/11/13  14:56:31  naim
19  * Making all internal metrics "developer mode" metrics - naim
20  *
21  * Revision 1.10  1995/09/26  20:28:46  naim
22  * Minor warning fixes and some other minor error messages fixes
23  *
24  * Revision 1.9  1995/07/24  03:52:34  tamches
25  * The Procedure -- > Code commit
26  *
27  * Revision 1.8  1995/05/18  10:34:38  markc
28  * Removed resource definitions
29  *
30  * Revision 1.7  1995/03/10  19:33:46  hollings
31  * Fixed several aspects realted to the cost model:
32  *     track the cost of the base tramp not just mini-tramps
33  *     correctly handle inst cost greater than an imm format on sparc
34  *     print starts at end of pvm apps.
35  *     added option to read a file with more accurate data for predicted cost.
36  *
37  * Revision 1.6  1995/02/16  08:53:12  markc
38  * Corrected error in comments -- I put a "star slash" in the comment.
39  *
40  * Revision 1.5  1995/02/16  08:33:19  markc
41  * Changed igen interfaces to use strings/vectors rather than char igen-arrays
42  * Changed igen interfaces to use bool, not Boolean.
43  * Cleaned up symbol table parsing - favor properly labeled symbol table objects
44  * Updated binary search for modules
45  * Moved machine dependnent ptrace code to architecture specific files.
46  * Moved machine dependent code out of class process.
47  * Removed almost all compiler warnings.
48  * Use "posix" like library to remove compiler warnings
49  *
50  * Revision 1.4  1994/11/10  18:57:57  jcargill
51  * The "Don't Blame Me Either" commit
52  *
53  * Revision 1.3  1994/11/09  18:40:01  rbi
54  * the "Don't Blame Me" commit
55  *
56  * Revision 1.1  1994/11/01  16:56:42  markc
57  * Environment code that is shared by all environs (pvm, cm5, sunos)
58  *
59  */
60
61 #include "metric.h"
62 #include "internalMetrics.h"
63 #include "inst.h"
64 #include "init.h"
65 #include "resource.h"
66
67 extern pdRPC *tp;
68
69 internalMetric *activeProcs = NULL;
70 internalMetric *pauseTime = NULL;
71 internalMetric *totalPredictedCost= NULL;
72 internalMetric *hybridPredictedCost = NULL;
73 internalMetric *observed_cost = NULL;
74
75 internalMetric *cpu_daemon = NULL;
76 internalMetric *sys_daemon = NULL;
77
78 internalMetric *minflt_daemon = NULL;
79 internalMetric *majflt_daemon = NULL;
80 internalMetric *swap_daemon = NULL;
81 internalMetric *io_in_daemon = NULL;
82 internalMetric *io_out_daemon = NULL;
83 internalMetric *msg_send_daemon = NULL;
84 internalMetric *msg_recv_daemon = NULL;
85 internalMetric *sigs_daemon = NULL;
86 internalMetric *vol_csw_daemon = NULL;
87 internalMetric *inv_csw_daemon = NULL;
88
89 internalMetric *c_bucket_width = NULL;
90 internalMetric *g_bucket_width = NULL;
91
92 vector<instMapping*> initialRequests;
93 vector<sym_data> syms_to_find;
94
95 // In Elmer Fudd voice: "Be vewwwey vewwey careful!"
96
97 bool init() {
98   struct utsname un;
99   P_uname(&un);
100   string hostName(un.nodename);
101   rootResource = new resource;
102   machineRoot = resource::newResource(rootResource, NULL, nullString,
103                                       "Machine", 0.0, "");
104   machineResource = resource::newResource(machineRoot, NULL, nullString, hostName, 0.0, "");
105   processResource = resource::newResource(rootResource, NULL, nullString,
106                                           "Process", 0.0, "");
107 //  moduleRoot = resource::newResource(rootResource, NULL, nullString,
108 //                                   "Procedure", 0.0, "");
109   moduleRoot = resource::newResource(rootResource, NULL, nullString,
110                                      "Code", 0.0, "");
111   syncRoot = resource::newResource(rootResource, NULL, nullString, 
112                                    "SyncObject", 0.0, "");
113
114   // TODO -- should these be detected and built ?
115   resource::newResource(syncRoot, NULL, nullString, "MsgTag", 0.0, "");
116   resource::newResource(syncRoot, NULL, nullString, "SpinLock", 0.0, "");
117   resource::newResource(syncRoot, NULL, nullString, "Barrier", 0.0, "");
118   resource::newResource(syncRoot, NULL, nullString, "Semaphore", 0.0, "");
119
120   im_pred_struct default_im_preds, obs_cost_preds;
121   default_im_preds.machine = pred_null;
122   default_im_preds.procedure = pred_invalid;
123   default_im_preds.process = pred_invalid;
124   default_im_preds.sync = pred_invalid;
125
126   obs_cost_preds.machine = pred_null;
127   obs_cost_preds.procedure = pred_invalid;
128   obs_cost_preds.process = pred_null;
129   obs_cost_preds.sync = pred_invalid;
130
131   c_bucket_width = internalMetric::newInternalMetric("c_bucket_width", 
132                                                    SampledFunction,
133                                                    aggMax,
134                                                    "operations",
135                                                    NULL,
136                                                    default_im_preds,
137                                                    true,
138                                                    false);
139
140   g_bucket_width = internalMetric::newInternalMetric("g_bucket_width", 
141                                                    SampledFunction,
142                                                    aggMax,
143                                                    "operations",
144                                                    NULL,
145                                                    default_im_preds,
146                                                    true,
147                                                    false);
148
149   totalPredictedCost = internalMetric::newInternalMetric("predicted_cost",
150                                                          EventCounter,
151                                                          aggMax,        
152                                                          "CPUs",
153                                                          NULL,
154                                                          default_im_preds,
155                                                          false, 
156                                                          true);
157
158   hybridPredictedCost = internalMetric::newInternalMetric("hybrid_cost", 
159                                                           SampledFunction,
160                                                           aggMax,
161                                                           "CPUs",
162                                                           NULL,
163                                                           default_im_preds,
164                                                           true,
165                                                           true);
166
167   observed_cost = internalMetric::newInternalMetric("observed_cost",
168                                                    EventCounter,
169                                                    aggMax,
170                                                    "CPUs",
171                                                    NULL,
172                                                    default_im_preds,
173                                                    false,
174                                                    true);
175
176   cpu_daemon = internalMetric::newInternalMetric("cpu_daemon",
177                                                  EventCounter,
178                                                  aggSum,
179                                                  "CPUs",
180                                                  OS::compute_rusage_cpu,
181                                                  default_im_preds,
182                                                  true,
183                                                  true);
184   
185   sys_daemon = internalMetric::newInternalMetric("sys_daemon",
186                                                  EventCounter,
187                                                  aggSum,
188                                                  "CPUs",
189                                                  OS::compute_rusage_sys,
190                                                  default_im_preds,
191                                                  true,
192                                                  true);
193
194   minflt_daemon = internalMetric::newInternalMetric("min_fault_daemon",
195                                                     EventCounter,
196                                                     aggSum,
197                                                     "operations",
198                                                     OS::compute_rusage_min,
199                                                     default_im_preds,
200                                                     true,
201                                                     false);
202
203   majflt_daemon = internalMetric::newInternalMetric("maj_fault_daemon",
204                                                     EventCounter,
205                                                     aggSum,
206                                                     "operations",
207                                                     OS::compute_rusage_maj,
208                                                     default_im_preds,
209                                                     true,
210                                                     false);
211
212   swap_daemon = internalMetric::newInternalMetric("swap_daemon",
213                                                   EventCounter,
214                                                   aggSum,
215                                                   "operations",
216                                                   OS::compute_rusage_swap,
217                                                   default_im_preds,
218                                                   true,
219                                                   false);
220
221   io_in_daemon = internalMetric::newInternalMetric("io_in_daemon",
222                                                    EventCounter,
223                                                    aggSum,
224                                                    "operations",
225                                                    OS::compute_rusage_io_in,
226                                                    default_im_preds,
227                                                    true,
228                                                    false);
229
230   io_out_daemon = internalMetric::newInternalMetric("io_out_daemon",
231                                                     EventCounter,
232                                                     aggSum,
233                                                     "operations",
234                                                     OS::compute_rusage_io_out,
235                                                     default_im_preds,
236                                                     true,
237                                                     false);
238
239   msg_send_daemon = internalMetric::newInternalMetric("msg_send_daemon",
240                                                     EventCounter,
241                                                     aggSum,
242                                                     "operations",
243                                                     OS::compute_rusage_msg_send,
244                                                     default_im_preds,
245                                                     true,
246                                                     false);
247
248   msg_recv_daemon = internalMetric::newInternalMetric("msg_recv_daemon",
249                                                     EventCounter,
250                                                     aggSum,
251                                                     "operations",
252                                                     OS::compute_rusage_msg_recv,
253                                                     default_im_preds,
254                                                     true,
255                                                     false);
256
257   sigs_daemon = internalMetric::newInternalMetric("signals_daemon",
258                                                   EventCounter,
259                                                   aggSum,
260                                                   "operations",
261                                                   OS::compute_rusage_sigs,
262                                                   default_im_preds,
263                                                   true,
264                                                   false);
265
266   vol_csw_daemon = internalMetric::newInternalMetric("vol_csw_daemon",
267                                                      EventCounter,
268                                                      aggSum,
269                                                      "operations",
270                                                      OS::compute_rusage_vol_cs,
271                                                      default_im_preds,
272                                                      true,
273                                                      false);
274
275   inv_csw_daemon = internalMetric::newInternalMetric("inv_csw_daemon",
276                                                      EventCounter,
277                                                      aggSum,
278                                                      "operations",
279                                                      OS::compute_rusage_inv_cs,
280                                                      default_im_preds,
281                                                      true,
282                                                      false);
283  
284    pauseTime = internalMetric::newInternalMetric("pause_time",
285                                                  EventCounter,
286                                                  aggMax,
287                                                  "CPUs",
288                                                  computePauseTimeMetric,
289                                                  default_im_preds,
290                                                  false,
291                                                  true);
292
293   activeProcs = internalMetric::newInternalMetric("active_processes",
294                                                   EventCounter,
295                                                   aggSum,
296                                                   "operations",
297                                                   NULL,
298                                                   obs_cost_preds,
299                                                   false,
300                                                   false);
301
302   sym_data sd;
303   sd.name = "DYNINSTobsCostLow"; sd.must_find = true; syms_to_find += sd;
304   sd.name = EXIT_NAME; sd.must_find = true; syms_to_find += sd;
305   sd.name = "main"; sd.must_find = true; syms_to_find += sd;
306
307   initDefaultPointFrequencyTable();
308   return (initOS());
309 }
310