Search in sources :

Example 1 with ErlangStackFrame

use of org.erlide.backend.debug.model.ErlangStackFrame 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)

Aggregations

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 IStackFrame (org.eclipse.debug.core.model.IStackFrame)1 ErlangStackFrame (org.erlide.backend.debug.model.ErlangStackFrame)1