import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.statesystem.IStateChangeInput;
+import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
import org.eclipse.linuxtools.tmf.core.statesystem.StateSystemManager;
/**
@Override
protected void buildStateSystem() throws TmfTraceException {
+ super.buildStateSystem();
+
/* Set up the path to the history tree file we'll use */
IResource resource = this.getResource();
String supplDirectory = null;
final File htFile = new File(supplDirectory + File.separator + HISTORY_TREE_FILE_NAME);
final IStateChangeInput htInput = new CtfKernelStateInput(this);
- this.ss = StateSystemManager.loadStateHistory(htFile, htInput, STATE_ID, false);
- }
-
- @Override
- public synchronized void dispose() {
- /* Clean up the state system */
- if (ss != null) {
- ss.dispose();
- }
- super.dispose();
+ ITmfStateSystem ss = StateSystemManager.loadStateHistory(htFile, htInput, STATE_ID, false);
+ fStateSystems.put(STATE_ID, ss);
}
-
}
import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
import org.eclipse.linuxtools.internal.lttng2.kernel.core.StateValues;
import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
+import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;
import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
Map<String, String> retMap = new LinkedHashMap<String, String>();
if (event instanceof ControlFlowEvent) {
ControlFlowEntry entry = (ControlFlowEntry) event.getEntry();
- ITmfStateSystem ssq = entry.getTrace().getStateSystem();
+ ITmfStateSystem ssq = entry.getTrace().getStateSystem(CtfKernelTrace.STATE_ID);
int tid = entry.getThreadId();
try {
}
if (trace instanceof CtfKernelTrace) {
CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) trace;
- ITmfStateSystem ssq = ctfKernelTrace.getStateSystem();
+ ITmfStateSystem ssq = ctfKernelTrace.getStateSystem(CtfKernelTrace.STATE_ID);
if (time >= ssq.getStartTime() && time <= ssq.getCurrentEndTime()) {
List<Integer> currentThreadQuarks = ssq.getQuarks(Attributes.CPUS, "*", Attributes.CURRENT_THREAD); //$NON-NLS-1$
for (int currentThreadQuark : currentThreadQuarks) {
if (aTrace instanceof CtfKernelTrace) {
ArrayList<ControlFlowEntry> entryList = new ArrayList<ControlFlowEntry>();
CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) aTrace;
- ITmfStateSystem ssq = ctfKernelTrace.getStateSystem();
+ ITmfStateSystem ssq = ctfKernelTrace.getStateSystem(CtfKernelTrace.STATE_ID);
if (!ssq.waitUntilBuilt()) {
return;
}
}
private void buildStatusEvents(ITmfTrace trace, ControlFlowEntry entry, IProgressMonitor monitor) {
- ITmfStateSystem ssq = entry.getTrace().getStateSystem();
+ ITmfStateSystem ssq = entry.getTrace().getStateSystem(CtfKernelTrace.STATE_ID);
long start = ssq.getStartTime();
long end = ssq.getCurrentEndTime() + 1;
long resolution = Math.max(1, (end - start) / fDisplayWidth);
if (endTime <= startTime) {
return null;
}
- ITmfStateSystem ssq = entry.getTrace().getStateSystem();
+ ITmfStateSystem ssq = entry.getTrace().getStateSystem(CtfKernelTrace.STATE_ID);
List<ITimeEvent> eventList = null;
try {
int statusQuark = ssq.getQuarkRelative(entry.getThreadQuark(), Attributes.STATUS);
import org.eclipse.linuxtools.internal.lttng2.kernel.core.StateValues;
import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources.ResourcesEntry.Type;
+import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;
import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
if (status == StateValues.CPU_STATUS_IRQ) {
// In IRQ state get the IRQ that caused the interruption
ResourcesEntry entry = (ResourcesEntry) event.getEntry();
- ITmfStateSystem ssq = entry.getTrace().getStateSystem();
+ ITmfStateSystem ss = entry.getTrace().getStateSystem(CtfKernelTrace.STATE_ID);
int cpu = entry.getId();
- ITmfStateSystem ss = entry.getTrace().getStateSystem();
try {
List<ITmfStateInterval> fullState = ss.queryFullState(event.getTime());
List<Integer> irqQuarks = ss.getQuarks(Attributes.RESOURCES, Attributes.IRQS, "*"); //$NON-NLS-1$
for (int irqQuark : irqQuarks) {
if (fullState.get(irqQuark).getStateValue().unboxInt() == cpu) {
- ITmfStateInterval value = ssq.querySingleState(event.getTime(), irqQuark);
+ ITmfStateInterval value = ss.querySingleState(event.getTime(), irqQuark);
if (!value.getStateValue().isNull()) {
- int irq = Integer.parseInt(ssq.getAttributeName(irqQuark));
+ int irq = Integer.parseInt(ss.getAttributeName(irqQuark));
retMap.put(Messages.ResourcesView_attributeIrqName, String.valueOf(irq));
}
break;
} else if (status == StateValues.CPU_STATUS_SOFTIRQ) {
// In SOFT_IRQ state get the SOFT_IRQ that caused the interruption
ResourcesEntry entry = (ResourcesEntry) event.getEntry();
- ITmfStateSystem ssq = entry.getTrace().getStateSystem();
+ ITmfStateSystem ss = entry.getTrace().getStateSystem(CtfKernelTrace.STATE_ID);
int cpu = entry.getId();
- ITmfStateSystem ss = entry.getTrace().getStateSystem();
try {
List<ITmfStateInterval> fullState = ss.queryFullState(event.getTime());
List<Integer> softIrqQuarks = ss.getQuarks(Attributes.RESOURCES, Attributes.SOFT_IRQS, "*"); //$NON-NLS-1$
for (int softIrqQuark : softIrqQuarks) {
if (fullState.get(softIrqQuark).getStateValue().unboxInt() == cpu) {
- ITmfStateInterval value = ssq.querySingleState(event.getTime(), softIrqQuark);
+ ITmfStateInterval value = ss.querySingleState(event.getTime(), softIrqQuark);
if (!value.getStateValue().isNull()) {
- int softIrq = Integer.parseInt(ssq.getAttributeName(softIrqQuark));
+ int softIrq = Integer.parseInt(ss.getAttributeName(softIrqQuark));
retMap.put(Messages.ResourcesView_attributeSoftIrqName, String.valueOf(softIrq));
}
break;
} else if (status == StateValues.CPU_STATUS_RUN_USERMODE || status == StateValues.CPU_STATUS_RUN_SYSCALL){
// In running state get the current tid
ResourcesEntry entry = (ResourcesEntry) event.getEntry();
- ITmfStateSystem ssq = entry.getTrace().getStateSystem();
+ ITmfStateSystem ssq = entry.getTrace().getStateSystem(CtfKernelTrace.STATE_ID);
try {
retMap.put(Messages.ResourcesView_attributeHoverTime, Utils.formatTime(hoverTime, TimeFormat.ABSOLUTE, Resolution.NANOSEC));
}
long resolution = Math.max(1, (fZoomEndTime - fZoomStartTime) / fDisplayWidth);
for (TraceEntry traceEntry : fZoomEntryList) {
- if (!traceEntry.fKernelTrace.getStateSystem().waitUntilBuilt()) {
+ if (!traceEntry.fKernelTrace.getStateSystem(CtfKernelTrace.STATE_ID).waitUntilBuilt()) {
return;
}
for (ITimeGraphEntry child : traceEntry.getChildren()) {
}
if (aTrace instanceof CtfKernelTrace) {
CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) aTrace;
- ITmfStateSystem ssq = ctfKernelTrace.getStateSystem();
+ ITmfStateSystem ssq = ctfKernelTrace.getStateSystem(CtfKernelTrace.STATE_ID);
if (!ssq.waitUntilBuilt()) {
return;
}
return;
}
CtfKernelTrace ctfKernelTrace = traceEntry.getTrace();
- ITmfStateSystem ssq = ctfKernelTrace.getStateSystem();
+ ITmfStateSystem ssq = ctfKernelTrace.getStateSystem(CtfKernelTrace.STATE_ID);
long startTime = ssq.getStartTime();
long endTime = ssq.getCurrentEndTime() + 1;
long resolution = (endTime - startTime) / fDisplayWidth;
private static List<ITimeEvent> getEventList(ResourcesEntry entry,
long startTime, long endTime, long resolution, boolean includeNull,
IProgressMonitor monitor) {
- ITmfStateSystem ssq = entry.getTrace().getStateSystem();
+ ITmfStateSystem ssq = entry.getTrace().getStateSystem(CtfKernelTrace.STATE_ID);
startTime = Math.max(startTime, ssq.getStartTime());
endTime = Math.min(endTime, ssq.getCurrentEndTime() + 1);
if (endTime <= startTime) {
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
-import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.junit.After;
import org.junit.Before;
assertEquals(1000, result.getCacheSize());
assertEquals(0L, result.getNbEvents());
assertEquals(0L, result.getStreamingInterval());
- assertNull(result.getStateSystem());
assertNull(result.getResource());
assertEquals(1000, result.getQueueSize());
assertNull(result.getType());
assertNotNull(result);
}
- /**
- * Run the IStateSystemQuerier getStateSystem() method test.
- */
- @Test
- public void testGetStateSystem() {
- ITmfStateSystem result = fixture.getStateSystem();
- assertNull(result);
- }
-
/**
* Run the long getStreamingInterval() method test.
*/
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.Collection;
import java.util.Vector;
import junit.framework.TestCase;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
+import org.eclipse.linuxtools.tmf.core.statistics.ITmfStatistics;
import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
assertEquals("GetBookmarksFile", bookmarks, fExperiment.getBookmarksFile());
}
+ // ------------------------------------------------------------------------
+ // State system and statistics methods
+ // ------------------------------------------------------------------------
+
+ public void testGetStatistics() {
+ /* There should not be any experiment-specific statistics */
+ ITmfStatistics stats = fExperiment.getStatistics();
+ assertNull(stats);
+ }
+
+ public void testGetStateSystem() {
+ /* There should not be any experiment-specific state system */
+ ITmfStateSystem ss = fExperiment.getStateSystem("something");
+ assertNull(ss);
+ }
+
+ public void testListStateSystem() {
+ Collection<String> sss = fExperiment.listStateSystems();
+ assertNotNull(sss);
+ assertEquals(0, sss.size());
+ }
+
// ------------------------------------------------------------------------
// seekEvent by location
// ------------------------------------------------------------------------
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.Collection;
import java.util.Vector;
import junit.framework.TestCase;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
+import org.eclipse.linuxtools.tmf.core.statistics.ITmfStatistics;
import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
trace.dispose();
}
+ // ------------------------------------------------------------------------
+ // State system and statistics methods
+ // ------------------------------------------------------------------------
+
+ public void testGetStatistics() {
+ /* Should be null in unit tests */
+ ITmfStatistics stats = fTrace.getStatistics();
+ assertNull(stats);
+ }
+
+ public void testGetStateSystem() {
+ /* There should be no state system registered so far */
+ ITmfStateSystem ss = fTrace.getStateSystem("something");
+ assertNull(ss);
+ }
+
+ public void testListStateSystem() {
+ Collection<String> sss = fTrace.listStateSystems();
+ assertNotNull(sss);
+ assertEquals(0, sss.size());
+ }
+
// ------------------------------------------------------------------------
// seekEvent on location (note: does not reliably set the rank)
// ------------------------------------------------------------------------
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
// Fields
//-------------------------------------------
- /** Reference to the state system assigned to this trace */
- protected ITmfStateSystem ss = null;
-
/* Reference to the CTF Trace */
private CTFTrace fTrace;
return event;
}
- /**
- * @since 2.0
- */
- @Override
- public ITmfStateSystem getStateSystem() {
- return this.ss;
- }
-
/**
* gets the CTFtrace that this is wrapping
* @return the CTF trace
package org.eclipse.linuxtools.tmf.core.trace;
+import java.util.Collection;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
public ITmfStatistics getStatistics();
/**
- * @return The state system that is associated with this trace
+ * Retrieve a state system that belongs to this trace
+ *
+ * @param id
+ * The ID of the state system to retrieve.
+ * @return The state system that is associated with this trace and ID, or
+ * 'null' if such a match doesn't exist.
+ * @since 2.0
+ */
+ public ITmfStateSystem getStateSystem(String id);
+
+ /**
+ * Return the list of existing state systems registered with this trace.
+ *
+ * @return A Collection view of the available state systems. The collection
+ * could be empty, but should not be null.
* @since 2.0
*/
- public ITmfStateSystem getStateSystem();
+ public Collection<String> listStateSystems();
// ------------------------------------------------------------------------
// Trace characteristics getters
package org.eclipse.linuxtools.tmf.core.trace;
import java.io.File;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
// The current selected range
private TmfTimeRange fCurrentRange = TmfTimeRange.NULL_RANGE;
+ /**
+ * The collection of state systems that are registered with this trace. Each
+ * sub-class can decide to add its (one or many) state system to this map
+ * during their {@link #buildStateSystem()}.
+ *
+ * @since 2.0
+ */
+ protected final Map<String, ITmfStateSystem> fStateSystems =
+ new HashMap<String, ITmfStateSystem>();
+
// ------------------------------------------------------------------------
// Construction
// ------------------------------------------------------------------------
protected void buildStateSystem() throws TmfTraceException {
/*
* Nothing is done in the base implementation, please specify
- * how/if to build a state system in derived classes.
+ * how/if to register a new state system in derived classes.
*/
return;
}
if (fStatistics != null) {
fStatistics.dispose();
}
+
+ /* Clean up the state systems */
+ for (ITmfStateSystem ss : fStateSystems.values()) {
+ ss.dispose();
+ }
+
super.dispose();
}
* @since 2.0
*/
@Override
- public ITmfStateSystem getStateSystem() {
- /*
- * By default, no state system is used. Sub-classes can specify their
- * own behaviour.
- */
- return null;
+ public final ITmfStateSystem getStateSystem(String id) {
+ return fStateSystems.get(id);
+ }
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public final Collection<String> listStateSystems() {
+ return fStateSystems.keySet();
}
// ------------------------------------------------------------------------