Search in sources :

Example 1 with TaskStackView

use of abs.backend.java.observing.TaskStackView in project abstools by abstools.

the class SchedulingStrategy method doStepOver.

/**
 * Gets called when the user selects to do a step over
 */
public synchronized void doStepOver() {
    if (steppedTask != null) {
        TaskStackView stack = steppedTask.getTaskView().getStack();
        if (stack.hasFrames()) {
            disableHighlighting();
            setCurrentScheduler(new StepOverScheduler(this, stack.getCurrentFrame()));
        } else {
            doSingleStep();
        }
    } else {
        doSingleStep();
    }
}
Also used : TaskStackView(abs.backend.java.observing.TaskStackView)

Example 2 with TaskStackView

use of abs.backend.java.observing.TaskStackView in project abstools by abstools.

the class StepOverScheduler method choose.

@Override
public ScheduleAction choose(ScheduleOptions options) {
    if (firstStep) {
        firstStep = false;
        schedulingStrategy.baseScheduler.reset();
        return schedulingStrategy.baseScheduler.choose(options);
    } else {
        TaskStackView stack = schedulingStrategy.steppedTask.getTaskView().getStack();
        if (stack.hasFrames() && stack.getCurrentFrame().equals(frame)) {
            return schedulingStrategy.awaitGUIAction(options);
        } else {
            schedulingStrategy.baseScheduler.reset();
            return schedulingStrategy.baseScheduler.choose(options);
        }
    }
}
Also used : TaskStackView(abs.backend.java.observing.TaskStackView)

Example 3 with TaskStackView

use of abs.backend.java.observing.TaskStackView 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));
}
Also used : TotalScheduler(org.absmodels.abs.plugin.debug.scheduling.TotalScheduler) TaskView(abs.backend.java.observing.TaskView) TaskStackView(abs.backend.java.observing.TaskStackView) TaskScheduler(abs.backend.java.scheduling.TaskScheduler) TaskStackFrameView(abs.backend.java.observing.TaskStackFrameView) TaskInfo(abs.backend.java.scheduling.SimpleTaskScheduler.TaskInfo) SchedulingStrategy(org.absmodels.abs.plugin.debug.scheduling.SchedulingStrategy) ScheduleOptions(abs.backend.java.scheduling.ScheduleOptions) ScheduleAction(abs.backend.java.scheduling.ScheduleAction) StepOverScheduler(org.absmodels.abs.plugin.debug.scheduling.StepOverScheduler) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 4 with TaskStackView

use of abs.backend.java.observing.TaskStackView 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;
}
Also used : COGView(abs.backend.java.observing.COGView) TaskView(abs.backend.java.observing.TaskView) Tasks(org.absmodels.abs.plugin.debug.model.Tasks) DebugModel(abs.backend.java.debugging.DebugModel) TaskStackView(abs.backend.java.observing.TaskStackView) Objects(org.absmodels.abs.plugin.debug.model.Objects) ArrayList(java.util.ArrayList) TaskStackFrameView(abs.backend.java.observing.TaskStackFrameView)

Aggregations

TaskStackView (abs.backend.java.observing.TaskStackView)4 TaskStackFrameView (abs.backend.java.observing.TaskStackFrameView)2 TaskView (abs.backend.java.observing.TaskView)2 ArrayList (java.util.ArrayList)2 DebugModel (abs.backend.java.debugging.DebugModel)1 COGView (abs.backend.java.observing.COGView)1 ScheduleAction (abs.backend.java.scheduling.ScheduleAction)1 ScheduleOptions (abs.backend.java.scheduling.ScheduleOptions)1 TaskInfo (abs.backend.java.scheduling.SimpleTaskScheduler.TaskInfo)1 TaskScheduler (abs.backend.java.scheduling.TaskScheduler)1 List (java.util.List)1 Objects (org.absmodels.abs.plugin.debug.model.Objects)1 Tasks (org.absmodels.abs.plugin.debug.model.Tasks)1 SchedulingStrategy (org.absmodels.abs.plugin.debug.scheduling.SchedulingStrategy)1 StepOverScheduler (org.absmodels.abs.plugin.debug.scheduling.StepOverScheduler)1 TotalScheduler (org.absmodels.abs.plugin.debug.scheduling.TotalScheduler)1 Test (org.junit.Test)1