Added srcObject and fork/exec/exit callbacks.
[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 #include "BPatch_sourceObj.h"
47 #include "BPatch_point.h"
48 #include "BPatch_type.h"
49 #include "BPatch_module.h"
50 #include "BPatch_function.h"
51
52 class AstNode;
53 class process;
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_addr,
80     BPatch_deref
81 } BPatch_unOp;
82
83 class BPatch_snippet {
84 public:
85 // The following members are for  internal use by the library only:
86     AstNode     *ast; /* XXX It would be better if this was protected */
87 // End members for internal use only.
88
89     BPatch_snippet() : ast(NULL) {};
90     BPatch_snippet(const BPatch_snippet &);
91     BPatch_snippet &operator=(const BPatch_snippet &);
92
93     virtual     ~BPatch_snippet();
94
95     float       getCost();
96 };
97
98 class BPatch_arithExpr: public BPatch_snippet {
99 public:
100     BPatch_arithExpr(BPatch_binOp op,
101                      const BPatch_snippet &lOperand,
102                      const BPatch_snippet &rOperand);
103     BPatch_arithExpr(BPatch_unOp op, const BPatch_snippet &lOperand);
104 };
105
106 class BPatch_boolExpr : public BPatch_snippet {
107 public:
108     BPatch_boolExpr(BPatch_relOp op, const BPatch_snippet &lOperand,
109                     const BPatch_snippet &rOperand);
110 };
111
112 class BPatch_constExpr : public BPatch_snippet {
113 public:
114     BPatch_constExpr(int value);
115 #ifdef BPATCH_NOT_YET
116     BPatch_constExpr(float value);
117 #endif
118     BPatch_constExpr(const char *value);
119 };
120
121 class BPatch_funcCallExpr : public BPatch_snippet {
122 public:
123     BPatch_funcCallExpr(const BPatch_function& func,
124                         const BPatch_Vector<BPatch_snippet *> &args);
125 };
126
127 class BPatch_funcJumpExpr : public BPatch_snippet {
128 public:
129      BPatch_funcJumpExpr(const BPatch_function& func);
130 };
131
132 class BPatch_ifExpr : public BPatch_snippet {
133 public:
134     BPatch_ifExpr(const BPatch_boolExpr &conditional,
135                   const BPatch_snippet &tClase);
136     BPatch_ifExpr(const BPatch_boolExpr &conditional,
137                   const BPatch_snippet &tClase,
138                   const BPatch_snippet &fClause);
139 };
140
141 class BPatch_nullExpr : public BPatch_snippet {
142 public:
143     BPatch_nullExpr();
144 };
145
146 class BPatch_paramExpr : public BPatch_snippet {
147 public:
148     BPatch_paramExpr(int n);
149 };
150
151 class BPatch_retExpr : public BPatch_snippet {
152 public:
153     BPatch_retExpr();
154 };
155
156 class BPatch_sequence : public BPatch_snippet {
157 public:
158     BPatch_sequence(const BPatch_Vector<BPatch_snippet *> &items);
159 };
160
161 class BPatch_variableExpr : public BPatch_snippet {
162     char                *name;
163     process             *proc;
164     void                *address;
165     int                 size;
166     BPatch_point        *scope;
167 public:
168 // The following functions are for internal use by the library only:
169     BPatch_variableExpr(char *name, process *in_process, void *in_address,
170                         const BPatch_type *type);
171     BPatch_variableExpr(process *in_process, void *in_address,
172                         const BPatch_type *type, bool frameRelative = false,
173                         BPatch_point *sc = NULL);
174     BPatch_variableExpr(process *in_process, void *in_address,
175                         int in_size);
176     BPatch_variableExpr(char *in_name, process *in_process, AstNode *_ast,
177                         const BPatch_type *type);
178
179 // Public functions for use by users of the library:
180     bool readValue(void *dst);
181     void readValue(void *dst, int len);
182     bool writeValue(const void *src);
183     void writeValue(const void *src, int len);
184
185     char *getName() { return name; }
186     void *getBaseAddr() const { return address; }
187     const BPatch_type *getType();
188     void setType(BPatch_type *);
189     void setSize(int sz) {  size = sz; }
190     BPatch_Vector<BPatch_variableExpr *> *getComponents();
191 };
192
193 class BPatch_breakPointExpr : public BPatch_snippet {
194 public:
195     BPatch_breakPointExpr();
196 };
197
198 #endif /* _BPatch_snippet_h_ */