2 * Copyright (c) 1996 Barton P. Miller
4 * We provide the Paradyn Parallel Performance Tools (below
5 * described as Paradyn") on an AS IS basis, and do not warrant its
6 * validity or performance. We reserve the right to update, modify,
7 * or discontinue this software at any time. We shall have no
8 * obligation to supply such updates or modifications or any other
9 * form of support to you.
11 * This license is for research uses. For such uses, there is no
12 * charge. We define "research use" to mean you may freely use it
13 * inside your organization for whatever purposes you see fit. But you
14 * may not re-distribute Paradyn or parts of Paradyn, in any form
15 * source or binary (including derivatives), electronic or otherwise,
16 * to any other organization or entity without our permission.
18 * (for other uses, please contact us at paradyn@cs.wisc.edu)
20 * All warranties, including without limitation, any warranty of
21 * merchantability or fitness for a particular purpose, are hereby
24 * By your use of Paradyn, you understand and agree that we (or any
25 * other person or entity with proprietary rights in Paradyn) are
26 * under no obligation to provide either maintenance services,
27 * update services, notices of latent defects, or correction of
28 * defects for Paradyn.
30 * Even if advised of the possibility of such damages, under no
31 * circumstances shall we (or any other person or entity with
32 * proprietary rights in the software licensed hereunder) be liable
33 * to you or any third party for direct, indirect, or consequential
34 * damages of any character regardless of type of action, including,
35 * without limitation, loss of profits, loss of use, loss of good
36 * will, or computer failure or malfunction. You agree to indemnify
37 * us (and any other person or entity with proprietary rights in the
38 * software licensed hereunder) for any and all liability it may
39 * incur to third parties resulting from your use of Paradyn.
48 * Revision 1.22 1997/12/01 02:15:45 tung
49 * modified for Linux/X86 Platform
51 * Revision 1.21 1997/07/22 19:09:56 naim
52 * Changes to make fork work on aix. Also, some change to make exec work on
53 * solaris. Althought it works now, there are still some things to be done
54 * for exec related to the visis - naim
56 * Revision 1.20 1997/07/16 19:13:55 naim
57 * Fixing fork on sunos - naim
59 * Revision 1.19 1997/07/14 20:43:23 naim
60 * Fixing problem with fork on x86 - naim
62 * Revision 1.18 1997/05/07 19:01:55 naim
63 * Getting rid of old support for threads and turning it off until the new
64 * version is finished. Additionally, new superTable, baseTable and superVector
65 * classes for future support of multiple threads. The fastInferiorHeap class has
68 * Revision 1.17 1997/03/23 16:53:11 zhichen
69 * based on process::pdFlavor, set initial inst accordingly.
71 * Revision 1.16 1997/02/21 20:15:47 naim
72 * Moving files from paradynd to dyninstAPI + eliminating references to
73 * dataReqNode from the ast class. This is the first pre-dyninstAPI commit! - naim
75 * Revision 1.15 1997/01/27 19:40:41 naim
76 * Part of the base instrumentation for supporting multithreaded applications
77 * (vectors of counter/timers) implemented for all current platforms +
78 * different bug fixes - naim
80 * Revision 1.14 1996/12/11 17:02:48 mjrg
81 * fixed problems with handling of fork and exec
83 * Revision 1.13 1996/11/14 14:27:00 naim
84 * Changing AstNodes back to pointers to improve performance - naim
86 * Revision 1.12 1996/10/31 08:44:32 tamches
87 * in initOS(), main no longer calls DYNINSTinit
89 * Revision 1.11 1996/09/26 18:58:32 newhall
90 * added support for instrumenting dynamic executables on sparc-solaris
93 * Revision 1.10 1996/08/16 21:18:44 tamches
94 * updated copyright for release 1.1
96 * Revision 1.9 1996/08/12 16:27:16 mjrg
97 * Code cleanup: removed cm5 kludges and some unused code
99 * Revision 1.8 1996/05/08 23:54:45 mjrg
100 * added support for handling fork and exec by an application
101 * use /proc instead of ptrace on solaris
104 * Revision 1.7 1996/03/20 17:02:44 mjrg
105 * Added multiple arguments to calls.
106 * Instrument pvm_send instead of pvm_recv to get tags.
108 * Revision 1.6 1996/03/01 22:31:59 mjrg
109 * Replaced calls at the exit point by a call to DYNINSTexit
111 * Revision 1.5 1995/12/15 22:26:48 mjrg
112 * Merged paradynd and paradyndPVM
113 * Get module name for functions from symbol table in solaris
114 * Fixed code generation for multiple instrumentation statements
115 * Changed syntax of MDL resource lists
117 * Revision 1.4 1995/08/24 15:03:54 hollings
118 * AIX/SP-2 port (including option for split instruction/data heaps)
119 * Tracing of rexec (correctly spawns a paradynd if needed)
120 * Added rtinst function to read getrusage stats (can now be used in metrics)
122 * Improved Error reporting in MDL sematic checks
123 * Fixed MDL Function call statement
124 * Fixed bugs in TK usage (strings passed where UID expected)
128 #include "paradynd/src/metric.h"
129 #include "paradynd/src/internalMetrics.h"
130 #include "dyninstAPI/src/inst.h"
131 #include "paradynd/src/init.h"
132 #include "dyninstAPI/src/ast.h"
133 #include "dyninstAPI/src/util.h"
134 #include "dyninstAPI/src/os.h"
136 // NOTE - the tagArg integer number starting with 0.
137 static AstNode *tagArg = new AstNode(AstNode::Param, (void *) 1);
138 static AstNode *cmdArg = new AstNode(AstNode::Param, (void *) 4);
139 static AstNode *tidArg = new AstNode(AstNode::Param, (void *) 0);
140 static AstNode *retVal = new AstNode(AstNode::ReturnVal, (void *) 0);
141 #if defined(SHM_SAMPLING) && defined(MT_THREAD)
142 static AstNode *THRidArg = new AstNode(AstNode::Param, (void *) 5);
147 // initialRequests += new instMapping("main", "DYNINSTinit", FUNC_ENTRY);
148 // (obsoleted by installBootstrapInst() --ari)
151 initialRequests += new instMapping("main", "DYNINSTexit", FUNC_EXIT);
153 initialRequests += new instMapping(EXIT_NAME, "DYNINSTexit", FUNC_ENTRY);
154 if(process::pdFlavor != string("cow"))
156 initialRequests += new instMapping("_fork", "DYNINSTfork",
157 FUNC_EXIT|FUNC_ARG, retVal);
159 #if defined(SHM_SAMPLING) && defined(MT_THREAD)
160 initialRequests += new instMapping("MY_thr_create", "DYNINSTthreadCreate",
161 FUNC_EXIT|FUNC_ARG, THRidArg);
164 if(process::pdFlavor != string("cow"))
166 //initialRequests += new instMapping("execve", "DYNINSTexec",
167 // FUNC_ENTRY|FUNC_ARG, tidArg);
168 //initialRequests += new instMapping("execve", "DYNINSTexecFailed", FUNC_EXIT);
169 initialRequests += new instMapping("_execve", "DYNINSTexec",
170 FUNC_ENTRY|FUNC_ARG, tidArg);
171 initialRequests += new instMapping("_execve", "DYNINSTexecFailed", FUNC_EXIT);
175 initialRequests += new instMapping("DYNINSTsampleValues", "DYNINSTreportNewTags",
179 if(process::pdFlavor != string("cow"))
181 initialRequests += new instMapping("rexec", "DYNINSTrexec",
182 FUNC_ENTRY|FUNC_ARG, cmdArg);
184 // initialRequests += new instMapping("PROCEDURE_LINKAGE_TABLE","DYNINSTdynlinker",FUNC_ENTRY);
190 initialRequests += new instMapping("pvm_send", "DYNINSTrecordTag",
191 FUNC_ENTRY|FUNC_ARG, tagArg);
193 // kludge to get Critical Path to work.
194 // XXX - should be tunable constant.
195 doPiggy = getenv("DYNINSTdoPiggy");
197 initialRequests += new instMapping("main", "DYNINSTpvmPiggyInit", FUNC_ENTRY);
198 initialRequests+= new instMapping("pvm_send", "DYNINSTpvmPiggySend",
199 FUNC_ENTRY|FUNC_ARG, tidArg);
200 initialRequests += new instMapping("pvm_recv", "DYNINSTpvmPiggyRecv", FUNC_EXIT);
201 initialRequests += new instMapping("pvm_mcast", "DYNINSTpvmPiggyMcast",
202 FUNC_ENTRY|FUNC_ARG, tidArg);