import java.io.IOException;
import java.io.ObjectInputStream;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.tracecompass.segmentstore.core.ISegment;
import org.eclipse.tracecompass.segmentstore.core.ISegmentStore;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.segment.ISegmentAspect;
import com.google.common.base.Function;
import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableList;
/**
* @author Alexandre Montplaisir
private static final String DATA_FILENAME = "latency-analysis.dat"; //$NON-NLS-1$
+ private static final Collection<ISegmentAspect> BASE_ASPECTS =
+ checkNotNull(ImmutableList.of(SyscallNameAspect.INSTANCE));
+
+
@Override
public String getId() {
return ID;
}
+ @Override
+ public Iterable<ISegmentAspect> getSegmentAspects() {
+ return BASE_ASPECTS;
+ }
+
@Override
public String getDataFileName() {
return DATA_FILENAME;
}
}
+ private static class SyscallNameAspect implements ISegmentAspect {
+ public static final ISegmentAspect INSTANCE = new SyscallNameAspect();
+
+ private SyscallNameAspect() { }
+
+ @Override
+ public String getHelpText() {
+ return checkNotNull(Messages.SegmentAspectHelpText_SystemCall);
+ }
+ @Override
+ public String getName() {
+ return checkNotNull(Messages.SegmentAspectName_SystemCall);
+ }
+ @Override
+ public @Nullable String resolve(ISegment segment) {
+ if (segment instanceof SystemCall) {
+ return ((SystemCall) segment).getName();
+ }
+ return EMPTY_STRING;
+ }
+ }
+
}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.analysis.os.linux.core.latency;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Messages for Syscall latency analysis.
+ * @since 2.0
+ */
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.tracecompass.analysis.os.linux.core.latency.messages"; //$NON-NLS-1$
+
+ /** System Call latency analysis aspect name */
+ public static @Nullable String SegmentAspectName_SystemCall;
+
+ /** System Call latency analysis aspect help text */
+ public static @Nullable String SegmentAspectHelpText_SystemCall;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+
+ /**
+ * Helper method to expose externalized strings as non-null objects.
+ */
+ static String getMessage(@Nullable String msg) {
+ if (msg == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return msg;
+ }
+}
--- /dev/null
+###############################################################################
+# Copyright (c) 2015 Ericsson
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+###############################################################################
+
+SegmentAspectName_SystemCall=System Call
+
+SegmentAspectHelpText_SystemCall=The name of the system call.
import org.eclipse.tracecompass.segmentstore.core.ISegment;
import org.eclipse.tracecompass.segmentstore.core.ISegmentStore;
import org.eclipse.tracecompass.segmentstore.core.SegmentComparators;
+import org.eclipse.tracecompass.tmf.core.segment.ISegmentAspect;
import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
/* Doubles as a null check */
return ""; //$NON-NLS-1$
}
- return getTextFoITimeRange((ISegment) input);
+ return getTextForSegment((ISegment) input);
}
- public abstract String getTextFoITimeRange(ISegment input);
+ public abstract String getTextForSegment(ISegment input);
}
/**
* Listener to update the model with the latency analysis results once the
* latency analysis is fully completed
*/
- private final class LatencyListener implements IAnalysisProgressListener {
+ private final class AnalysisProgressListener implements IAnalysisProgressListener {
@Override
public void onComplete(AbstractSegmentStoreAnalysisModule activeAnalysis, ISegmentStore<ISegment> data) {
// Check if the active trace was changed while the analysis was
/**
* Latency analysis completion listener
*/
- private LatencyListener fListener;
+ private AnalysisProgressListener fListener;
+
+ /**
+ * Flag to create columns once
+ */
+ boolean fColumnsCreated = false;
// ------------------------------------------------------------------------
// Constructor
}
createColumns();
getTableViewer().getTable().addSelectionListener(new LatencyTableSelectionListener());
- fListener = new LatencyListener();
+ fListener = new AnalysisProgressListener();
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
/**
- * Create columns for start time, end time and duration
+ * Create default columns for start time, end time and duration
*/
private void createColumns() {
createColumn(Messages.LatencyTableViewer_startTime, new LatencyTableColumnLabelProvider() {
@Override
- public String getTextFoITimeRange(ISegment input) {
+ public String getTextForSegment(ISegment input) {
return NonNullUtils.nullToEmptyString(TmfTimestampFormat.getDefaulTimeFormat().format(input.getStart()));
}
}, SegmentComparators.INTERVAL_START_COMPARATOR);
createColumn(Messages.LatencyTableViewer_endTime, new LatencyTableColumnLabelProvider() {
@Override
- public String getTextFoITimeRange(ISegment input) {
+ public String getTextForSegment(ISegment input) {
return NonNullUtils.nullToEmptyString(TmfTimestampFormat.getDefaulTimeFormat().format(input.getEnd()));
}
}, SegmentComparators.INTERVAL_END_COMPARATOR);
createColumn(Messages.LatencyTableViewer_duration, new LatencyTableColumnLabelProvider() {
@Override
- public String getTextFoITimeRange(ISegment input) {
+ public String getTextForSegment(ISegment input) {
return NonNullUtils.nullToEmptyString(Long.toString(input.getLength()));
}
}, SegmentComparators.INTERVAL_LENGTH_COMPARATOR);
}
+ /**
+ * Create columns specific to the analysis
+ */
+ private void createAnalysisColumns() {
+ if (!fColumnsCreated) {
+ AbstractSegmentStoreAnalysisModule analysis = getAnalysisModule();
+ if (analysis != null) {
+ for (final ISegmentAspect aspect : analysis.getSegmentAspects()) {
+ createColumn(aspect.getName(), new LatencyTableColumnLabelProvider() {
+ @Override
+ public String getTextForSegment(ISegment input) {
+ return NonNullUtils.nullToEmptyString(aspect.resolve(input));
+ }
+ },
+ null);
+ }
+ }
+ fColumnsCreated = true;
+ }
+ }
+
/**
* Update the data in the table viewer
*
updateModel(null);
return;
}
+
+ createAnalysisColumns();
+
ISegmentStore<ISegment> results = analysis.getResults();
// If results are not null, then analysis is completed and model can be
// updated
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
+import org.eclipse.tracecompass.tmf.core.segment.ISegmentAspect;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
+import com.google.common.collect.ImmutableList;
+
/**
* Abstract analysis module to generate a segment store. It is a base class that
* can be used as a shortcut by analysis who just need to build a single segment
return fListeners;
}
+ /**
+ * Return the pre-defined set of segment aspects exposed by this analysis.
+ *
+ * It should not be null, but could be empty.
+ * @return The segment aspects for this analysis
+ */
+ public Iterable<ISegmentAspect> getSegmentAspects() {
+ Collection<ISegmentAspect> coll = ImmutableList.of();
+ return checkNotNull(coll);
+ }
+
/**
* Returns the file name for storing segment store
* @return segment store fine name