Search in sources :

Example 11 with OtpErlangPid

use of com.ericsson.otp.erlang.OtpErlangPid in project erlide_eclipse by erlang.

the class TraceDataHandler method createProcessNode.

private ITreeNode createProcessNode(final String label, final OtpErlangObject erlangObject) {
    final StringBuilder builder = new StringBuilder();
    ITreeNode functionNode = null;
    ITreeNode nameNode = null;
    ITreeNode pidNode = null;
    ITreeNode processNodeNode = null;
    if (erlangObject instanceof OtpErlangTuple) {
        // tuple: {Pid(), Initial_call()|Registered_name(), Node()} |
        // {Registered_name, Node()}
        final OtpErlangTuple processTuple = (OtpErlangTuple) erlangObject;
        int index = 0;
        // pid
        OtpErlangPid pid = null;
        if (processTuple.arity() == 3) {
            // {Pid(), Initial_call()|Registered_name(), Node()}
            pid = (OtpErlangPid) processTuple.elementAt(TraceDataHandler.INDEX_PROCESS_PID);
            pidNode = new TreeNode("pid: " + pid2Str(pid), Activator.getImage(Images.INFO_NODE));
        } else {
            // tuple doesn't contain Pid element
            index = 1;
        }
        final OtpErlangObject info = processTuple.elementAt(TraceDataHandler.INDEX_PROCESS_INFO - index);
        // process node
        final OtpErlangObject processNode = processTuple.elementAt(TraceDataHandler.INDEX_PROCESS_NODE - index);
        processNodeNode = new TreeNode("node: " + processNode, Activator.getImage(Images.INFO_NODE));
        if (info instanceof OtpErlangTuple) {
            // initial call
            functionNode = createFunctionNode("initial call:", info);
            functionNode.setImage(Activator.getImage(Images.INFO_NODE));
            if (pid != null) {
                builder.append(pid2Str(pid));
            } else {
                builder.append(lastFunctionDescription);
            }
        } else {
            // registered name
            nameNode = new TreeNode("name: " + info, Activator.getImage(Images.INFO_NODE));
            builder.append(info.toString());
        }
        builder.append(" (").append(processNode).append(")");
    } else if (erlangObject instanceof OtpErlangPid) {
        // Pid
        final OtpErlangPid pid = (OtpErlangPid) erlangObject;
        pidNode = new TreeNode("pid: " + pid2Str(pid), Activator.getImage(Images.INFO_NODE));
        processNodeNode = new TreeNode("node: " + pid.node(), Activator.getImage(Images.INFO_NODE));
        builder.append(pid2Str(pid)).append(" (").append(pid.node()).append(")");
    } else {
        // Atom (registered name)
        nameNode = new TreeNode("name: " + erlangObject, Activator.getImage(Images.INFO_NODE));
        builder.append(erlangObject.toString());
    }
    final ITreeNode node = new TreeNode();
    if (pidNode != null) {
        node.addChildren(pidNode);
    }
    if (nameNode != null) {
        node.addChildren(nameNode);
    }
    if (processNodeNode != null) {
        node.addChildren(processNodeNode);
    }
    if (functionNode != null) {
        node.addChildren(functionNode);
    }
    lastProcessDescription = builder.toString();
    node.setLabel(label + lastProcessDescription);
    return node;
}
Also used : ITreeNode(org.erlide.tracing.core.mvc.model.treenodes.ITreeNode) OtpErlangPid(com.ericsson.otp.erlang.OtpErlangPid) TreeNode(org.erlide.tracing.core.mvc.model.treenodes.TreeNode) ITreeNode(org.erlide.tracing.core.mvc.model.treenodes.ITreeNode) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Example 12 with OtpErlangPid

use of com.ericsson.otp.erlang.OtpErlangPid in project erlide_eclipse by erlang.

the class OtpNodeProxy method waitForCodeServer.

private boolean waitForCodeServer() {
    try {
        OtpErlangObject r;
        int i = 30;
        boolean gotIt = false;
        do {
            r = otpRpc.call("erlang", "whereis", "a", "code_server");
            gotIt = !(r instanceof OtpErlangPid);
            if (!gotIt) {
                try {
                    Thread.sleep(OtpNodeProxy.POLL_INTERVAL);
                } catch (final InterruptedException e) {
                }
            }
            i--;
        } while (gotIt && i > 0);
        if (gotIt) {
            ErlLogger.error("code server did not start in time for %s", getNodeName());
            return false;
        }
        return true;
    } catch (final Exception e) {
        ErlLogger.error("error starting code server for %s: %s", getNodeName(), e.getMessage());
        return false;
    }
}
Also used : OtpErlangPid(com.ericsson.otp.erlang.OtpErlangPid) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) TimeoutException(java.util.concurrent.TimeoutException) IOException(java.io.IOException) OtpErlangDecodeException(com.ericsson.otp.erlang.OtpErlangDecodeException)

Example 13 with OtpErlangPid

use of com.ericsson.otp.erlang.OtpErlangPid in project erlide_eclipse by erlang.

the class EventParser method parse.

public ErlEvent parse(final OtpErlangObject msg, final IOtpNodeProxy runtime) {
    if (msg == null) {
        return null;
    }
    final String topic = getEventTopic(msg);
    if (topic == null) {
        return null;
    }
    final OtpErlangObject event = getEventData(msg);
    final OtpErlangPid sender = getEventSender(msg);
    return new ErlEvent(topic, runtime, event, sender);
}
Also used : OtpErlangPid(com.ericsson.otp.erlang.OtpErlangPid) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) ErlEvent(org.erlide.runtime.events.ErlEvent)

Example 14 with OtpErlangPid

use of com.ericsson.otp.erlang.OtpErlangPid in project erlide_eclipse by erlang.

the class DebugTraceTarget method cacheCurrentProcess.

private void cacheCurrentProcess() {
    final DebugTraceEvent event = getCurrentEvent();
    final OtpErlangPid pid = event.getPid();
    currentProcess = getProcessWithPid(pid);
    if (currentProcess == null) {
        currentProcess = new DebugTraceProcess(this, pid);
        processes.add(currentProcess);
    }
}
Also used : OtpErlangPid(com.ericsson.otp.erlang.OtpErlangPid)

Example 15 with OtpErlangPid

use of com.ericsson.otp.erlang.OtpErlangPid in project erlide_eclipse by erlang.

the class ErlideReshd method start.

@Override
public OtpErlangPid start(final IOtpNodeProxy runtime) {
    try {
        final OtpErlangObject r = runtime.getOtpRpc().call("erlide_shell", "start", "p", runtime.getEventPid());
        final OtpErlangPid server = (OtpErlangPid) BackendUtils.ok(r);
        return server;
    } catch (final RpcException e) {
        return null;
    }
}
Also used : OtpErlangPid(com.ericsson.otp.erlang.OtpErlangPid) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException)

Aggregations

OtpErlangPid (com.ericsson.otp.erlang.OtpErlangPid)15 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)10 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)8 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)4 RpcException (org.erlide.runtime.rpc.RpcException)4 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 ErlangProcess (org.erlide.backend.debug.model.ErlangProcess)2 OtpErlangBinary (com.ericsson.otp.erlang.OtpErlangBinary)1 OtpErlangChar (com.ericsson.otp.erlang.OtpErlangChar)1 OtpErlangDecodeException (com.ericsson.otp.erlang.OtpErlangDecodeException)1 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)1 OtpErlangMap (com.ericsson.otp.erlang.OtpErlangMap)1 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)1 OtpErlangRef (com.ericsson.otp.erlang.OtpErlangRef)1 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 Map (java.util.Map)1