Search in sources :

Example 6 with OtpErlangInt

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

the class TraceBackend method start.

/**
 * Starts tracing given nodes.
 *
 * @return <code>true</code> if successful, <code>false</code> otherwise
 */
public TracingStatus start() {
    TracingStatus status = TracingStatus.OK;
    if (!tracing) {
        synchronized (this) {
            if (!tracing) {
                try {
                    tracing = true;
                    getBackend(true);
                    loadingFileInfo = true;
                    handler = new TraceEventHandler();
                    tracerBackend.getRuntime().registerEventListener(handler);
                    // list of nodes being traced
                    final List<OtpErlangObject> erlangObjects = new ArrayList<>();
                    notActivatedNodes = new HashSet<>();
                    for (final TracedNode tracedNode : tracedNodes) {
                        if (tracedNode.isEnabled()) {
                            final OtpErlangAtom name = new OtpErlangAtom(tracedNode.getNodeName());
                            final OtpErlangAtom cookie = new OtpErlangAtom(tracedNode.getCookie());
                            erlangObjects.add(new OtpErlangTuple(new OtpErlangObject[] { name, cookie }));
                            notActivatedNodes.add(tracedNode.getNodeName());
                        }
                    }
                    final OtpErlangList nodes = new OtpErlangList(erlangObjects.toArray(new OtpErlangObject[erlangObjects.size()]));
                    // net tick time
                    final int tickTimeValue = Activator.getDefault().getPreferenceStore().getInt(PreferenceNames.TICK_TIME);
                    final OtpErlangInt netTickTime = new OtpErlangInt(tickTimeValue);
                    final OtpErlangObject callResult = tracerBackend.getOtpRpc().call(Constants.ERLANG_HELPER_MODULE, TraceBackend.FUN_START, "xsi", nodes, Constants.OUTPUT_FILE, netTickTime);
                    status = processResult(callResult);
                    if (TracingStatus.OK.equals(status) || TracingStatus.NOT_ALL_NODES_ACTIVATED.equals(status)) {
                        setProcessFlags();
                        setFunctionTracePatterns();
                        for (final ITraceNodeObserver listener : listeners) {
                            try {
                                listener.startTracing();
                            } catch (final Exception e) {
                                ErlLogger.error(e);
                            }
                        }
                    } else {
                        tracing = false;
                    }
                } catch (final Exception e) {
                    ErlLogger.error(e);
                    status = TracingStatus.EXCEPTION_THROWN;
                    errorObject = e;
                    tracing = false;
                }
            }
        }
    }
    return status;
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) ArrayList(java.util.ArrayList) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) TracedNode(org.erlide.tracing.core.mvc.model.TracedNode) RpcException(org.erlide.runtime.rpc.RpcException) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangInt(com.ericsson.otp.erlang.OtpErlangInt) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Aggregations

OtpErlangInt (com.ericsson.otp.erlang.OtpErlangInt)6 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)4 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)4 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)3 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)3 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)2 RpcException (org.erlide.runtime.rpc.RpcException)2 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)1 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)1 ArrayList (java.util.ArrayList)1 RpcResult (org.erlide.runtime.rpc.RpcResult)1 TracedNode (org.erlide.tracing.core.mvc.model.TracedNode)1 FunctionNode (org.erlide.tracing.core.mvc.model.treenodes.FunctionNode)1 ITreeNode (org.erlide.tracing.core.mvc.model.treenodes.ITreeNode)1 ModuleNode (org.erlide.tracing.core.mvc.model.treenodes.ModuleNode)1 TreeNode (org.erlide.tracing.core.mvc.model.treenodes.TreeNode)1 IErlMemberSelection (org.erlide.wrangler.refactoring.selection.IErlMemberSelection)1