Search in sources :

Example 1 with IStackFrame

use of org.eclipse.debug.core.model.IStackFrame in project erlide_eclipse by erlang.

the class ErlangProcess method getBreakpoints.

@Override
public IBreakpoint[] getBreakpoints() {
    IStackFrame top = null;
    try {
        top = getTopStackFrame();
    } catch (final DebugException e1) {
    // can never happen
    }
    if (top instanceof ErlangStackFrame) {
        final ErlangStackFrame topFrame = (ErlangStackFrame) top;
        final IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
        final IBreakpoint[] breakpoints = breakpointManager.getBreakpoints();
        for (final IBreakpoint breakpoint : breakpoints) {
            if (breakpoint instanceof ErlangLineBreakpoint) {
                final ErlangLineBreakpoint lineBreakpoint = (ErlangLineBreakpoint) breakpoint;
                try {
                    if (lineBreakpoint.getModule().equals(topFrame.getModule()) && lineBreakpoint.getLineNumber() == topFrame.getLineNumber()) {
                        return new IBreakpoint[] { lineBreakpoint };
                    }
                } catch (final DebugException e) {
                    ErlLogger.warn(e);
                } catch (final CoreException e) {
                    ErlLogger.warn(e);
                }
            }
        }
    }
    return new IBreakpoint[0];
}
Also used : ErlangLineBreakpoint(org.erlide.backend.debug.ErlangLineBreakpoint) IStackFrame(org.eclipse.debug.core.model.IStackFrame) CoreException(org.eclipse.core.runtime.CoreException) IBreakpointManager(org.eclipse.debug.core.IBreakpointManager) DebugException(org.eclipse.debug.core.DebugException) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint)

Example 2 with IStackFrame

use of org.eclipse.debug.core.model.IStackFrame in project erlide_eclipse by erlang.

the class DebugTraceEvent method getStackFrames.

public List<IStackFrame> getStackFrames(final IDebugTarget target, final IThread process) {
    // XXX JC copy paste
    final OtpErlangTuple tuple = getTuple();
    final OtpErlangList erlStackFrames = (OtpErlangList) tuple.elementAt(2);
    final OtpErlangTuple t2 = (OtpErlangTuple) tuple.elementAt(1);
    final OtpErlangTuple ieval = (OtpErlangTuple) t2.elementAt(0);
    OtpErlangAtom m = (OtpErlangAtom) ieval.elementAt(3);
    OtpErlangList bindings = (OtpErlangList) t2.elementAt(t2.arity() - 1);
    OtpErlangLong l = (OtpErlangLong) ieval.elementAt(1);
    final List<IStackFrame> stackFrames = new ArrayList<>(erlStackFrames.arity() + 1);
    for (final OtpErlangObject o : erlStackFrames) {
        final OtpErlangTuple t = (OtpErlangTuple) o;
        final OtpErlangTuple ml = (OtpErlangTuple) t.elementAt(1);
        final OtpErlangObject ml0 = ml.elementAt(0);
        int stackFrameNo;
        final OtpErlangLong n = (OtpErlangLong) t.elementAt(3);
        try {
            stackFrameNo = n.intValue();
        } catch (final OtpErlangRangeException e) {
            stackFrameNo = -1;
        }
        final String module = m.atomValue();
        int line;
        try {
            line = l.intValue();
        } catch (final OtpErlangRangeException e) {
            line = -1;
        }
        final IStackFrame sf = new ErlangStackFrame(module, (ErlangProcess) process, target, line, null, bindings, stackFrameNo);
        stackFrames.add(sf);
        bindings = (OtpErlangList) t.elementAt(2);
        m = (OtpErlangAtom) ml0;
        l = (OtpErlangLong) ml.elementAt(1);
    }
    return stackFrames;
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) IStackFrame(org.eclipse.debug.core.model.IStackFrame) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) ArrayList(java.util.ArrayList) ErlangStackFrame(org.erlide.backend.debug.model.ErlangStackFrame) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 3 with IStackFrame

use of org.eclipse.debug.core.model.IStackFrame in project webtools.sourceediting by eclipse.

the class JAXPJavaLaunchConfigurationDelegate method launch.

@Override
public synchronized void launch(ILaunchConfiguration configuration, final String mode, final ILaunch launch, IProgressMonitor monitor) throws CoreException {
    this.mode = mode;
    launchHelper.save(getLaunchConfigFile());
    // set the launch name
    IProcessorInstall install = getProcessorInstall(configuration, mode);
    String tfactory = getTransformerFactory(install);
    String name = install.getName();
    if (tfactory != null)
        // $NON-NLS-1$//$NON-NLS-2$
        name += "[" + tfactory + "]";
    // $NON-NLS-1$
    launch.setAttribute("launchName", name);
    // the super.launch will add a Java source director if we set it to null
    // here
    final ISourceLocator configuredLocator = launch.getSourceLocator();
    launch.setSourceLocator(null);
    super.launch(configuration, mode, launch, monitor);
    // now get the java source locator
    final ISourceLocator javaSourceLookupDirector = launch.getSourceLocator();
    // now add our own participant to the java director
    launch.setSourceLocator(new ISourceLocator() {

        public Object getSourceElement(IStackFrame stackFrame) {
            // simply look at one and then the other
            Object sourceElement = javaSourceLookupDirector.getSourceElement(stackFrame);
            if (sourceElement == null)
                sourceElement = configuredLocator.getSourceElement(stackFrame);
            return sourceElement;
        }
    });
    // IJavaDebugTarget javaTarget =
    // (IJavaDebugTarget)launch.getDebugTarget();
    // launch.removeDebugTarget(javaTarget);
    IDebugTarget javaTarget = launch.getDebugTarget();
    IDebugTarget xslTarget = new JAXPDebugTarget(launch, launch.getProcesses()[0], launchHelper);
    // remove java as the primary target and make xsl the primary target
    launch.removeDebugTarget(javaTarget);
    launch.addDebugTarget(xslTarget);
// add this here to make java the non-primary target
// launch.addDebugTarget(javaTarget);
// launch.addDebugTarget(new JavaXSLDebugTarget(launch,
// launch.getProcesses()[0], launchHelper, javaTarget));
}
Also used : JAXPDebugTarget(org.eclipse.wst.xsl.jaxp.launching.model.JAXPDebugTarget) IStackFrame(org.eclipse.debug.core.model.IStackFrame) IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall) IDebugTarget(org.eclipse.debug.core.model.IDebugTarget) ISourceLocator(org.eclipse.debug.core.model.ISourceLocator)

Example 4 with IStackFrame

use of org.eclipse.debug.core.model.IStackFrame in project webtools.sourceediting by eclipse.

the class JAXPDebugTarget method getStackFrames.

/**
 * Returns the current stack frames in the target.
 */
public IStackFrame[] getStackFrames() throws DebugException {
    synchronized (STACK_FRAMES_LOCK) {
        if (stale) {
            stale = false;
            String framesData = sendRequest(DebugConstants.REQUEST_STACK);
            // $NON-NLS-1$
            String[] frames = framesData.split("\\$\\$\\$");
            IStackFrame[] sf = new IStackFrame[frames.length];
            List<IStackFrame> currentFrames = Arrays.asList(stackFramesCache);
            for (int i = 0; i < frames.length; i++) {
                String data = frames[i];
                XSLStackFrame frame = new XSLStackFrame(thread, data, i);
                int index;
                if ((index = currentFrames.indexOf(frame)) != -1) {
                    XSLStackFrame curr = (XSLStackFrame) currentFrames.get(index);
                    curr.setLineNumber(frame.getLineNumber());
                    curr.setVariables(frame.getVariables());
                    frame = curr;
                }
                sf[frames.length - i - 1] = frame;
            }
            stackFramesCache = sf;
        }
        return stackFramesCache;
    }
}
Also used : IStackFrame(org.eclipse.debug.core.model.IStackFrame) XSLStackFrame(org.eclipse.wst.xsl.launching.model.XSLStackFrame) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint)

Aggregations

IStackFrame (org.eclipse.debug.core.model.IStackFrame)4 IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)2 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)1 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)1 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)1 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)1 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)1 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)1 ArrayList (java.util.ArrayList)1 CoreException (org.eclipse.core.runtime.CoreException)1 DebugException (org.eclipse.debug.core.DebugException)1 IBreakpointManager (org.eclipse.debug.core.IBreakpointManager)1 IDebugTarget (org.eclipse.debug.core.model.IDebugTarget)1 ILineBreakpoint (org.eclipse.debug.core.model.ILineBreakpoint)1 ISourceLocator (org.eclipse.debug.core.model.ISourceLocator)1 IProcessorInstall (org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall)1 JAXPDebugTarget (org.eclipse.wst.xsl.jaxp.launching.model.JAXPDebugTarget)1 XSLStackFrame (org.eclipse.wst.xsl.launching.model.XSLStackFrame)1 ErlangLineBreakpoint (org.erlide.backend.debug.ErlangLineBreakpoint)1 ErlangStackFrame (org.erlide.backend.debug.model.ErlangStackFrame)1