3 * inst-sunos.C - sunos specifc code for paradynd.
5 * $Log: inst-sunos.C,v $
6 * Revision 1.22 1994/11/11 10:44:03 markc
7 * Remove non-emergency prints
8 * Changed others to use statusLine
10 * Revision 1.21 1994/11/11 10:11:40 markc
11 * Used correct arg order for RPC_make_arg_list
13 * Revision 1.20 1994/11/11 07:04:55 markc
14 * Added code to bundle extra command line argument.
16 * Revision 1.19 1994/11/10 18:58:02 jcargill
17 * The "Don't Blame Me Either" commit
19 * Revision 1.18 1994/11/09 18:40:10 rbi
20 * the "Don't Blame Me" commit
22 * Revision 1.17 1994/11/02 11:06:19 markc
23 * Removed redundant code into inst.C
24 * Provide "tag" dictionary for known functions.
26 * Revision 1.16 1994/10/13 07:24:45 krisna
27 * solaris porting and updates
29 * Revision 1.15 1994/09/30 19:47:05 rbi
30 * Basic instrumentation for CMFortran
32 * Revision 1.14 1994/09/22 01:58:53 markc
33 * Enter handles for primitiveCosts into stringPool
34 * changed libraryList to List<libraryFunc*>
36 * Revision 1.13 1994/09/20 18:18:25 hollings
37 * added code to use actual clock speed for cost model numbers.
39 * Revision 1.12 1994/08/17 18:11:59 markc
40 * Changed the execv to execvp.
41 * Changed arglist in forkProcess.
43 * Revision 1.11 1994/07/22 19:16:36 hollings
44 * moved computePauseTimeMetric here, and added lib func calls for cmmd routines.
46 * Revision 1.10 1994/07/15 20:22:03 hollings
47 * fixed 64 bit record to be 32 bits.
49 * Revision 1.9 1994/07/14 23:30:26 hollings
50 * Hybrid cost model added.
52 * Revision 1.8 1994/07/12 19:46:57 jcargill
53 * Removed old code, added ability for fork paradyndCM5 when nodes start.
55 * Revision 1.7 1994/07/05 03:26:04 hollings
58 * Revision 1.6 1994/06/29 02:52:29 hollings
59 * Added metricDefs-common.{C,h}
60 * Added module level performance data
61 * cleanedup types of inferrior addresses instrumentation defintions
62 * added firewalls for large branch displacements due to text+data over 2meg.
65 * Revision 1.5 1994/06/27 18:56:49 hollings
66 * removed printfs. Now use logLine so it works in the remote case.
67 * added internalMetric class.
68 * added extra paramter to metric info for aggregation.
70 * Revision 1.4 1994/03/26 20:50:47 jcargill
71 * Changed the pause/continue code. Now it really stops, instead of
74 * Revision 1.3 1994/03/22 21:03:14 hollings
75 * Made it possible to add new processes (& paradynd's) via addExecutable.
77 * Revision 1.2 1994/03/20 01:53:07 markc
78 * Added a buffer to each process structure to allow for multiple writers on the
79 * traceStream. Replaced old inst-pvm.C. Changed addProcess to return type
82 * Revision 1.1 1994/02/07 17:38:48 hollings
83 * Added inst-sunos to split cm-5 code from standard sunos code.
88 char inst_sunos_ident[] = "@(#) $Header: /home/jaw/CVSROOT_20081103/CVSROOT/core/paradynd/src/Attic/inst-sunos.C,v 1.22 1994/11/11 10:44:03 markc Exp $";
90 #include "util/h/kludges.h"
94 #include "rtinst/h/trace.h"
100 #include "ptrace_emul.h"
101 #include "dyninstRPC.SRVR.h"
105 #include "perfStream.h"
109 char *getProcessStatus(process *proc)
113 switch (proc->status) {
115 sprintf(ret, "%d running", proc->pid);
118 sprintf(ret, "%d neonatal", proc->pid);
121 sprintf(ret, "%d stopped", proc->pid);
124 sprintf(ret, "%d exited", proc->pid);
127 sprintf(ret, "%d UNKNOWN State", proc->pid);
134 // All costs are based on Measurements on a SPARC station 10/40.
136 void initPrimitiveCost()
138 /* Need to add code here to collect values for other machines */
140 // these happen async of the rest of the system.
141 primitiveCosts["DYNINSTalarmExpire"] = 1;
142 primitiveCosts["DYNINSTsampleValues"] = 1;
143 primitiveCosts["DYNINSTreportTimer"] = 1;
144 primitiveCosts["DYNINSTreportCounter"] = 1;
145 primitiveCosts["DYNINSTreportCost"] = 1;
146 primitiveCosts["DYNINSTreportNewTags"] = 1;
147 primitiveCosts["DYNINSTprintCost"] = 1;
149 // this doesn't really take any time
150 primitiveCosts["DYNINSTbreakPoint"] = 1;
152 // this happens before we start keeping time.
153 primitiveCosts["DYNINSTinit"] = 1;
155 // isthmus acutal numbers from 7/3/94 -- jkh
157 primitiveCosts["DYNINSTincrementCounter"] = 16;
159 primitiveCosts["DYNINSTdecrementCounter"] = 16;
160 // 7.4 usec * 70 mhz (SS-5)
161 primitiveCosts["DYNINSTstartWallTimer"] = 518;
162 // 9.6 usec * 70 mhz (SS-5)
163 primitiveCosts["DYNINSTstopWallTimer"] = 841;
164 // 1.80 usec * 70 Mhz (measured on a SS-5)
165 primitiveCosts["DYNINSTstartProcessTimer"] = 126;
166 // 3.46 usec * 70 mhz (measured on a SS-5)
167 primitiveCosts["DYNINSTstopProcessTimer"] = 242;
176 void forkNodeProcesses(process *curr, traceHeader *hr, traceFork *fr)
182 char application[256];
187 if (!processMap.defines(fr->ppid)) {
188 sprintf(errorLine, "In forkNodeProcesses, parent id %d unknown", fr->ppid);
189 statusLine(errorLine);
192 parent = processMap[fr->ppid];
196 arg_list = RPC_make_arg_list (pd_family, pd_type,
197 pd_known_socket, pd_flag, 0, pd_machine);
199 sprintf (command, "%sCM5", programName);
200 sprintf (application, "%s", (curr->symbols->file).string_of());
201 sprintf (app_pid, "%d", curr->pid);
202 sprintf (num_nodes, "%d", fr->npids);
205 * It would be nice if this weren't sensitive to the size of
206 * arg_list. For the moment, only arg_list[0] --> arg_list[5]
207 * are written by RPC_make_arg_list (arg_list[6] is NULL).
208 * This is a small-time hack.
212 argv[1] = application;
215 argv[4] = arg_list[0];
216 argv[5] = arg_list[1];
217 argv[6] = arg_list[2];
218 argv[7] = arg_list[3];
219 argv[8] = arg_list[4];
220 argv[9] = arg_list[5];
223 if ((childPid=fork()) == 0) { /* child */
225 /* ptrace (0, 0, 0, 0, 0); */
227 execvp (command, argv);
228 logLine("Exec failed in paradynd to start paradyndCM5\n");
232 sprintf (errorLine, "forked child process (pid=%d)", childPid);
233 statusLine(errorLine);
236 /* Mark the cm-process as running now */
237 // curr->status = running;
244 * Define the various classes of library functions to inst.
247 void initLibraryFunctions()
249 /* should record waiting time in read/write, but have a conflict with
250 * use of these functions by our inst code.
251 * This happens when a CPUtimer that is stopped is stopped again by the
252 * write. It is then started again at the end of the write and should
253 * not be running then. We could let timers go negative, but this
254 * causes a problem when inst is inserted into already running code.
255 * Not sure what the best fix is - jkh 10/4/93
258 tagDict["write"] = TAG_LIB_FUNC | TAG_IO_OUT;
259 tagDict["read"] = TAG_LIB_FUNC | TAG_IO_IN;
261 tagDict["DYNINSTalarmExpire"] = TAG_LIB_FUNC;
262 tagDict["DYNINSTsampleValues"] = TAG_LIB_FUNC;
263 tagDict[EXIT_NAME] = TAG_LIB_FUNC;
264 tagDict["fork"] = TAG_LIB_FUNC;
266 tagDict["cmmd_debug"] = TAG_LIB_FUNC;
267 tagDict["CMRT_init"] = TAG_LIB_FUNC;
268 tagDict["CMMD_send"] = TAG_LIB_FUNC;
269 tagDict["CMMD_receive"] = TAG_LIB_FUNC;
270 tagDict["CMMD_receive_block"] = TAG_LIB_FUNC;
271 tagDict["CMMD_send_block"] = TAG_LIB_FUNC;
272 tagDict["CMMD_send_async"] = TAG_LIB_FUNC;
273 tagDict["CMMD_send_async"] = TAG_LIB_FUNC;
278 float computePauseTimeMetric()
281 timeStamp elapsed=0.0;
283 now = getCurrentTime(false);
284 if (firstRecordTime) {
285 elapsed = elapsedPauseTime;
286 if (isApplicationPaused())
287 elapsed += now - startPause;
289 assert(elapsed >= 0.0);
296 void osDependentInst(process *proc) {