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;
}
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;
}
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);
}
}
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);
}
}
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;
}
Aggregations