-
Notifications
You must be signed in to change notification settings - Fork 3
/
IDSLDebugger.java
439 lines (391 loc) · 11 KB
/
IDSLDebugger.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
/*******************************************************************************
* Copyright (c) 2015, 2024 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.acceleo.debug;
import java.util.Deque;
import java.util.Map;
import org.eclipse.acceleo.debug.event.IDSLDebugEventProcessor;
import org.eclipse.acceleo.debug.util.FrameVariable;
import org.eclipse.acceleo.debug.util.StackFrame;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
/**
* The debugger.
*
* @author <a href="mailto:yvan.lussaud@obeo.fr">Yvan Lussaud</a>
*/
public interface IDSLDebugger extends IDSLDebugEventProcessor {
/**
* Stepping modes.
*
* @author <a href="mailto:yvan.lussaud@obeo.fr">Yvan Lussaud</a>
*/
enum Stepping {
/**
* Not stepping.
*/
NONE,
/**
* Stepping over.
*/
STEP_OVER,
/**
* Stepping into.
*/
STEP_INTO,
/**
* Stepping return.
*/
STEP_RETURN;
}
/**
* Initializes the debugger.
*
* @param noDebug
* <code>true</code> if no debug is needed
* @param arguments
* the {@link Map} of arguments
*/
void initialize(boolean noDebug, Map<String, Object> arguments);
/**
* Starts the debugger.
*/
void start();
/**
* Terminates the debugger.
*/
void terminate();
/**
* Suspends the debugger.
*/
void suspend();
/**
* The thread is suspended with the given state.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
*/
void suspended(Long threadID);
/**
* Resumes the debugger.
*/
void resume();
/**
* Disconnect the debugger.
*/
void disconnect();
/**
* Tells if we can step into the given the {@link EObject} representing an instruction for the given
* thread.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
* @param instruction
* the {@link EObject} representing an instruction
* @return <code>true</code> if we can step into the given instruction, <code>false</code> otherwise
*/
boolean canStepInto(Long threadID, EObject instruction);
/**
* Step into the current instruction of the given thread.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
*/
void stepInto(Long threadID);
/**
* The thread is stepping into.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
*/
void steppingInto(Long threadID);
/**
* Step over the current instruction of the given thread.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
*/
void stepOver(Long threadID);
/**
* The thread is stepping over.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
*/
void steppingOver(Long threadID);
/**
* Step return from the current stack frame of the given thread.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
*/
void stepReturn(Long threadID);
/**
* The thread is stepping return.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
*/
void steppingReturn(Long threadID);
/**
* The thread is stepped with the given state.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
*/
void stepped(Long threadID);
/**
* Resumes the given thread.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
*/
void resume(Long threadID);
/**
* The thread is resuming.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
*/
void resuming(Long threadID);
/**
* Suspends the given thread.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
*/
void suspend(Long threadID);
/**
* Terminates the given thread.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
*/
void terminate(Long threadID);
/**
* Adds the given {@link URI} pointing an {@link EObject instruction} as a break point.
*
* @param instruction
* the {@link URI} pointing an {@link EObject instruction}
*/
void addBreakPoint(URI instruction);
/**
* Removes the given {@link URI} pointing an {@link EObject instruction} as a break point.
*
* @param instruction
* {@link URI} pointing an {@link EObject instruction}
*/
void removeBreakPoint(URI instruction);
/**
* Clears all breakpoints.
*/
void clearBreakPoints();
/**
* Gets the {@link EObject instruction} for the given position.
*
* @param path
* the source path
* @param line
* the start line
* @param column
* the start column
* @return the {@link EObject instruction} for the given position
*/
EObject getInstruction(String path, long line, long column);
/**
* Gets the {@link DSLSource} for a given {@link EObject instruction}.
*
* @param instruction
* the {@link EObject instruction}
* @return the {@link DSLSource} for a given {@link EObject instruction}
*/
DSLSource getSource(EObject instruction);
/**
* Changes the given attribute value for the given break point.
*
* @param instruction
* {@link URI} pointing an {@link EObject instruction}
* @param attribute
* the attribute
* @param value
* the value
*/
void changeBreakPoint(URI instruction, String attribute, String value);
/**
* The thread suspended on a breakpoint with the given state.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
*/
void breaked(Long threadID);
/**
* Notify the debug model that our debugger is terminated.
*/
void terminated();
/**
* Method that can be called by a particular execution engine to delegate control of execution flow of the
* given thread.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
* @param instruction
* the given {@link EObject} representing an instruction, can't be <code>null</code>
* @return <code>false</code> if execution shall stop, <code>true</code> if execution shall continue
*/
boolean control(Long threadID, EObject instruction);
/**
* Spawn a running thread in the model.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
* @param threadName
* the {@link org.eclipse.acceleo.debug.Thread#getName() thread name}
* @param context
* the {@link EObject} representing the current context of the thread
*/
void spawnRunningThread(Long threadID, String threadName, EObject context);
/**
* Gets the mapping from thread {@link Thread#getThreadID() ID} to
* {@link org.eclipse.acceleo.debug.Thread#getName() thread name}.
*
* @return the mapping from thread {@link Thread#getThreadID() ID} to
* {@link org.eclipse.acceleo.debug.Thread#getName() thread name}
*/
Map<Long, String> getThreads();
/**
* Tells is the debugger is terminated.
*
* @return <code>true</code> if the debugger is terminated, <code>false</code> otherwise
*/
boolean isTerminated();
/**
* Set the debugger to terminated or not.
*
* @param terminated
* the new value
*/
void setTerminated(boolean terminated);
/**
* Tells if we should break on the given instruction.
*
* @param instruction
* the {@link EObject instruction}
* @return <code>true</code> if we should break, <code>false</code> otherwise
*/
boolean shouldBreak(EObject instruction);
/**
* Sets the value of the variable with the given name in the given thread.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
* @param stackName
* the stack frame name
* @param declarationTypeName
* the variable declaration type name
* @param variableName
* the name of the variable
* @param value
* the value
* @param supportModifications
* tells if the value can be changed
*/
void variable(Long threadID, String stackName, String declarationTypeName, String variableName,
Object value, boolean supportModifications);
/**
* Deletes the variable with the given name for the given thread.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
* @param name
* the variable name
*/
void deleteVariable(Long threadID, String name);
/**
* Gets the stack of {@link StackFrame} for the given {@link Thread#getThreadID() ID}.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
* @return the stack of {@link StackFrame} for the given {@link Thread#getThreadID() ID}
*/
Deque<StackFrame> getStackFrame(Long threadID);
/**
* The given thread is terminated.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
*/
void terminated(Long threadID);
/**
* Tells if the given thread is terminated.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
* @return <code>true</code> if the given thread is terminated, <code>false</code> otherwise
*/
boolean isTerminated(Long threadID);
/**
* Validates a variable value.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
* @param variableName
* the variable name
* @param value
* the value to validate
* @return <code>true</code> if the value is valid, <code>false</code> otherwise
*/
boolean validateVariableValue(Long threadID, String variableName, String value);
/**
* Gets the variable value after {@link IDSLDebugger#validateVariableValue(String, String, String)
* validation} returned <code>true</code>.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
* @param stackName
* the stack frame name
* @param variableName
* the variable name
* @param value
* the value to validate
* @return the variable value
*/
Object getVariableValue(Long threadID, String stackName, String variableName, String value);
/**
* Sets the variable value after {@link IDSLDebugger#validateVariableValue(String, String, String)
* validation} returned <code>true</code>.
*
* @param threadID
* the {@link Thread#getThreadID() ID}
* @param stackName
* the stack frame name
* @param variableName
* the variable name
* @param value
* the value to validate
*/
void setVariableValue(Long threadID, String stackName, String variableName, Object value);
/**
* Prints the given text to the console.
*
* @param text
* the text to print
*/
void consolePrint(String text);
/**
* Creates the {@link FrameVariable} for the given {@link Object value}.
*
* @param name
* the variable name
* @param value
* the {@link Object value}
* @return the {@link FrameVariable} for the given {@link Object value}
*/
FrameVariable getFrameVariable(String name, Object value);
}