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.
43 * This file contains the standard insrumentation functions that are provied
44 * by the instrumentation layer.
51 /* We sometimes include this into assembly files, so guard the struct defs. */
52 #if !defined(__ASSEMBLER__)
54 /* If we must make up a boolean type, we should make it unique */
55 #define RT_Boolean unsigned char
59 //typedef void (*instFunc)(void *cdata, int type, char *eventData);
61 /* parameters to a instremented function */
62 typedef enum { processTime, wallTime } timerType;
64 /* 64 bit time values */
65 typedef long long int time64;
66 typedef long long int int64;
70 /* formerly an aggregate bit, but that's now obsolete */
72 typedef struct sampleIdRec sampleId;
90 struct intCounterRec {
91 int value; /* this field must be first for setValue to work -jkh */
94 unsigned char theSpinner;
95 /* mutex serving 2 purposes: (1) so paradynd won't sample while we're in middle of
96 updating and (2) so multiple LWPs or threads won't update at the same time */
98 typedef struct intCounterRec intCounter;
100 struct floatCounterRec {
104 typedef struct floatCounterRec floatCounter;
108 volatile time64 total;
109 volatile time64 start;
110 volatile int counter;
111 volatile sampleId id; /* can be made obsolete in the near future */
113 /* the following 2 vrbles are used to implement consistent sampling.
114 Updating by rtinst works as follows: bump protector1, do action, then
115 bump protector2. Shared-memory sampling by paradynd works as follows:
116 read protector2, read the 3 vrbles above, read protector1. If
117 the 2 protector values differ then try again, else the sample got
118 a good snapshot. Don't forget to be sure paradynd reads the protector
119 vrbles in the _opposite_ order that rtinst writes them!!! */
120 volatile int protector1;
121 volatile int protector2;
125 volatile int counter; /* must be 0 to start; must be 1 to stop */
126 volatile time64 total;
127 volatile time64 start;
128 volatile time64 lastValue; /* to check for rollback */
129 volatile time64 snapShot; /* used to get consistant value
131 volatile int normalize; /* value to divide total by to
133 /* always seems to be MILLION; can we get rid
135 volatile timerType type;
136 volatile sampleId id;
138 // volatile char sampled; /* is this used? */
140 // volatile unsigned char theSpinner;
141 /* mutex serving 2 purposes: (1) so paradynd won't sample while we're in middle of
142 updating and (2) so multiple LWPs or threads won't update at the same time */
145 typedef struct tTimerRec tTimer;
147 typedef int traceStream;
149 void DYNINSTgenerateTraceRecord(traceStream sid, short type,
151 void *eventData, int flush,
152 time64 wall_time,time64 process_time);
153 extern time64 DYNINSTgetCPUtime(void);
154 extern time64 DYNINSTgetWalltime(void);
156 #if defined(MT_THREAD)
157 #define MAX_NUMBER_OF_THREADS (100)
158 extern int DYNINSTthreadPos(void);
159 extern int DYNINSTthreadSelf(void);
163 The tramp table is used when we need to insert traps in instrumentation
164 points. It is used by the trap handler to lookup the base tramp for
167 The table is updated by the paradyn daemon.
170 #define TRAMPTABLESZ (4096)
172 #define HASH1(x) ((x) % TRAMPTABLESZ)
173 #define HASH2(x) (((x) % TRAMPTABLESZ-1) & 1)
175 typedef struct trampTableEntryStruct trampTableEntry;
176 struct trampTableEntryStruct {
184 * Define the size of the per process data area.
186 * This should be a power of two to reduce paging and chacing shifts.
189 /* The only possible problem with 1024*1024 instead of 1024*256 is that
190 * HP needs to handle longjumps in mini-trampolines...sparc doesn't have
191 * this problem until the size gets much bigger...
194 #define SYN_INST_BUF_SIZE 1024*1024*4