Skip to content

Commit 784dd70

Browse files
committed
Changed hack used to enable trace serialization, until the proper solution is implemented, and made several improvement around trace loading, execution relaunching and various performance tweaks
1 parent a9debd0 commit 784dd70

File tree

32 files changed

+590
-654
lines changed

32 files changed

+590
-654
lines changed

framework/execution_framework/plugins/org.gemoc.executionframework.engine.ui/src/org/gemoc/executionframework/engine/ui/commons/RunConfiguration.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,7 @@
2626

2727
public class RunConfiguration implements IRunConfiguration {
2828

29-
// main launch parameters
30-
public static final String LAUNCH_MODEL_PATH = "GEMOC_LAUNCH_MODEL_PATH";
31-
public static final String LAUNCH_DELAY = "GEMOC_ANIMATE_DELAY";
32-
public static final String LAUNCH_SELECTED_LANGUAGE = "GEMOC_LAUNCH_SELECTED_LANGUAGE";
33-
public static final String LAUNCH_MELANGE_QUERY = "GEMOC_LAUNCH_MELANGE_QUERY";
34-
public static final String LAUNCH_MODEL_ENTRY_POINT = "LAUNCH_MODEL_ENTRY_POINT";
35-
public static final String LAUNCH_METHOD_ENTRY_POINT = "LAUNCH_METHOD_ENTRY_POINT";
36-
public static final String LAUNCH_INITIALIZATION_METHOD = "GEMOC_LAUNCH_INITIALIZATION_METHOD";
37-
public static final String LAUNCH_INITIALIZATION_ARGUMENTS = "GEMOC_LAUNCH_INITIALIZATION_ARGUMENTS";
38-
public static final String LAUNCH_BREAK_START = "GEMOC_LAUNCH_BREAK_START";
39-
40-
// parameters that should be derived from the language in future version
41-
public static final String LAUNCH_DEADLOCK_DETECTION_DEPTH = "GEMOC_LAUNCH_DEADLOCK_DETECTION_DEPTH";
29+
4230

4331
protected ILaunchConfiguration _launchConfiguration;
4432

framework/execution_framework/plugins/org.gemoc.executionframework.engine.ui/src/org/gemoc/executionframework/engine/ui/debug/AbstractGemocDebugger.java

Lines changed: 63 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,17 @@ public abstract class AbstractGemocDebugger extends AbstractDSLDebugger implemen
8585
protected final IBasicExecutionEngine engine;
8686

8787
private String bundleSymbolicName;
88-
88+
8989
private List<IMutableFieldExtractor> mutableFieldExtractors = new ArrayList<>();
9090

9191
public AbstractGemocDebugger(IDSLDebugEventProcessor target, IBasicExecutionEngine engine) {
9292
super(target);
9393
this.engine = engine;
94-
95-
// This prevents a null pointer exception if the engine does not have a Language Definition Extension.
96-
// In that case, the getLanguageDefinitionExtension() returns null
97-
// e.g., the coordination engine
94+
95+
// This prevents a null pointer exception if the engine does not have a
96+
// Language Definition Extension.
97+
// In that case, the getLanguageDefinitionExtension() returns null
98+
// e.g., the coordination engine
9899
if (engine.getExecutionContext().getLanguageDefinitionExtension() != null) {
99100
bundleSymbolicName = engine.getExecutionContext().getMelangeBundle().getSymbolicName();
100101
}
@@ -123,7 +124,7 @@ protected void registerModelChangeListener() {
123124
}
124125

125126
public void setMutableFieldExtractors(List<IMutableFieldExtractor> mutableFieldExtractors) {
126-
this.mutableFieldExtractors = mutableFieldExtractors;
127+
this.mutableFieldExtractors = mutableFieldExtractors;
127128
}
128129

129130
private Set<BiPredicate<IBasicExecutionEngine, MSEOccurrence>> predicateBreakPoints = new HashSet<BiPredicate<IBasicExecutionEngine, MSEOccurrence>>();
@@ -148,16 +149,16 @@ public void addPredicateBreak(BiPredicate<IBasicExecutionEngine, MSEOccurrence>
148149
protected boolean shouldBreakPredicates(IBasicExecutionEngine engine, MSEOccurrence mseOccurrence) {
149150

150151
// We look at predicate breaks to remove the ones that are true
151-
boolean shouldBreak2 = false;
152+
boolean shouldBreak = false;
152153
Set<BiPredicate<IBasicExecutionEngine, MSEOccurrence>> toRemove = new HashSet<BiPredicate<IBasicExecutionEngine, MSEOccurrence>>();
153154
for (BiPredicate<IBasicExecutionEngine, MSEOccurrence> pred : predicateBreaks) {
154155
if (pred.test(engine, mseOccurrence)) {
155-
shouldBreak2 = true;
156+
shouldBreak = true;
156157
toRemove.add(pred);
157158
}
158159
}
159160
predicateBreaks.removeAll(toRemove);
160-
if (shouldBreak2)
161+
if (shouldBreak)
161162
return true;
162163

163164
// If no break yet, we look at predicate breakpoints
@@ -199,7 +200,7 @@ private void initializeMutableDatas() {
199200
Resource executedResource = executedModelRoot.eResource();
200201
Set<Resource> allResources = org.gemoc.commons.eclipse.emf.EMFResource.getRelatedResources(executedResource);
201202
allResources.add(executedResource);
202-
allResources.removeIf(r->r==null);
203+
allResources.removeIf(r -> r == null);
203204

204205
// We try each extractor
205206
for (IMutableFieldExtractor extractor : mutableFieldExtractors) {
@@ -301,7 +302,7 @@ protected void updateVariables(String threadName) {
301302
String frameName = "Global context : " + executedModelRoot.eClass().getName();
302303
for (MutableField m : changed) {
303304
variable(threadName, frameName, "mutable data", m.getName(), m.getValue(), true);
304-
// m.getMutableProperty().eContainer();
305+
// m.getMutableProperty().eContainer();
305306
}
306307

307308
if (!nextSuspendMutableFields.isEmpty()) {
@@ -311,7 +312,8 @@ protected void updateVariables(String threadName) {
311312
}
312313

313314
/*
314-
* Checks if the given string can be interpreted as a valid value for the given variable.
315+
* Checks if the given string can be interpreted as a valid value for the
316+
* given variable.
315317
*/
316318
@Override
317319
public boolean validateVariableValue(String threadName, String variableName, String value) {
@@ -320,7 +322,8 @@ public boolean validateVariableValue(String threadName, String variableName, Str
320322
}
321323

322324
/*
323-
* Returns the given string interpreted as a value of the same type as the current value of the data.
325+
* Returns the given string interpreted as a value of the same type as the
326+
* current value of the data.
324327
*/
325328
private Object getValue(MutableField data, String value) {
326329
final Object res;
@@ -353,7 +356,7 @@ private Object getValue(MutableField data, String value) {
353356

354357
return res;
355358
}
356-
359+
357360
@Override
358361
public void pushStackFrame(String threadName, String frameName, EObject context, EObject instruction) {
359362
super.pushStackFrame(threadName, frameName, context, instruction);
@@ -377,7 +380,7 @@ public void setVariableValue(String threadName, String stackName, String variabl
377380
}
378381

379382
private ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
380-
383+
381384
@Override
382385
public void updateData(String threadName, EObject instruction) {
383386
if (executedModelRoot == null) {
@@ -387,8 +390,7 @@ public void updateData(String threadName, EObject instruction) {
387390
pushStackFrame(threadName, frameName, executedModelRoot, instruction);
388391

389392
for (MutableField m : mutableFields) {
390-
variable(threadName, frameName, "mutable data", m.getName(), m.getValue(),
391-
true);
393+
variable(threadName, frameName, "mutable data", m.getName(), m.getValue(), true);
392394
}
393395
} else {
394396
// Updating mutable datas
@@ -397,56 +399,62 @@ public void updateData(String threadName, EObject instruction) {
397399
updateStack(threadName, instruction);
398400
scheduleSelectLastStackframe(500);
399401
}
400-
402+
401403
protected void scheduleSelectLastStackframe(long delay) {
402-
executorService.schedule(()->selectLastStackframe(), 500, TimeUnit.MILLISECONDS);
404+
executorService.schedule(() -> selectLastStackframe(), 500, TimeUnit.MILLISECONDS);
403405
}
404-
405-
private <T> List<T> flatten(List<T> ts, Function<T,List<T>> provider) {
406+
407+
private <T> List<T> flatten(List<T> ts, Function<T, List<T>> provider) {
406408
if (ts.isEmpty()) {
407409
return ts;
408410
} else {
409411
List<T> res = new ArrayList<>();
410412
for (T t : ts) {
411-
res.addAll(flatten(provider.apply(t),provider));
413+
res.addAll(flatten(provider.apply(t), provider));
412414
res.add(t);
413415
}
414416
return res;
415417
}
416418
}
417-
419+
418420
private void selectLastStackframe() {
419421
final IWorkbench workbench = PlatformUI.getWorkbench();
420-
workbench.getDisplay().asyncExec(()->{
421-
final IWorkbenchPage workbenchPage = workbench.getActiveWorkbenchWindow().getActivePage();
422-
final IViewPart view = workbenchPage.findView("org.eclipse.debug.ui.DebugView");
423-
view.setFocus();
424-
final ISelectionProvider selectionProvider = view.getSite().getSelectionProvider();
425-
selectionProvider.setSelection(StructuredSelection.EMPTY);
426-
if (view instanceof LaunchView) {
427-
final LaunchView launchView = (LaunchView) view;
428-
final Viewer viewer = launchView.getViewer();
429-
final Tree tree = ((TreeModelViewer) viewer).getTree();
430-
final TreeItem[] items = tree.getItems();
431-
final List<TreeItem> allItems = flatten(Arrays.asList(items),t -> Arrays.asList(t.getItems()));
432-
final List<TreeItem> leafItems = allItems.stream()
433-
.filter(i->i.getData() instanceof DSLStackFrameAdapter)
434-
.filter(i->((DSLStackFrameAdapter) i.getData()).getTarget() instanceof StackFrame)
435-
.collect(Collectors.toList());
436-
for (TreeItem item : leafItems) {
437-
final DSLStackFrameAdapter stackFrameAdapter = (DSLStackFrameAdapter) item.getData();
438-
final StackFrame s = (StackFrame)stackFrameAdapter.getTarget();
439-
if (s.getName().startsWith("Global context :")) {
440-
tree.showItem(item);
441-
tree.select(item);
442-
final TreeSelection selection = (TreeSelection)viewer.getSelection();
443-
final TreePath[] paths = selection.getPathsFor(stackFrameAdapter);
444-
selectionProvider.setSelection(new TreeSelection(paths));
445-
break;
446-
}
447-
}
448-
}
449-
});
422+
workbench
423+
.getDisplay()
424+
.asyncExec(
425+
() -> {
426+
final IWorkbenchPage workbenchPage = workbench.getActiveWorkbenchWindow().getActivePage();
427+
final IViewPart view = workbenchPage.findView("org.eclipse.debug.ui.DebugView");
428+
view.setFocus();
429+
final ISelectionProvider selectionProvider = view.getSite().getSelectionProvider();
430+
selectionProvider.setSelection(StructuredSelection.EMPTY);
431+
if (view instanceof LaunchView) {
432+
final LaunchView launchView = (LaunchView) view;
433+
final Viewer viewer = launchView.getViewer();
434+
final Tree tree = ((TreeModelViewer) viewer).getTree();
435+
final TreeItem[] items = tree.getItems();
436+
final List<TreeItem> allItems = flatten(Arrays.asList(items),
437+
t -> Arrays.asList(t.getItems()));
438+
final List<TreeItem> leafItems = allItems
439+
.stream()
440+
.filter(i -> i.getData() instanceof DSLStackFrameAdapter)
441+
.filter(i -> ((DSLStackFrameAdapter) i.getData()).getTarget() instanceof StackFrame)
442+
.collect(Collectors.toList());
443+
for (TreeItem item : leafItems) {
444+
final DSLStackFrameAdapter stackFrameAdapter = (DSLStackFrameAdapter) item
445+
.getData();
446+
final StackFrame s = (StackFrame) stackFrameAdapter.getTarget();
447+
if (s.getName().startsWith("Global context :")) {
448+
tree.showItem(item);
449+
tree.select(item);
450+
final TreeSelection selection = (TreeSelection) viewer.getSelection();
451+
final TreePath[] paths = selection.getPathsFor(stackFrameAdapter);
452+
selectionProvider.setSelection(new TreeSelection(paths));
453+
break;
454+
}
455+
}
456+
}
457+
});
450458
}
451459

452460
@Override
@@ -486,10 +494,10 @@ public void logicalStepSelected(IBasicExecutionEngine engine, LogicalStep select
486494
@Override
487495
public void logicalStepExecuted(IBasicExecutionEngine engine, LogicalStep logicalStepExecuted) {
488496
}
489-
497+
490498
@Override
491499
public List<String> validate(List<IEngineAddon> otherAddons) {
492500
return new ArrayList<String>();
493501
}
494-
502+
495503
}

framework/execution_framework/plugins/org.gemoc.executionframework.engine.ui/src/org/gemoc/executionframework/engine/ui/launcher/AbstractGemocLauncher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
abstract public class AbstractGemocLauncher extends fr.obeo.dsl.debug.ide.sirius.ui.launch.AbstractDSLLaunchConfigurationDelegateUI {
1919

20-
// warning this MODEL_ID must be the same as teh one in the ModelLoader in order to enable correctly the breakpoints
20+
// warning this MODEL_ID must be the same as the one in the ModelLoader in order to enable correctly the breakpoints
2121
public final static String MODEL_ID = org.gemoc.executionframework.engine.ui.Activator.PLUGIN_ID+".debugModel";
2222

2323

framework/execution_framework/plugins/org.gemoc.executionframework.engine/src/org/gemoc/executionframework/engine/core/AbstractSequentialExecutionEngine.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,11 @@ private LogicalStep createLogicalStep(EObject caller, String className, String m
190190
MSEOccurrence occurrence = null;
191191
if (traceAddon == null) {
192192
occurrence = MseFactory.eINSTANCE.createMSEOccurrence();
193-
occurrence.setLogicalStep(logicalStep);
193+
logicalStep.getMseOccurrences().add(occurrence);
194194
occurrence.setMse(mse);
195195
} else {
196196
occurrence = traceAddon.getFactory().createMSEOccurrence(mse, new ArrayList<Object>(), new ArrayList<Object>());
197-
occurrence.setLogicalStep(logicalStep);
197+
logicalStep.getMseOccurrences().add(occurrence);
198198
}
199199
currentLogicalSteps.push(logicalStep);
200200
return logicalStep;

framework/execution_framework/plugins/org.gemoc.executionframework.ui/src/org/gemoc/executionframework/ui/views/engine/EnginesStatusView.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,15 @@ public void run() {
347347
});
348348
}
349349

350-
350+
private IBasicExecutionEngine selectedEngine = null;
351+
351352
private void fireEngineSelectionChanged() {
352353
IBasicExecutionEngine engine = getSelectedEngine();
353-
for(IEngineSelectionListener listener: Activator.getDefault().getEngineSelectionManager().getEngineSelectionListeners()) {
354-
listener.engineSelectionChanged(engine);
354+
if (engine != selectedEngine) {
355+
selectedEngine = engine;
356+
for(IEngineSelectionListener listener: Activator.getDefault().getEngineSelectionManager().getEngineSelectionListeners()) {
357+
listener.engineSelectionChanged(selectedEngine);
358+
}
355359
}
356360
}
357361

@@ -472,6 +476,6 @@ public void engineAboutToDispose(IBasicExecutionEngine engine) {
472476

473477
@Override
474478
public List<String> validate(List<IEngineAddon> otherAddons) {
475-
return new ArrayList<String>();
479+
return new ArrayList<>();
476480
}
477481
}

framework/framework_commons/plugins/org.gemoc.executionframework.engine.mse.model/model/GemocExecutionEngineMSE.ecore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
eType="ecore:EDataType ../../org.eclipse.emf.ecore/model/Ecore.ecore#//EJavaObject"/>
1010
<eStructuralFeatures xsi:type="ecore:EAttribute" name="result" upperBound="-1"
1111
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaObject"/>
12-
<eStructuralFeatures xsi:type="ecore:EReference" name="logicalStep" eType="#//LogicalStep"
13-
eOpposite="#//LogicalStep/mseOccurrences"/>
1412
</eClassifiers>
1513
<eClassifiers xsi:type="ecore:EClass" name="MSE" abstract="true" eSuperTypes="../../org.eclipse.emf.ecore/model/Ecore.ecore#//ENamedElement">
1614
<eOperations name="getCaller" eType="ecore:EClass ../../org.eclipse.emf.ecore/model/Ecore.ecore#//EObject"/>
@@ -28,6 +26,6 @@
2826
</eClassifiers>
2927
<eClassifiers xsi:type="ecore:EClass" name="LogicalStep">
3028
<eStructuralFeatures xsi:type="ecore:EReference" name="mseOccurrences" lowerBound="1"
31-
upperBound="-1" eType="#//MSEOccurrence" eOpposite="#//MSEOccurrence/logicalStep"/>
29+
upperBound="-1" eType="#//MSEOccurrence"/>
3230
</eClassifiers>
3331
</ecore:EPackage>

framework/framework_commons/plugins/org.gemoc.executionframework.engine.mse.model/src/org/gemoc/executionframework/engine/mse/GenericMSE.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
*
2121
* <p>
2222
* The following features are supported:
23+
* </p>
2324
* <ul>
2425
* <li>{@link org.gemoc.executionframework.engine.mse.GenericMSE#getCallerReference <em>Caller Reference</em>}</li>
2526
* <li>{@link org.gemoc.executionframework.engine.mse.GenericMSE#getActionReference <em>Action Reference</em>}</li>
2627
* </ul>
27-
* </p>
2828
*
2929
* @see org.gemoc.executionframework.engine.mse.MsePackage#getGenericMSE()
3030
* @model

framework/framework_commons/plugins/org.gemoc.executionframework.engine.mse.model/src/org/gemoc/executionframework/engine/mse/LogicalStep.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
*
2222
* <p>
2323
* The following features are supported:
24+
* </p>
2425
* <ul>
2526
* <li>{@link org.gemoc.executionframework.engine.mse.LogicalStep#getMseOccurrences <em>Mse Occurrences</em>}</li>
2627
* </ul>
27-
* </p>
2828
*
2929
* @see org.gemoc.executionframework.engine.mse.MsePackage#getLogicalStep()
3030
* @model
@@ -34,7 +34,6 @@ public interface LogicalStep extends EObject {
3434
/**
3535
* Returns the value of the '<em><b>Mse Occurrences</b></em>' reference list.
3636
* The list contents are of type {@link org.gemoc.executionframework.engine.mse.MSEOccurrence}.
37-
* It is bidirectional and its opposite is '{@link org.gemoc.executionframework.engine.mse.MSEOccurrence#getLogicalStep <em>Logical Step</em>}'.
3837
* <!-- begin-user-doc -->
3938
* <p>
4039
* If the meaning of the '<em>Mse Occurrences</em>' reference list isn't clear,
@@ -43,8 +42,7 @@ public interface LogicalStep extends EObject {
4342
* <!-- end-user-doc -->
4443
* @return the value of the '<em>Mse Occurrences</em>' reference list.
4544
* @see org.gemoc.executionframework.engine.mse.MsePackage#getLogicalStep_MseOccurrences()
46-
* @see org.gemoc.executionframework.engine.mse.MSEOccurrence#getLogicalStep
47-
* @model opposite="logicalStep" required="true"
45+
* @model required="true"
4846
* @generated
4947
*/
5048
EList<MSEOccurrence> getMseOccurrences();

framework/framework_commons/plugins/org.gemoc.executionframework.engine.mse.model/src/org/gemoc/executionframework/engine/mse/MSEModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
*
2222
* <p>
2323
* The following features are supported:
24+
* </p>
2425
* <ul>
2526
* <li>{@link org.gemoc.executionframework.engine.mse.MSEModel#getOwnedMSEs <em>Owned MS Es</em>}</li>
2627
* </ul>
27-
* </p>
2828
*
2929
* @see org.gemoc.executionframework.engine.mse.MsePackage#getMSEModel()
3030
* @model

0 commit comments

Comments
 (0)