author | ryall |
Tue, 12 Jan 2010 07:49:28 -0600 | |
changeset 129 | 723898599d35 |
parent 105 | fbceb3d6fb44 |
permissions | -rw-r--r-- |
37 | 1 |
/******************************************************************************* |
2 |
* Copyright (c) 2006, 2008 Wind River Systems and others. |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* Wind River Systems - initial API and implementation |
|
10 |
* Ericsson - Update for GDB/MI |
|
11 |
*******************************************************************************/ |
|
12 |
package org.eclipse.cdt.dsf.debug.service; |
|
13 |
||
129
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
14 |
import java.math.BigInteger; |
37 | 15 |
import java.util.Map; |
16 |
||
129
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
17 |
import org.eclipse.cdt.core.IAddress; |
37 | 18 |
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; |
19 |
import org.eclipse.cdt.dsf.concurrent.RequestMonitor; |
|
20 |
import org.eclipse.cdt.dsf.datamodel.IDMContext; |
|
21 |
import org.eclipse.cdt.dsf.datamodel.IDMData; |
|
22 |
import org.eclipse.cdt.dsf.datamodel.IDMEvent; |
|
23 |
||
24 |
/** |
|
25 |
* Expressions service provides access to the debugger's expression evaluator. This service has |
|
26 |
* dependencies on the Stack service, as it is be used to provide context for an |
|
27 |
* expression to be evaluated. |
|
28 |
* |
|
29 |
* @since 1.0 |
|
30 |
*/ |
|
31 |
@SuppressWarnings("nls") |
|
32 |
public interface IExpressions extends IFormattedValues { |
|
33 |
||
34 |
/** |
|
35 |
* Expression context. |
|
36 |
*/ |
|
37 |
public interface IExpressionDMContext extends IFormattedDataDMContext { |
|
38 |
/** |
|
39 |
* Returns a fully qualified expression string represented by this context. This |
|
40 |
* expression string is the same as the string that is sent to the debug engine to be |
|
41 |
* evaluated in context of a stack frame, thread, or a symbol context. |
|
42 |
*/ |
|
43 |
String getExpression(); |
|
44 |
} |
|
129
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
45 |
|
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
46 |
|
37 | 47 |
/** |
48 |
* The address and size of an expression. |
|
49 |
*/ |
|
50 |
public interface IExpressionDMAddress { |
|
129
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
51 |
|
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
52 |
/** |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
53 |
* Returns the address of the expression. |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
54 |
*/ |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
55 |
IAddress getAddress(); |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
56 |
|
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
57 |
/** |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
58 |
* Returns the size of the address. |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
59 |
*/ |
37 | 60 |
int getSize(); |
61 |
} |
|
129
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
62 |
|
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
63 |
/** |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
64 |
* A representation of an expression location that does not correspond to |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
65 |
* an address. |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
66 |
* |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
67 |
* @since 2.1 |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
68 |
*/ |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
69 |
public interface IExpressionDMLocation extends IExpressionDMAddress { |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
70 |
|
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
71 |
/** |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
72 |
* A constant that can be returned by {@link IExpressionDMAddress#getAddress()} |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
73 |
* to represent an invalid address. Implementations of |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
74 |
* <code>IExpressionDMLocation</code> can return this constant if no |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
75 |
* valid address can be returned for a given expression location. |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
76 |
*/ |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
77 |
public static final IAddress INVALID_ADDRESS = new IAddress() { |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
78 |
public IAddress add(BigInteger offset) { return this; } |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
79 |
public IAddress add(long offset) { return this; } |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
80 |
public BigInteger getMaxOffset() { return BigInteger.ZERO; } |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
81 |
public BigInteger distanceTo(IAddress other) { return BigInteger.ZERO; } |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
82 |
public BigInteger getValue() { return BigInteger.ZERO; } |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
83 |
public boolean isZero() { return false; } |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
84 |
public boolean isMax() { return false; } |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
85 |
public String toString(int radix) { return "INVALID"; } |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
86 |
public String toHexAddressString() { return toString(); } |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
87 |
public String toBinaryAddressString() { return toString(); } |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
88 |
public int getCharsNum() { return 0; } |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
89 |
public int getSize() { return 0; } |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
90 |
public int compareTo(Object o) { return 0; } |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
91 |
}; |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
92 |
|
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
93 |
/** |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
94 |
* Returns a string representation of the expression location. |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
95 |
*/ |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
96 |
public String getLocation(); |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
97 |
} |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
98 |
|
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
99 |
|
37 | 100 |
|
101 |
/** |
|
102 |
* This is the model data interface that corresponds to IExpressionDMContext. |
|
103 |
*/ |
|
104 |
public interface IExpressionDMData extends IDMData { |
|
105 |
// These static fields define the possible return values of method getTypeId(). |
|
106 |
||
107 |
final static String TYPEID_UNKNOWN = "TYPEID_UNKNOWN"; |
|
108 |
final static String TYPEID_INTEGER = "TYPEID_INTEGER"; |
|
109 |
final static String TYPEID_CHAR = "TYPEID_CHAR"; |
|
110 |
final static String TYPEID_FLOAT = "TYPEID_FLOAT"; |
|
111 |
final static String TYPEID_DOUBLE = "TYPEID_DOUBLE"; |
|
112 |
final static String TYPEID_OPAQUE = "TYPEID_OPAQUE"; |
|
113 |
||
114 |
/** |
|
115 |
* This enumerates the possible basic types that an expression can have. |
|
116 |
* |
|
117 |
* @see getBasicType(). |
|
118 |
*/ |
|
119 |
enum BasicType { |
|
120 |
unknown, // Unknown type. |
|
121 |
basic, // Scalar type (e.g., int, short, float). |
|
122 |
pointer, // Pointer to anything. |
|
123 |
array, // Array of anything. |
|
124 |
composite, // Struct, union, or class. |
|
125 |
enumeration, // Enumeration. |
|
126 |
function // Function. |
|
127 |
} |
|
128 |
||
129 |
/** |
|
130 |
* If this expression is a sub-expression of another expression, this method returns |
|
131 |
* the expression relative to the parent of this expression. Otherwise this method |
|
132 |
* will return the same string as {@link #getExpression()}. |
|
133 |
*/ |
|
134 |
String getName(); |
|
135 |
||
136 |
/** |
|
137 |
* @return A BasicType enumerator describing the basic type of an expression. |
|
138 |
*/ |
|
139 |
BasicType getBasicType(); |
|
140 |
||
141 |
/** |
|
142 |
* @return The source code type of this expression. This is a string such as "struct Foo", "short", |
|
143 |
* "int *", "mytypedef", "(int *)[]", "enum Bar". If the debugger backend cannot supply |
|
144 |
* this information, this method returns "<UNKNOWN>" (the angle brackets are there just in |
|
145 |
* case there is a type named "UNKNOWN" in the application). |
|
146 |
*/ |
|
147 |
String getTypeName(); |
|
148 |
||
149 |
/** |
|
150 |
* This method needs to be defined. For now, this returns the empty string. |
|
151 |
*/ |
|
152 |
String getEncoding(); |
|
153 |
||
154 |
/** |
|
155 |
* @return One of the TYPEID_* static field values defined by this interface. |
|
156 |
*/ |
|
157 |
String getTypeId(); |
|
158 |
||
159 |
/** |
|
160 |
* @return A Map in which the keys are strings that are the names of enumerators in the enumeration |
|
161 |
* that is the value of this expression and the values are the integer values of the |
|
162 |
* enumerators. If the expression type is not an enumeration, this returns an empty Map. |
|
163 |
*/ |
|
164 |
Map<String, Integer> getEnumerations(); |
|
165 |
||
166 |
/** |
|
167 |
* This method needs to be defined. |
|
168 |
*/ |
|
169 |
IRegisters.IRegisterDMContext getRegister(); |
|
170 |
} |
|
171 |
||
172 |
/** |
|
173 |
* Event indicating that a given expression is changed. If an expression is changed, it's implied that all |
|
174 |
* the children of that expression are changed too. |
|
175 |
*/ |
|
176 |
public interface IExpressionChangedDMEvent extends IDMEvent<IExpressionDMContext> {} |
|
177 |
||
178 |
/** |
|
179 |
* Retrieves the expression DM data object for the given expression context(<tt>dmc</tt>). |
|
180 |
* |
|
181 |
* @param dmc |
|
182 |
* The ExpressionDMC for the expression to be evaluated. |
|
183 |
* @param rm |
|
184 |
* The data request monitor that will contain the requested data |
|
185 |
*/ |
|
186 |
void getExpressionData(IExpressionDMContext dmc, DataRequestMonitor<IExpressionDMData> rm); |
|
187 |
||
188 |
/** |
|
189 |
* Retrieves the address and size of an expression given by the expression context(<tt>dmc</tt>). |
|
190 |
* Non-lvalues do not have an addresses (e.g., "x + 5"). When the expression |
|
129
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
191 |
- * has no address, the request monitor will have an error with code |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
192 |
* <code>IDsfStatusConstants.REQUEST_FAILED</code> and the data request |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
193 |
* monitor will contain null. |
37 | 194 |
* |
195 |
* @param dmc |
|
196 |
* The ExpressionDMC for the expression |
|
197 |
* @param rm |
|
198 |
* The data request monitor that will contain the requested data |
|
199 |
*/ |
|
200 |
void getExpressionAddressData(IExpressionDMContext dmc, DataRequestMonitor<IExpressionDMAddress> rm); |
|
201 |
||
202 |
/** |
|
203 |
* Returns the data model context object for the specified expression in the context |
|
204 |
* specified by <b>ctx</b>. |
|
205 |
* |
|
206 |
* @param ctx: Context in which to evaluate the expression. This context could include the |
|
207 |
* PC location, stack frame, thread, or just a symbol context. |
|
208 |
* |
|
209 |
* @param expression: The expression to evaluate. |
|
210 |
* |
|
129
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
211 |
* @return An expression data model context object that must be passed to the appropriate |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
212 |
* data retrieval routine to obtain the value of the expression. |
37 | 213 |
*/ |
214 |
IExpressionDMContext createExpression(IDMContext ctx, String expression); |
|
215 |
||
216 |
/** |
|
217 |
* Retrieves the sub-expressions of the given expression. Sub-expressions are fields of a struct, union, |
|
218 |
* or class, the enumerators of an enumeration, and the element of an array. |
|
129
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
219 |
* <br> |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
220 |
* Note: Clients may call this method on any valid expression context, and before calling any other |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
221 |
* method to evaluate the expression value. It is up to the implementation to internally evaluate the |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
222 |
* expression if needed, in order to calculate sub expressions. |
37 | 223 |
* |
224 |
* @param exprCtx: The data model context representing an expression. |
|
225 |
* |
|
226 |
* @param rm: Request completion monitor containing an array of all sub-expressions |
|
227 |
*/ |
|
228 |
void getSubExpressions(IExpressionDMContext exprCtx, DataRequestMonitor<IExpressionDMContext[]> rm); |
|
229 |
||
230 |
/** |
|
231 |
* Retrieves a particular range of sub-expressions of the given expression. |
|
232 |
* Sub-expressions are fields of a struct, union, or class, the enumerators |
|
233 |
* of an enumeration, and the element of an array. |
|
129
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
234 |
* <br> |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
235 |
* Note: Clients may call this method on any valid expression context, and before calling any other |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
236 |
* method to evaluate the expression value. It is up to the implementation to internally evaluate the |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
237 |
* expression if needed, in order to calculate sub expressions. |
37 | 238 |
* |
239 |
* @param exprCtx: The data model context representing an expression. |
|
240 |
* startIndex: Index of the first sub-expression to retrieve |
|
241 |
* length: Total number of sub-expressions to retrieve |
|
242 |
* |
|
243 |
* @param rm: Request completion monitor containing an array of the requested |
|
244 |
* range of sub-expressions |
|
245 |
*/ |
|
246 |
void getSubExpressions(IExpressionDMContext exprCtx, int startIndex, int length, |
|
247 |
DataRequestMonitor<IExpressionDMContext[]> rm); |
|
248 |
||
249 |
/** |
|
250 |
* Retrieves the number of sub-expressions of the given expression. Sub-expressions are fields of a struct, union, |
|
251 |
* or class, the enumerators of an enumeration, and the element of an array. |
|
129
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
252 |
* <br> |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
253 |
* Note: Clients may call this method on any valid expression context, and before calling any other |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
254 |
* method to evaluate the expression value. It is up to the implementation to internally evaluate the |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
255 |
* expression if needed, in order to calculate sub expressions. |
37 | 256 |
* |
257 |
* @param exprCtx: The data model context representing an expression. |
|
258 |
* |
|
259 |
* @param rm: Request completion monitor containing the number of sub-expressions |
|
260 |
* of the specified expression |
|
261 |
*/ |
|
262 |
void getSubExpressionCount(IExpressionDMContext exprCtx, DataRequestMonitor<Integer> rm); |
|
263 |
||
264 |
/** |
|
265 |
* For object oriented languages, this method returns the expressions representing base types of |
|
266 |
* the given expression type. |
|
129
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
267 |
* <br> |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
268 |
* Note: Clients may call this method on any valid expression context, and before calling any other |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
269 |
* method to evaluate the expression value. It is up to the implementation to internally evaluate the |
723898599d35
Bug 299167, turn the Variable View's Address column into a Location column.
ryall
parents:
105
diff
changeset
|
270 |
* expression if needed, in order to calculate sub expressions. |
37 | 271 |
* |
272 |
* @param exprContext: The data model context representing an expression. |
|
273 |
* |
|
274 |
* @param rm: Request completion monitor. |
|
275 |
*/ |
|
276 |
void getBaseExpressions(IExpressionDMContext exprContext, DataRequestMonitor<IExpressionDMContext[]> rm); |
|
277 |
||
278 |
/** |
|
279 |
* This method indicates if an expression can be written to. |
|
280 |
* |
|
281 |
* @param expressionContext: The data model context representing an expression. |
|
282 |
* |
|
283 |
* @param rm: Data Request monitor containing True if this expression's value can be edited. False otherwise. |
|
284 |
*/ |
|
285 |
void canWriteExpression(IExpressionDMContext expressionContext, DataRequestMonitor<Boolean> rm); |
|
286 |
||
287 |
/** |
|
288 |
* This method supports the writing/modifying the value of the expression. |
|
289 |
* |
|
290 |
* @param expressionContext: The data model context representing an expression. |
|
291 |
* |
|
292 |
* @param expressionValue: The new value of the expression as a String. |
|
293 |
* |
|
294 |
* @param formatId: The format ID specifying the format of parameter <b>expressionValue</b>. |
|
295 |
* |
|
296 |
* @param rm: Request completion monitor. |
|
297 |
*/ |
|
298 |
void writeExpression(IExpressionDMContext expressionContext, String expressionValue, String formatId, RequestMonitor rm); |
|
299 |
} |