Search in sources :

Example 1 with TaskStackFrameView

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

the class TestModel method testStarted.

public void testStarted(TaskView task) {
    final String testMethod;
    final String className;
    final List<ABSValue> testMethodArguments;
    final LinkedList<ABSValue> arguments = new LinkedList<>();
    if (task.getStack().hasFrames()) {
        final TaskStackFrameView currentF = task.getStack().getCurrentFrame();
        testMethod = currentF.getMethod().getName();
        className = currentF.getMethod().getClassView().getName();
        for (String parameterName : currentF.getVariableNames()) {
            arguments.add(currentF.getValue(parameterName));
        }
    } else {
        testMethod = task.getMethodName();
        className = task.getTarget().getClassName();
        arguments.addAll(task.getArgs());
    }
    if (!task.getStack().hasFrames()) {
        System.out.println("Not yet started " + testMethod + " for task " + task.getID());
    } else {
        System.out.println("Test " + task.getStack().getCurrentFrame().getMethod() + " task: " + task.getID());
    }
    final TestStatus newTest = new TestStatus(task.getID(), testMethod, className, arguments, task.getStack().getFrames(), TestStatus.Status.ACTIVE);
    push(newTest);
    System.out.println("Test started: " + task.getMethodName() + " : " + testMethod);
    informListenersTestStarted(newTest);
}
Also used : ABSValue(abs.backend.java.lib.types.ABSValue) TaskStackFrameView(abs.backend.java.observing.TaskStackFrameView) LinkedList(java.util.LinkedList)

Example 2 with TaskStackFrameView

use of abs.backend.java.observing.TaskStackFrameView 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 3 with TaskStackFrameView

use of abs.backend.java.observing.TaskStackFrameView 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);
    }
}
Also used : TaskView(abs.backend.java.observing.TaskView) TaskStackFrameView(abs.backend.java.observing.TaskStackFrameView)

Example 4 with TaskStackFrameView

use of abs.backend.java.observing.TaskStackFrameView 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)

Example 5 with TaskStackFrameView

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

the class DebugTreeStyledLabelProvider method getLabel.

private StyledString getLabel(Object element) {
    if (element instanceof TaskView) {
        String s = "Task " + ((TaskView) element).getID() + " (" + ((TaskView) element).getMethodName() + ")";
        List<TaskView> schedulableTasks = getSchedulerRef().getSchedulableTasks();
        if (schedulableTasks != null) {
            for (TaskView taskView : schedulableTasks) {
                if (taskView.getID() == ((TaskView) element).getID()) {
                    return new StyledString(s, STYLER_BLACK);
                }
            }
        }
        return new StyledString(s, STYLER_GREY);
    } else if (element instanceof COGView) {
        COGView cog = (COGView) element;
        String s = "COG " + cog.getID() + " (" + getInitialObject(cog).getClassName() + " " + getInitialObject(cog).getID() + ")";
        // for color of the string, check if there is a task that can be stepped
        if (cog.getScheduler().getSchedulableTasks().size() > 0) {
            return new StyledString(s, STYLER_BLACK);
        } else {
            return new StyledString(s, STYLER_GREY);
        }
    } else if (element instanceof Tasks) {
        String s = "Tasks (" + getCOGInfo(((Tasks) element).getCOG()).getTasks().size() + ")";
        // for color of the string, check if there is a task that can be stepped
        if (((Tasks) element).getCOG().getScheduler().getSchedulableTasks().size() > 0) {
            return new StyledString(s, STYLER_BLACK);
        } else {
            return new StyledString(s, STYLER_GREY);
        }
    } else if (element instanceof Objects) {
        return new StyledString("Objects (" + ((Objects) element).getObjects().size() + ")", STYLER_BLACK);
    } else if (element instanceof TaskStackFrameView) {
        TaskStackFrameView tsv = ((TaskStackFrameView) element);
        MethodView mv = tsv.getMethod();
        return new StyledString("StackFrame (" + mv.toString() + ")", STYLER_BLACK);
    } else if (element instanceof ObjectView) {
        ObjectView obj = (ObjectView) element;
        return new StyledString(obj.getClassName() + " " + obj.getID(), STYLER_BLACK);
    } else if (element instanceof DebugModel) {
        return new StyledString(getDebugger().getProjectName(), STYLER_BLACK);
    } else {
        return new StyledString("UnknownObject", STYLER_GREY);
    }
}
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) Objects(org.absmodels.abs.plugin.debug.model.Objects) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) TaskStackFrameView(abs.backend.java.observing.TaskStackFrameView) MethodView(abs.backend.java.observing.MethodView) ObjectView(abs.backend.java.observing.ObjectView)

Aggregations

TaskStackFrameView (abs.backend.java.observing.TaskStackFrameView)7 TaskView (abs.backend.java.observing.TaskView)5 ObjectView (abs.backend.java.observing.ObjectView)3 ArrayList (java.util.ArrayList)3 DebugModel (abs.backend.java.debugging.DebugModel)2 COGView (abs.backend.java.observing.COGView)2 TaskStackView (abs.backend.java.observing.TaskStackView)2 Objects (org.absmodels.abs.plugin.debug.model.Objects)2 Tasks (org.absmodels.abs.plugin.debug.model.Tasks)2 TaskInfo (abs.backend.java.debugging.TaskInfo)1 ABSObject (abs.backend.java.lib.runtime.ABSObject)1 ABSValue (abs.backend.java.lib.types.ABSValue)1 MethodView (abs.backend.java.observing.MethodView)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 LinkedList (java.util.LinkedList)1 List (java.util.List)1 VariableValuePair (org.absmodels.abs.plugin.debug.model.VariableValuePair)1