Search in sources :

Example 6 with OtpErlangPid

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

the class ErlideDebug method attached.

/**
 * Sent upon attach of process (should we move this to erlang, erlide_debug?
 * maybe we should have an erlang process subscribing, and even filtering
 * events to us)
 *
 * @param backend
 *            backend
 * @param pid
 *            pid of attached process
 * @param jpid
 *            java pseudo-pid
 * @return pid of meta process
 */
public static OtpErlangPid attached(final IOtpRpc backend, final OtpErlangPid pid, final OtpErlangPid jpid) {
    OtpErlangObject res = null;
    try {
        res = backend.call(ErlideDebug.ERLIDE_DEBUG, "attached", "xx", pid, jpid);
        if (res instanceof OtpErlangTuple) {
            final OtpErlangTuple t = (OtpErlangTuple) res;
            final OtpErlangPid meta = (OtpErlangPid) t.elementAt(1);
            return meta;
        }
        return null;
    } catch (final RpcException e) {
        ErlLogger.warn(e);
    }
    return null;
}
Also used : OtpErlangPid(com.ericsson.otp.erlang.OtpErlangPid) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Example 7 with OtpErlangPid

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

the class BackendShellManager method openShell.

public synchronized IBackendShell openShell(final String id) {
    BackendShell shell = getShell(id);
    if (shell == null) {
        OtpErlangPid server = null;
        try {
            server = new ErlideReshd().start(backend.getRuntime());
        } catch (final Exception e) {
            ErlLogger.warn(e);
        }
        shell = new BackendShell(backend, id, server);
        shell.open();
        fShells.put(id, shell);
    }
    return shell;
}
Also used : OtpErlangPid(com.ericsson.otp.erlang.OtpErlangPid) IBackendShell(org.erlide.runtime.shell.IBackendShell)

Example 8 with OtpErlangPid

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

the class AttachedEvent method execute.

@Override
public void execute(final ErlangDebugTarget debugTarget) {
    if (debugTarget.getMetaFromPid(pid) == null) {
        final OtpErlangPid self = debugTarget.getEventMBox();
        final OtpErlangPid metaPid = ErlideDebug.attached(debugTarget.getBackend().getOtpRpc(), pid, self);
        // ErlLogger.debug("attached: " + pid + ", meta: " + metaPid);
        if (metaPid != null) {
            debugTarget.putMetaPid(metaPid, pid);
        }
    // ErlideDebug.tracing(runtime, true, metaPid);
    }
}
Also used : OtpErlangPid(com.ericsson.otp.erlang.OtpErlangPid)

Example 9 with OtpErlangPid

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

the class IOServer method handleMessage.

private void handleMessage(final OtpErlangObject msg) {
    final OtpErlangTuple tuple = (OtpErlangTuple) msg;
    final String tag = ((OtpErlangAtom) tuple.elementAt(0)).atomValue();
    if ("io_request".equals(tag)) {
        final OtpErlangPid from = (OtpErlangPid) tuple.elementAt(1);
        final OtpErlangObject replyAs = tuple.elementAt(2);
        final OtpErlangTuple request = (OtpErlangTuple) tuple.elementAt(3);
        final OtpErlangObject reply = processRequest(from, request);
        final OtpErlangTuple replyMsg = OtpErlang.mkTuple(new OtpErlangAtom("io_reply"), replyAs, reply);
        mbox.send(from, replyMsg);
    } else {
        ErlLogger.warn("IOServer: unknown message " + msg);
    }
}
Also used : OtpErlangPid(com.ericsson.otp.erlang.OtpErlangPid) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 10 with OtpErlangPid

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

the class ErlSearchQuery method run.

@Override
public IStatus run(final IProgressMonitor monitor) throws OperationCanceledException {
    final Object locker = new Object();
    final IRpcResultCallback callback = new IRpcResultCallback() {

        @Override
        public void start(final OtpErlangObject msg) {
            if (fSearchResult != null) {
                fSearchResult.removeAll();
            }
            final OtpErlangLong progressMaxL = (OtpErlangLong) msg;
            int progressMax;
            try {
                progressMax = progressMaxL.intValue();
            } catch (final OtpErlangRangeException e) {
                progressMax = 10;
            }
            monitor.beginTask("Searching", progressMax);
        }

        @Override
        public void stop(final OtpErlangObject msg) {
            monitor.done();
            stopped = true;
            synchronized (locker) {
                locker.notifyAll();
            }
        }

        @Override
        public void progress(final OtpErlangObject msg) {
            final OtpErlangTuple t = (OtpErlangTuple) msg;
            final OtpErlangPid backgroundSearchPid = (OtpErlangPid) t.elementAt(0);
            final OtpErlangLong progressL = (OtpErlangLong) t.elementAt(1);
            final OtpErlangObject resultO = t.elementAt(2);
            int progress = 1;
            try {
                progress = progressL.intValue();
                final List<ModuleLineFunctionArityRef> result = Lists.newArrayList();
                SearchUtil.addSearchResult(result, resultO);
                addMatches(result);
            } catch (final OtpErlangRangeException e) {
            }
            monitor.worked(progress);
            if (monitor.isCanceled()) {
                try {
                    ErlangEngine.getInstance().getSearchServerService().cancelSearch(backgroundSearchPid);
                } catch (final RpcException e) {
                }
            }
        }
    };
    try {
        final ErlSearchScope reducedScope = pattern.reduceScope(scope);
        ErlangEngine.getInstance().getSearchServerService().startFindRefs(pattern, reducedScope, ErlangEngine.getInstance().getStateDir(), callback, false);
    } catch (final RpcException e) {
        return new Status(IStatus.ERROR, ErlideUIPlugin.PLUGIN_ID, "Search error", e);
    }
    while (!stopped) {
        synchronized (locker) {
            try {
                if (!stopped) {
                    locker.wait();
                }
            } catch (final InterruptedException e) {
            }
        }
    }
    return Status.OK_STATUS;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) ModuleLineFunctionArityRef(org.erlide.engine.services.search.ModuleLineFunctionArityRef) ErlSearchScope(org.erlide.engine.services.search.ErlSearchScope) IRpcResultCallback(org.erlide.runtime.rpc.IRpcResultCallback) OtpErlangPid(com.ericsson.otp.erlang.OtpErlangPid) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

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