use of abs.backend.java.observing.TaskView in project abstools by abstools.
the class SequenceDiagramVisualization method taskResumed.
@Override
public synchronized void taskResumed(TaskView task, GuardView guard) {
if (!isObserved(task))
return;
if (guard.isFutureGuard()) {
FutView fut = guard.getFuture();
TaskView resolvingTask = fut.getResolvingTask();
if (isObserved(resolvingTask)) {
if (!waitingFutures.contains(fut) || resolvedFutures.contains(fut))
return;
resolvedFutures.add(fut);
writeOut(getActorName(resolvingTask.getTarget()));
writeOut("[" + "Task" + resolvingTask.getID() + "]");
writeOut(":>");
writeOut(getActorName(task.getTarget()));
writeOut("[" + "Taskx" + resolvingTask.getID() + "]");
writeOut(".resolved\\: ");
writeOut(shorten(String.valueOf(fut.getValue())));
writeOutLn();
writeOut(getActorName(resolvingTask.getTarget()));
writeOut("[" + "Task" + resolvingTask.getID() + "]");
writeOut(":stop");
writeOutLn();
writeOut(getActorName(task.getTarget()));
writeOut("[" + "Taskx" + resolvingTask.getID() + "]");
writeOut(":stop");
writeOutLn();
writeOutLn("(" + fut.getID() + ") " + getActorName(task.getTarget()));
}
}
}
use of abs.backend.java.observing.TaskView in project abstools by abstools.
the class SchedulingTest method testStepOverScheduler.
@Test
public void testStepOverScheduler() {
final SchedulingStrategy ss = mock(SchedulingStrategy.class);
doCallRealMethod().when(ss).setBaseScheduler(any(TotalScheduler.class));
doCallRealMethod().when(ss).setCurrentScheduler(any(TotalScheduler.class));
doCallRealMethod().when(ss).doSingleStep();
TotalScheduler ts = mock(TotalScheduler.class);
ScheduleAction scheduleAction = mock(ScheduleAction.class, Mockito.RETURNS_DEEP_STUBS);
when(ts.choose(any(ScheduleOptions.class))).thenReturn(scheduleAction);
TaskInfo taskInfo = mock(TaskInfo.class);
when(ts.schedule(any(TaskScheduler.class), any(List.class))).thenReturn(taskInfo);
ss.setBaseScheduler(ts);
TaskStackFrameView tsfv = mock(TaskStackFrameView.class);
StepOverScheduler sos = new StepOverScheduler(ss, tsfv);
ss.setCurrentScheduler(sos);
ScheduleOptions scheduleOptions = mock(ScheduleOptions.class, Mockito.RETURNS_DEEP_STUBS);
ss.curScheduler.choose(scheduleOptions);
verify(ts).reset();
verify(ts).choose(any(ScheduleOptions.class));
abs.backend.java.debugging.TaskInfo ti = mock(abs.backend.java.debugging.TaskInfo.class);
TaskView tv = mock(TaskView.class);
TaskStackView tsv = mock(TaskStackView.class);
when(tsv.hasFrames()).thenReturn(true);
TaskStackFrameView testStackFrame = mock(TaskStackFrameView.class);
OngoingStubbing<TaskStackFrameView> ongoingStubbing = when(tsv.getCurrentFrame()).thenReturn(testStackFrame);
for (int i = 0; i < 9; i++) {
testStackFrame = mock(TaskStackFrameView.class);
ongoingStubbing = ongoingStubbing.thenReturn(testStackFrame);
}
ongoingStubbing.thenReturn(tsfv);
when(tv.getStack()).thenReturn(tsv);
when(ti.getTaskView()).thenReturn(tv);
ss.steppedTask = ti;
for (int i = 0; i < 10; i++) {
ss.curScheduler.choose(scheduleOptions);
}
assertEquals(sos, ss.curScheduler);
verify(ss, never()).awaitGUIAction(any(ScheduleOptions.class));
ss.curScheduler.choose(scheduleOptions);
verify(ss).awaitGUIAction(any(ScheduleOptions.class));
}
use of abs.backend.java.observing.TaskView in project abstools by abstools.
the class DebugUtils method refreshButtonEnablement.
/**
* Disables ExecuteNSteps, resume and terminate buttons. Enables saveHistory button. Checks, if an action exists for
* the currently in the debug tree selected element and sets enablement of singleStep button accordingly.
*/
public static void refreshButtonEnablement() {
if (terminate == null) {
return;
}
terminate.setEnabled(isDebuggerRunning());
schedulerMenu.setEnabled(isDebuggerRunning());
saveHistory.setEnabled(true);
// Set enablement for step buttons explicitly
setStepButtonEnablement(false);
List<TaskView> schedulableTasks;
switch(scheduler) {
case interactive:
Object selectedObject = getDebugViewerSelection();
schedulableTasks = getSchedulerRef().getSchedulableTasks();
if (selectedObject instanceof TaskView) {
if (schedulableTasks != null) {
for (TaskView taskView : schedulableTasks) {
if (taskView == selectedObject) {
setStepButtonEnablement(true);
}
}
}
} else if (selectedObject instanceof TaskStackFrameView) {
if (schedulableTasks != null) {
for (TaskView taskView : schedulableTasks) {
if (taskView == ((TaskStackFrameView) selectedObject).getStack().getTask()) {
setStepButtonEnablement(true);
}
}
}
}
break;
case random:
case replay:
schedulableTasks = getSchedulerRef().getSchedulableTasks();
if (schedulableTasks != null && !schedulableTasks.isEmpty()) {
setStepButtonEnablement(true);
}
break;
default:
// disable all buttons
setStepButtonEnablement(false);
terminate.setEnabled(false);
saveHistory.setEnabled(false);
}
}
use of abs.backend.java.observing.TaskView in project abstools by abstools.
the class SchedulingStrategy method choose.
@Override
public ScheduleAction choose(ScheduleOptions options) {
synchronized (this) {
scheduleActions = options.allOptions();
schedulableTasks = new ArrayList<TaskView>();
for (ScheduleAction a : scheduleActions) {
if (a.getTask() != null) {
schedulableTasks.add(a.getTask());
} else {
schedulableTasks.addAll(a.getCOG().getView().getScheduler().getSchedulableTasks());
}
}
}
if (highlightStep) {
highlightNextStep();
}
ScheduleAction a = curScheduler.choose(options);
// is null when the system was terminated
if (a != null) {
logAction(a);
history.chosenAction(a);
}
return a;
}
use of abs.backend.java.observing.TaskView in project abstools by abstools.
the class DebugTreeContentProvider method getChildren.
@Override
public Object[] getChildren(Object parentElement) {
DebugModel model = getDebugger().getModel();
if (model != null && parentElement != null) {
if (parentElement instanceof DebugModel) {
List<COGView> cogs = ((DebugModel) parentElement).getCOGs();
Collections.sort(cogs, new COGViewComparator());
return cogs.toArray();
} else if (parentElement instanceof COGView) {
COGView cog = (COGView) parentElement;
Tasks t = getDebugger().getTasks(cog);
Objects o = getDebugger().getObjects(cog);
return new Object[] { t, o };
} else if (parentElement instanceof Tasks) {
return model.getTasks(((Tasks) parentElement).getCOG()).toArray();
} else if (parentElement instanceof Objects) {
return ((Objects) parentElement).getObjects().toArray();
} else if (parentElement instanceof TaskView) {
TaskView t = (TaskView) parentElement;
TaskStackView s = t.getStack();
ArrayList<TaskStackFrameView> list = new ArrayList<TaskStackFrameView>(s.getFrames());
Collections.reverse(list);
return list.toArray();
}
}
return EMPTY_OBJECT_ARRAY;
}
Aggregations