Search in sources :

Example 1 with DebugModel

use of abs.backend.java.debugging.DebugModel in project abstools by abstools.

the class Debugger method initDebugger.

/**
 * Shuts down the previous debug process and initializes the debugger with parameters
 * for a new debug process.
 * @param useOurSystemObserver indicate if the internal debug perspective should be used
 * @param projectName
 * @param r
 * @param debuggerRunner
 */
public void initDebugger(String projectName, ABSRuntime r, Thread debuggerRunner, boolean useOurSystemObserver) {
    shutdown();
    this.projectName = projectName;
    this.runtime = r;
    if (useOurSystemObserver) {
        r.addSystemObserver(this);
    }
    model = new DebugModel();
    model.registerListener(new DebugModelListener());
    debuggerRunner.start();
    getDebugViewer().setInput(new Object[] { model });
    if (DebugUtils.getSchedulerRef() != null)
        DebugUtils.getSchedulerRef().updateScheduler();
}
Also used : DebugModel(abs.backend.java.debugging.DebugModel)

Example 2 with DebugModel

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

use of abs.backend.java.debugging.DebugModel 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

DebugModel (abs.backend.java.debugging.DebugModel)3 COGView (abs.backend.java.observing.COGView)2 TaskStackFrameView (abs.backend.java.observing.TaskStackFrameView)2 TaskView (abs.backend.java.observing.TaskView)2 Objects (org.absmodels.abs.plugin.debug.model.Objects)2 Tasks (org.absmodels.abs.plugin.debug.model.Tasks)2 MethodView (abs.backend.java.observing.MethodView)1 ObjectView (abs.backend.java.observing.ObjectView)1 TaskStackView (abs.backend.java.observing.TaskStackView)1 ArrayList (java.util.ArrayList)1 StyledString (org.eclipse.jface.viewers.StyledString)1