Added several calls to API (waitForStatusChange, BPatch_variableExpr
[dyninst.git] / dyninstAPI / h / BPatch_snippet.h
1 /*
2  * Copyright (c) 1996 Barton P. Miller
3  * 
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.
10  * 
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.
17  * 
18  * (for other uses, please contact us at paradyn@cs.wisc.edu)
19  * 
20  * All warranties, including without limitation, any warranty of
21  * merchantability or fitness for a particular purpose, are hereby
22  * excluded.
23  * 
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.
29  * 
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.
40  */
41
42 #ifndef _BPatch_snippet_h_
43 #define _BPatch_snippet_h_
44
45 #include "BPatch_Vector.h"
46
47 class AstNode;
48 class function_base;
49 class process;
50
51 class BPatch_function;
52 class BPatch_point;
53 class BPatch_type;
54
55 typedef enum {
56     BPatch_lt,
57     BPatch_eq,
58     BPatch_gt,
59     BPatch_le,
60     BPatch_ne,
61     BPatch_ge,
62     BPatch_and,
63     BPatch_or
64 } BPatch_relOp;
65
66 typedef enum {
67     BPatch_assign,
68     BPatch_plus,
69     BPatch_minus,
70     BPatch_divide,
71     BPatch_times,
72     BPatch_mod,
73     BPatch_ref,
74     BPatch_seq
75 } BPatch_binOp;
76
77 typedef enum {
78     BPatch_negate,
79     BPatch_address
80 } BPatch_unOp;
81
82
83 /*
84  * Used with BPatch_function::findPoint to specify which of the possible
85  * instrumentation points within a procedure should be returned.
86  */
87 typedef enum {
88     BPatch_entry,
89     BPatch_exit,
90     BPatch_subroutine,
91     BPatch_longJump,
92     BPatch_allLocations
93 } BPatch_procedureLocation;
94
95
96 class BPatch_function {
97     process *proc;
98 public:
99 // The following are for  internal use by the library only:
100     function_base *func;
101     BPatch_function(process *_proc, function_base *_func) :
102         proc(_proc), func(_func) {};
103
104 // For users of the library:
105     char        *getName(char *s, int len);
106
107     BPatch_Vector<BPatch_point *>
108         *findPoint(const BPatch_procedureLocation loc);
109 };
110
111
112 class BPatch_snippet {
113 public:
114 // The following members are for  internal use by the library only:
115     AstNode     *ast; /* XXX It would be better if this was protected */
116 // End members for internal use only.
117
118     BPatch_snippet() : ast(NULL) {};
119     BPatch_snippet(const BPatch_snippet &);
120     BPatch_snippet &operator=(const BPatch_snippet &);
121
122     virtual     ~BPatch_snippet();
123
124     float       getCost();
125 };
126
127 class BPatch_arithExpr: public BPatch_snippet {
128 public:
129     BPatch_arithExpr(BPatch_binOp op,
130                      const BPatch_snippet &lOperand,
131                      const BPatch_snippet &rOperand);
132 };
133
134 class BPatch_boolExpr : public BPatch_snippet {
135 public:
136     BPatch_boolExpr(BPatch_relOp op, const BPatch_snippet &lOperand,
137                     const BPatch_snippet &rOperand);
138 };
139
140 class BPatch_constExpr : public BPatch_snippet {
141 public:
142     BPatch_constExpr(int value);
143 #ifdef BPATCH_NOT_YET
144     BPatch_constExpr(float value);
145 #endif
146     BPatch_constExpr(const char *value);
147 };
148
149 class BPatch_funcCallExpr : public BPatch_snippet {
150 public:
151     BPatch_funcCallExpr(const BPatch_function& func,
152                         const BPatch_Vector<BPatch_snippet *> &args);
153 };
154
155 class BPatch_ifExpr : public BPatch_snippet {
156 public:
157     BPatch_ifExpr(const BPatch_boolExpr &conditional,
158                   const BPatch_snippet &tClase);
159     BPatch_ifExpr(const BPatch_boolExpr &conditional,
160                   const BPatch_snippet &tClase,
161                   const BPatch_snippet &fClause);
162 };
163
164 class BPatch_nullExpr : public BPatch_snippet {
165 public:
166     BPatch_nullExpr();
167 };
168
169 class BPatch_paramExpr : public BPatch_snippet {
170 public:
171     BPatch_paramExpr(int n);
172 };
173
174 class BPatch_retExpr : public BPatch_snippet {
175 public:
176     BPatch_retExpr();
177 };
178
179 class BPatch_sequence : public BPatch_snippet {
180 public:
181     BPatch_sequence(const BPatch_Vector<BPatch_snippet *> &items);
182 };
183
184 class BPatch_variableExpr : public BPatch_snippet {
185     process     *proc;
186     void        *address;
187     int         size;
188 public:
189 // The following functions are for internal use by the library only:
190     BPatch_variableExpr(process *in_process, void *in_address,
191                         const BPatch_type *type);
192     BPatch_variableExpr(process *in_process, void *in_address,
193                         int in_size);
194
195 // Public functions for use by users of the library:
196     void readValue(void *dst);
197     void readValue(void *dst, int len);
198     void writeValue(const void *src);
199     void writeValue(const void *src, int len);
200
201     void *getBaseAddr() const { return address; }
202 };
203
204 #endif /* _BPatch_snippet_h_ */