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