Exemplo n.º 1
0
 /**
  * Loads traces from active result set ( {@link #setActiveResultSet(TracingResultsNode)}). Index
  * of last trace which will be loaded is <code>max(number_of_traces, endIndex)</code>.
  *
  * @param theStartIndex number of first trace
  * @param endIndex number of last trace
  */
 public void loadDataFromFile(final long theStartIndex, final long endIndex) {
   if (!tracing && !loading) {
     synchronized (this) {
       if (!tracing && !loading) {
         try {
           loading = true;
           loadingFileInfo = false;
           startIndex = theStartIndex;
           handler = new TraceEventHandler();
           getBackend(true);
           TraceCollections.getTracesList().clear();
           tracerBackend.getEventDaemon().addHandler(handler);
           final OtpErlangLong start = new OtpErlangLong(theStartIndex);
           final OtpErlangLong stop = new OtpErlangLong(endIndex);
           tracerBackend.call(
               Constants.ERLANG_HELPER_MODULE,
               FUN_LOAD,
               "sii",
               new OtpErlangString(activeResultSet.getFileName()),
               start,
               stop);
         } catch (final RpcException e) {
           ErlLogger.error(e);
           errorObject = e;
           finishLoading(TracingStatus.EXCEPTION_THROWN);
         }
       }
     }
   }
 }
Exemplo n.º 2
0
 /**
  * Performs actions after loading file or trace data.
  *
  * @param status status
  */
 private void finishLoading(final TracingStatus status) {
   tracerBackend.getEventDaemon().removeHandler(handler);
   for (final ITraceNodeObserver listener : listeners) {
     try {
       if (loadingFileInfo) {
         listener.finishLoadingFile(status);
       } else {
         listener.finishLoadingTraces(status);
       }
     } catch (final Exception e) {
       ErlLogger.error(e);
     }
   }
   loading = false;
   tracing = false;
 }
Exemplo n.º 3
0
    public Object[] getElements(final Object parent) {
      final IBackend bk = getBackend();
      if (bk == null) {
        return new OtpErlangObject[] {};
      }
      bk.getEventDaemon().addHandler(handler);

      final OtpErlangList r = ErlideProclist.getProcessList(bk);
      if (r.arity() == 0) {
        return new OtpErlangObject[] {};
      }
      final OtpErlangObject[] ss = new OtpErlangObject[r.elements().length];

      for (int i = 0; i < r.elements().length; i++) {
        final OtpErlangTuple e = (OtpErlangTuple) r.elementAt(i);
        ss[i] = e;
      }

      return ss;
    }
Exemplo n.º 4
0
 /**
  * Loads information about given file.
  *
  * @param path path
  */
 public void loadFile(final String path) {
   if (!tracing && !loading) {
     synchronized (this) {
       if (!tracing && !loading) {
         try {
           loading = true;
           loadingFileInfo = true;
           handler = new TraceEventHandler();
           getBackend(true);
           tracerBackend.getEventDaemon().addHandler(handler);
           tracerBackend.call(
               Constants.ERLANG_HELPER_MODULE, FUN_FILE_INFO, "s", new OtpErlangString(path));
         } catch (final RpcException e) {
           ErlLogger.error(e);
           errorObject = e;
           finishLoading(TracingStatus.EXCEPTION_THROWN);
         }
       }
     }
   }
 }
Exemplo n.º 5
0
  /**
   * 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.getEventDaemon().addHandler(handler);

            // list of nodes being traced
            final List<OtpErlangObject> erlangObjects = new ArrayList<OtpErlangObject>();
            notActivatedNodes = new HashSet<String>();
            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.call(
                    Constants.ERLANG_HELPER_MODULE,
                    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) {
            e.printStackTrace();
            ErlLogger.error("Could not start tracing tool: " + e.getMessage());
            status = TracingStatus.EXCEPTION_THROWN;
            errorObject = e;
            tracing = false;
          }
        }
      }
    }
    return status;
  }
Exemplo n.º 6
0
 public void dispose() {
   final IBackend backend = getBackend();
   if (backend != null) {
     backend.getEventDaemon().removeHandler(handler);
   }
 }