os.linux: Re-organize the KernelAnalysisModule
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 23 Apr 2015 17:25:19 +0000 (13:25 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 4 May 2015 21:43:34 +0000 (17:43 -0400)
Bring the KernelAnalysis up to speed with regards to naming
conventions and public/internal separation:

- Rename KernelAnalysis to KernelAnalysisModule
- Move KernelStateProvider to internal package
- Move KernelStateProviderTest from lttng2 to os.linux plugin
- Remove direct references to KernelStateProvider in
  lttng2.kernel.core.tests, extend the analysis module instead
- Expose the internal package to the test plugin

Change-Id: I8a7baaacdc8a31c033e0fd8ae1650f34fd5232ae
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/46373
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
37 files changed:
org.eclipse.tracecompass.analysis.os.linux.core.tests/plugin.xml
org.eclipse.tracecompass.analysis.os.linux.core.tests/src/org/eclipse/tracecompass/analysis/os/linux/core/tests/cpuusage/CpuUsageStateProviderTest.java
org.eclipse.tracecompass.analysis.os.linux.core.tests/src/org/eclipse/tracecompass/analysis/os/linux/core/tests/kernelanalysis/AllTests.java
org.eclipse.tracecompass.analysis.os.linux.core.tests/src/org/eclipse/tracecompass/analysis/os/linux/core/tests/kernelanalysis/KernelStateProviderTest.java [new file with mode: 0644]
org.eclipse.tracecompass.analysis.os.linux.core.tests/src/org/eclipse/tracecompass/analysis/os/linux/core/tests/kernelanalysis/KernelThreadInformationProviderTest.java
org.eclipse.tracecompass.analysis.os.linux.core.tests/src/org/eclipse/tracecompass/analysis/os/linux/core/tests/kernelanalysis/KernelTidAspectTest.java
org.eclipse.tracecompass.analysis.os.linux.core/META-INF/MANIFEST.MF
org.eclipse.tracecompass.analysis.os.linux.core/plugin.xml
org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/cpuusage/KernelCpuUsageAnalysis.java
org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelAnalysis.java [deleted file]
org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelAnalysisModule.java [new file with mode: 0644]
org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelStateProvider.java [deleted file]
org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelThreadInformationProvider.java
org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelTidAspect.java
org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/ThreadPriorityAspect.java
org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernelanalysis/KernelStateProvider.java [new file with mode: 0644]
org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernelanalysis/LinuxValues.java
org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernelanalysis/package-info.java [new file with mode: 0644]
org.eclipse.tracecompass.analysis.os.linux.ui/plugin.xml
org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/controlflow/ControlFlowCheckActiveProvider.java
org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/controlflow/ControlFlowPresentationProvider.java
org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/controlflow/ControlFlowView.java
org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/cpuusage/CpuUsageComposite.java
org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/resources/ResourcesPresentationProvider.java
org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/resources/ResourcesView.java
org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/AnalysisBenchmark.java
org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/kernel/LttngKernelAnalysisTest.java
org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/kernel/statesystem/GenerateTestValues.java
org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/kernel/statesystem/LttngKernelStateProviderTest.java [deleted file]
org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/kernel/statesystem/PartialStateSystemTest.java
org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/kernel/statesystem/StateSystemFullHistoryTest.java
org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/kernel/statesystem/StateSystemInMemoryTest.java
org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/kernel/statesystem/TestAll.java
org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/vm/VirtualMachineAnalysisTest.java
org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/model/qemukvm/QemuKvmVmModel.java
org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineCpuAnalysis.java
org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineStateProvider.java

index f8059ab8e024946be4bc3f33942b8f102f7d5f32..162b33fca07340ae82be760f4e89eab079db1358 100644 (file)
@@ -14,7 +14,7 @@
          </tracetype>
       </module>
       <module
-            analysis_module="org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis"
+            analysis_module="org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule"
             automatic="false"
             id="org.eclipse.tracecompass.analysis.os.linux.kernel"
             name="Linux Kernel Test Analysis">
index b9d9e76a9d9ef8f72ede8c596524fbe3676ec308..51b4b70d4608ad34392f30877cf873bc5ce7768c 100644 (file)
@@ -27,7 +27,7 @@ import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.KernelCpuUsageAnalysis;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.Attributes;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.analysis.os.linux.core.tests.Activator;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
@@ -91,7 +91,7 @@ public class CpuUsageStateProviderTest {
          * request precedence is implemented
          */
         IAnalysisModule module = null;
-        for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, KernelAnalysis.class)) {
+        for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, KernelAnalysisModule.class)) {
             module = mod;
         }
         assertNotNull(module);
index f2e1a49dbd213a435fea80108fbd5627cefc8f6f..781e2f32cd0fb8345e1bce7f59b708ca59b7312c 100644 (file)
@@ -20,8 +20,9 @@ import org.junit.runners.Suite;
  */
 @RunWith(Suite.class)
 @Suite.SuiteClasses({
-    KernelThreadInformationProviderTest.class,
-    KernelTidAspectTest.class
+        KernelStateProviderTest.class,
+        KernelThreadInformationProviderTest.class,
+        KernelTidAspectTest.class
 })
 public class AllTests {
 
diff --git a/org.eclipse.tracecompass.analysis.os.linux.core.tests/src/org/eclipse/tracecompass/analysis/os/linux/core/tests/kernelanalysis/KernelStateProviderTest.java b/org.eclipse.tracecompass.analysis.os.linux.core.tests/src/org/eclipse/tracecompass/analysis/os/linux/core/tests/kernelanalysis/KernelStateProviderTest.java
new file mode 100644 (file)
index 0000000..4f53a3d
--- /dev/null
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 2015 Ericsson
+ * Copyright (c) 2010, 2011 École Polytechnique de Montréal
+ * Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
+ *
+ * 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.tests.kernelanalysis;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assume.assumeTrue;
+
+import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
+import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernelanalysis.KernelStateProvider;
+import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
+import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests for the {@link KernelStateProvider}
+ *
+ * @author Alexandre Montplaisir
+ */
+public class KernelStateProviderTest {
+
+    private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.TRACE2;
+
+    private static ITmfStateProvider input;
+
+    /**
+     * Set-up.
+     */
+    @BeforeClass
+    public static void initialize() {
+        assumeTrue(testTrace.exists());
+        input = new KernelStateProvider(testTrace.getTrace(), IKernelAnalysisEventLayout.DEFAULT_LAYOUT);
+    }
+
+    /**
+     * Test loading the state provider.
+     */
+    @Test
+    public void testOpening() {
+        long testStartTime;
+        testStartTime = input.getStartTime();
+        /* Expected start time of "trace2" */
+        assertEquals(testStartTime, 1331668247314038062L);
+    }
+
+}
index 416937e92f94c652fab2334a833882b2c1099d62..987d5fcb31078ff22fbdfb4cf6100170d2fca40b 100644 (file)
@@ -28,7 +28,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelThreadInformationProvider;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.StateValues;
 import org.eclipse.tracecompass.analysis.os.linux.core.tests.Activator;
@@ -49,7 +49,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 /**
- * Test analysis-specific methods for the {@link KernelAnalysis} class.
+ * Test analysis-specific methods for the {@link KernelAnalysisModule} class.
  *
  * @author Geneviève Bastien
  */
@@ -58,7 +58,7 @@ public class KernelThreadInformationProviderTest {
     private static final @NonNull String LTTNG_KERNEL_FILE = "testfiles/lttng_kernel_analysis.xml";
 
     private ITmfTrace fTrace;
-    private KernelAnalysis fModule;
+    private KernelAnalysisModule fModule;
 
     private static void deleteSuppFiles(ITmfTrace trace) {
         /* Remove supplementary files */
@@ -87,13 +87,13 @@ public class KernelThreadInformationProviderTest {
         deleteSuppFiles(trace);
         ((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
         IAnalysisModule module = null;
-        for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, KernelAnalysis.class)) {
+        for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, KernelAnalysisModule.class)) {
             module = mod;
         }
         assertNotNull(module);
         module.schedule();
         module.waitForCompletion();
-        fModule = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelAnalysis.class, KernelAnalysis.ID);
+        fModule = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelAnalysisModule.class, KernelAnalysisModule.ID);
         fTrace = trace;
     }
 
@@ -108,24 +108,24 @@ public class KernelThreadInformationProviderTest {
 
     /**
      * Test the
-     * {@link KernelThreadInformationProvider#getThreadIds(KernelAnalysis)}
+     * {@link KernelThreadInformationProvider#getThreadIds(KernelAnalysisModule)}
      * method
      */
     @Test
     public void testGetThreadQuarks() {
-        KernelAnalysis module = checkNotNull(fModule);
+        KernelAnalysisModule module = checkNotNull(fModule);
         Collection<Integer> threadIds = KernelThreadInformationProvider.getThreadIds(module);
         assertEquals(7, threadIds.size());
     }
 
     /**
      * Test the
-     * {@link KernelThreadInformationProvider#getThreadOnCpu(KernelAnalysis, long, long)}
+     * {@link KernelThreadInformationProvider#getThreadOnCpu(KernelAnalysisModule, long, long)}
      * method
      */
     @Test
     public void testGetThreadOnCpu() {
-        KernelAnalysis module = checkNotNull(fModule);
+        KernelAnalysisModule module = checkNotNull(fModule);
 
         /* Check with invalid timestamps */
         Integer tid = KernelThreadInformationProvider.getThreadOnCpu(module, 0, -1);
@@ -173,12 +173,12 @@ public class KernelThreadInformationProviderTest {
 
     /**
      * Test the
-     * {@link KernelThreadInformationProvider#getParentPid(KernelAnalysis, Integer, long)}
+     * {@link KernelThreadInformationProvider#getParentPid(KernelAnalysisModule, Integer, long)}
      * method
      */
     @Test
     public void testGetPpid() {
-        KernelAnalysis module = checkNotNull(fModule);
+        KernelAnalysisModule module = checkNotNull(fModule);
 
         /* Check with invalid timestamps */
         Integer ppid = KernelThreadInformationProvider.getParentPid(module, 11, -1);
@@ -218,11 +218,11 @@ public class KernelThreadInformationProviderTest {
     }
 
     /**
-     * Test the {@link KernelThreadInformationProvider#getExecutableName(KernelAnalysis, Integer)} method
+     * Test the {@link KernelThreadInformationProvider#getExecutableName(KernelAnalysisModule, Integer)} method
      */
     @Test
     public void testGetExecutableName() {
-        KernelAnalysis module = checkNotNull(fModule);
+        KernelAnalysisModule module = checkNotNull(fModule);
 
         /* Check with invalid threads */
         String execName = KernelThreadInformationProvider.getExecutableName(module, 101);
@@ -250,12 +250,12 @@ public class KernelThreadInformationProviderTest {
 
     /**
      * Test the
-     * {@link KernelThreadInformationProvider#getStatusIntervalsForThread(KernelAnalysis, Integer, long, long, long, IProgressMonitor)}
+     * {@link KernelThreadInformationProvider#getStatusIntervalsForThread(KernelAnalysisModule, Integer, long, long, long, IProgressMonitor)}
      * method
      */
     @Test
     public void testGetStatusIntervalsForThread() {
-        KernelAnalysis module = checkNotNull(fModule);
+        KernelAnalysisModule module = checkNotNull(fModule);
 
         IProgressMonitor monitor = new NullProgressMonitor();
         Integer process21 = 21;
index f1be7084f17faae35febbe13acf5914f1e02ddab..9617287c24ac422a91f95ba6d3f61f8435fe5bf4 100644 (file)
@@ -22,7 +22,7 @@ import java.io.File;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.ThreadPriorityAspect;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelTidAspect;
 import org.eclipse.tracecompass.analysis.os.linux.core.tests.Activator;
@@ -105,7 +105,7 @@ public class KernelTidAspectTest {
         /* Make sure the Kernel analysis has run */
         ((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
         IAnalysisModule module = null;
-        for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, KernelAnalysis.class)) {
+        for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, KernelAnalysisModule.class)) {
             module = mod;
         }
         assertNotNull(module);
index d0394f65926a0c69c028e8188163049734b16d61..0a76920665a3ae2579a41df5466d16a14b4fe5f7 100644 (file)
@@ -20,4 +20,4 @@ Export-Package: org.eclipse.tracecompass.analysis.os.linux.core.cpuusage,
  org.eclipse.tracecompass.analysis.os.linux.core.model,
  org.eclipse.tracecompass.analysis.os.linux.core.trace,
  org.eclipse.tracecompass.internal.analysis.os.linux.core;x-internal:=true,
- org.eclipse.tracecompass.internal.analysis.os.linux.core.kernelanalysis;x-internal:=true
+ org.eclipse.tracecompass.internal.analysis.os.linux.core.kernelanalysis;x-friends:="org.eclipse.tracecompass.analysis.os.linux.core.tests"
index a28e5f2c489ecca96fded1e0ff3314299dc24031..46b9a6355e2fa2eaeb3939cb15c499416016d2d2 100644 (file)
@@ -4,7 +4,7 @@
    <extension
          point="org.eclipse.linuxtools.tmf.core.analysis">
       <module
-            analysis_module="org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis"
+            analysis_module="org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule"
             automatic="true"
             id="org.eclipse.tracecompass.analysis.os.linux.kernel"
             name="%analysis.linuxkernel">
index 1f271d621d36c314e17689c0715a236db7bc057f..7d713e68e474b118a57e4e2bd4fbb38ba9deeba2 100644 (file)
@@ -22,7 +22,7 @@ import java.util.Map.Entry;
 import java.util.Set;
 
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.Attributes;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
 import org.eclipse.tracecompass.internal.analysis.os.linux.core.Activator;
@@ -88,8 +88,8 @@ public class KernelCpuUsageAnalysis extends TmfStateSystemAnalysisModule {
          * This analysis depends on the LTTng kernel analysis, so it's added to
          * dependent modules.
          */
-        Iterable<KernelAnalysis> kernelModules = TmfTraceUtils.getAnalysisModulesOfClass(trace, KernelAnalysis.class);
-        for (KernelAnalysis kernelModule : kernelModules) {
+        Iterable<KernelAnalysisModule> kernelModules = TmfTraceUtils.getAnalysisModulesOfClass(trace, KernelAnalysisModule.class);
+        for (KernelAnalysisModule kernelModule : kernelModules) {
             /* Only add the first one we find, if there is one */
             modules.add(kernelModule);
             break;
@@ -115,7 +115,7 @@ public class KernelCpuUsageAnalysis extends TmfStateSystemAnalysisModule {
         if (trace == null || cpuSs == null) {
             return map;
         }
-        ITmfStateSystem kernelSs = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysis.ID);
+        ITmfStateSystem kernelSs = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysisModule.ID);
         if (kernelSs == null) {
             return map;
         }
diff --git a/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelAnalysis.java b/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelAnalysis.java
deleted file mode 100644 (file)
index 76ae871..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2015 École Polytechnique de Montréal
- *
- * 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
- *
- * Contributors:
- *   Geneviève Bastien - Initial API and implementation
- *   Mathieu Rail - Provide the requirements of the analysis
- *******************************************************************************/
-
-package org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis;
-
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
-import java.util.Collections;
-import java.util.Set;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.common.core.NonNullUtils;
-import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
-import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
-import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement;
-import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
-import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
-import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
-
-/**
- * State System Module for lttng kernel traces
- *
- * @author Geneviève Bastien
- */
-public class KernelAnalysis extends TmfStateSystemAnalysisModule {
-
-    /**
-     * The file name of the History Tree
-     */
-    public static final String HISTORY_TREE_FILE_NAME = "stateHistory.ht"; //$NON-NLS-1$
-
-    /** The ID of this analysis module */
-    public static final String ID = "org.eclipse.tracecompass.analysis.os.linux.kernel"; //$NON-NLS-1$
-
-    /*
-     * TODO: Decide which events should be mandatory for the analysis, once the
-     * appropriate error messages and session setup are in place.
-     */
-//    private static final ImmutableSet<String> REQUIRED_EVENTS = ImmutableSet.of();
-//
-//    private static final ImmutableSet<String> OPTIONAL_EVENTS = ImmutableSet.of(
-            // FIXME These cannot be declared statically anymore, they depend on
-            // the OriginTracer of the kernel trace.
-            // LttngStrings.EXIT_SYSCALL,
-            // LttngStrings.IRQ_HANDLER_ENTRY,
-            // LttngStrings.IRQ_HANDLER_EXIT,
-            // LttngStrings.SOFTIRQ_ENTRY,
-            // LttngStrings.SOFTIRQ_EXIT,
-            // LttngStrings.SOFTIRQ_RAISE,
-            // LttngStrings.SCHED_PROCESS_FORK,
-            // LttngStrings.SCHED_PROCESS_EXIT,
-            // LttngStrings.SCHED_PROCESS_FREE,
-            // LttngStrings.SCHED_SWITCH,
-            // LttngStrings.STATEDUMP_PROCESS_STATE,
-            // LttngStrings.SCHED_WAKEUP,
-            // LttngStrings.SCHED_WAKEUP_NEW,
-            //
-            // /* FIXME Add the prefix for syscalls */
-            // LttngStrings.SYSCALL_PREFIX
-            // );
-
-    /** The requirements as an immutable set */
-    private static final Set<TmfAnalysisRequirement> REQUIREMENTS;
-
-    static {
-//        /* initialize the requirement: domain and events */
-//        TmfAnalysisRequirement domainReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_DOMAIN);
-//        domainReq.addValue(SessionConfigStrings.CONFIG_DOMAIN_TYPE_KERNEL, ValuePriorityLevel.MANDATORY);
-//
-//        TmfAnalysisRequirement eventReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_EVENT, REQUIRED_EVENTS, ValuePriorityLevel.MANDATORY);
-//        eventReq.addValues(OPTIONAL_EVENTS, ValuePriorityLevel.OPTIONAL);
-//
-//        REQUIREMENTS = checkNotNull(ImmutableSet.of(domainReq, eventReq));
-        REQUIREMENTS = checkNotNull(Collections.EMPTY_SET);
-    }
-
-    @Override
-    protected @NonNull ITmfStateProvider createStateProvider() {
-        ITmfTrace trace = checkNotNull(getTrace());
-        IKernelAnalysisEventLayout layout;
-
-        if (trace instanceof IKernelTrace) {
-            layout = ((IKernelTrace) trace).getKernelEventLayout();
-        } else {
-            /* Fall-back to the base LttngEventLayout */
-            layout = IKernelAnalysisEventLayout.DEFAULT_LAYOUT;
-        }
-
-        return new KernelStateProvider(trace, layout);
-    }
-
-    @Override
-    @NonNull
-    protected String getSsFileName() {
-        return HISTORY_TREE_FILE_NAME;
-    }
-
-    @Override
-    protected String getFullHelpText() {
-        return NonNullUtils.nullToEmptyString(Messages.LttngKernelAnalysisModule_Help);
-    }
-
-    @Override
-    public Iterable<TmfAnalysisRequirement> getAnalysisRequirements() {
-        return REQUIREMENTS;
-    }
-}
diff --git a/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelAnalysisModule.java b/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelAnalysisModule.java
new file mode 100644 (file)
index 0000000..984a330
--- /dev/null
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2015 École Polytechnique de Montréal
+ *
+ * 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
+ *
+ * Contributors:
+ *   Geneviève Bastien - Initial API and implementation
+ *   Mathieu Rail - Provide the requirements of the analysis
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis;
+
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
+import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernelanalysis.KernelStateProvider;
+import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
+import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
+import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement;
+import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
+import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+
+/**
+ * State System Module for lttng kernel traces
+ *
+ * @author Geneviève Bastien
+ * @since 1.0
+ */
+public class KernelAnalysisModule extends TmfStateSystemAnalysisModule {
+
+    /**
+     * The file name of the History Tree
+     */
+    public static final String HISTORY_TREE_FILE_NAME = "stateHistory.ht"; //$NON-NLS-1$
+
+    /** The ID of this analysis module */
+    public static final String ID = "org.eclipse.tracecompass.analysis.os.linux.kernel"; //$NON-NLS-1$
+
+    /*
+     * TODO: Decide which events should be mandatory for the analysis, once the
+     * appropriate error messages and session setup are in place.
+     */
+//    private static final ImmutableSet<String> REQUIRED_EVENTS = ImmutableSet.of();
+//
+//    private static final ImmutableSet<String> OPTIONAL_EVENTS = ImmutableSet.of(
+            // FIXME These cannot be declared statically anymore, they depend on
+            // the OriginTracer of the kernel trace.
+            // LttngStrings.EXIT_SYSCALL,
+            // LttngStrings.IRQ_HANDLER_ENTRY,
+            // LttngStrings.IRQ_HANDLER_EXIT,
+            // LttngStrings.SOFTIRQ_ENTRY,
+            // LttngStrings.SOFTIRQ_EXIT,
+            // LttngStrings.SOFTIRQ_RAISE,
+            // LttngStrings.SCHED_PROCESS_FORK,
+            // LttngStrings.SCHED_PROCESS_EXIT,
+            // LttngStrings.SCHED_PROCESS_FREE,
+            // LttngStrings.SCHED_SWITCH,
+            // LttngStrings.STATEDUMP_PROCESS_STATE,
+            // LttngStrings.SCHED_WAKEUP,
+            // LttngStrings.SCHED_WAKEUP_NEW,
+            //
+            // /* FIXME Add the prefix for syscalls */
+            // LttngStrings.SYSCALL_PREFIX
+            // );
+
+    /** The requirements as an immutable set */
+    private static final Set<TmfAnalysisRequirement> REQUIREMENTS;
+
+    static {
+//        /* initialize the requirement: domain and events */
+//        TmfAnalysisRequirement domainReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_DOMAIN);
+//        domainReq.addValue(SessionConfigStrings.CONFIG_DOMAIN_TYPE_KERNEL, ValuePriorityLevel.MANDATORY);
+//
+//        TmfAnalysisRequirement eventReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_EVENT, REQUIRED_EVENTS, ValuePriorityLevel.MANDATORY);
+//        eventReq.addValues(OPTIONAL_EVENTS, ValuePriorityLevel.OPTIONAL);
+//
+//        REQUIREMENTS = checkNotNull(ImmutableSet.of(domainReq, eventReq));
+        REQUIREMENTS = checkNotNull(Collections.EMPTY_SET);
+    }
+
+    @Override
+    protected @NonNull ITmfStateProvider createStateProvider() {
+        ITmfTrace trace = checkNotNull(getTrace());
+        IKernelAnalysisEventLayout layout;
+
+        if (trace instanceof IKernelTrace) {
+            layout = ((IKernelTrace) trace).getKernelEventLayout();
+        } else {
+            /* Fall-back to the base LttngEventLayout */
+            layout = IKernelAnalysisEventLayout.DEFAULT_LAYOUT;
+        }
+
+        return new KernelStateProvider(trace, layout);
+    }
+
+    @Override
+    @NonNull
+    protected String getSsFileName() {
+        return HISTORY_TREE_FILE_NAME;
+    }
+
+    @Override
+    protected String getFullHelpText() {
+        return NonNullUtils.nullToEmptyString(Messages.LttngKernelAnalysisModule_Help);
+    }
+
+    @Override
+    public Iterable<TmfAnalysisRequirement> getAnalysisRequirements() {
+        return REQUIREMENTS;
+    }
+}
diff --git a/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelStateProvider.java b/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelStateProvider.java
deleted file mode 100644 (file)
index a8eddb2..0000000
+++ /dev/null
@@ -1,647 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2015 Ericsson
- * Copyright (c) 2010, 2011 École Polytechnique de Montréal
- * Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
- *
- * 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.kernelanalysis;
-
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
-import java.util.Map;
-
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
-import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernelanalysis.LinuxValues;
-import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
-import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
-import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
-import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
-import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
-import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
-import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
-import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
-import org.eclipse.tracecompass.tmf.core.event.aspect.TmfCpuAspect;
-import org.eclipse.tracecompass.tmf.core.statesystem.AbstractTmfStateProvider;
-import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
-import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- * This is the state change input plugin for TMF's state system which handles
- * the LTTng 2.0 kernel traces in CTF format.
- *
- * It uses the reference handler defined in CTFKernelHandler.java.
- *
- * @author alexmont
- *
- */
-public class KernelStateProvider extends AbstractTmfStateProvider {
-
-    // ------------------------------------------------------------------------
-    // Static fields
-    // ------------------------------------------------------------------------
-
-    /**
-     * Version number of this state provider. Please bump this if you modify the
-     * contents of the generated state history in some way.
-     */
-    private static final int VERSION = 7;
-
-    private static final int IRQ_HANDLER_ENTRY_INDEX = 1;
-    private static final int IRQ_HANDLER_EXIT_INDEX = 2;
-    private static final int SOFT_IRQ_ENTRY_INDEX = 3;
-    private static final int SOFT_IRQ_EXIT_INDEX = 4;
-    private static final int SOFT_IRQ_RAISE_INDEX = 5;
-    private static final int SCHED_SWITCH_INDEX = 6;
-    private static final int SCHED_PROCESS_FORK_INDEX = 7;
-    private static final int SCHED_PROCESS_EXIT_INDEX = 8;
-    private static final int SCHED_PROCESS_FREE_INDEX = 9;
-    private static final int STATEDUMP_PROCESS_STATE_INDEX = 10;
-    private static final int SCHED_WAKEUP_INDEX = 11;
-    private static final int SCHED_PI_SETPRIO_INDEX = 12;
-
-
-    // ------------------------------------------------------------------------
-    // Fields
-    // ------------------------------------------------------------------------
-
-    private final Map<String, Integer> fEventNames;
-    private final IKernelAnalysisEventLayout fLayout;
-
-    // ------------------------------------------------------------------------
-    // Constructor
-    // ------------------------------------------------------------------------
-
-    /**
-     * Instantiate a new state provider plugin.
-     *
-     * @param trace
-     *            The LTTng 2.0 kernel trace directory
-     * @param layout
-     *            The event layout to use for this state provider. Usually
-     *            depending on the tracer implementation.
-     */
-    public KernelStateProvider(ITmfTrace trace, IKernelAnalysisEventLayout layout) {
-        super(trace, "Kernel"); //$NON-NLS-1$
-        fLayout = layout;
-        fEventNames = buildEventNames(layout);
-    }
-
-    // ------------------------------------------------------------------------
-    // Event names management
-    // ------------------------------------------------------------------------
-
-    private static Map<String, Integer> buildEventNames(IKernelAnalysisEventLayout layout) {
-        ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder();
-
-        builder.put(layout.eventIrqHandlerEntry(), IRQ_HANDLER_ENTRY_INDEX);
-        builder.put(layout.eventIrqHandlerExit(), IRQ_HANDLER_EXIT_INDEX);
-        builder.put(layout.eventSoftIrqEntry(), SOFT_IRQ_ENTRY_INDEX);
-        builder.put(layout.eventSoftIrqExit(), SOFT_IRQ_EXIT_INDEX);
-        builder.put(layout.eventSoftIrqRaise(), SOFT_IRQ_RAISE_INDEX);
-        builder.put(layout.eventSchedSwitch(), SCHED_SWITCH_INDEX);
-        builder.put(layout.eventSchedPiSetprio(), SCHED_PI_SETPRIO_INDEX);
-        builder.put(layout.eventSchedProcessFork(), SCHED_PROCESS_FORK_INDEX);
-        builder.put(layout.eventSchedProcessExit(), SCHED_PROCESS_EXIT_INDEX);
-        builder.put(layout.eventSchedProcessFree(), SCHED_PROCESS_FREE_INDEX);
-
-        final String eventStatedumpProcessState = layout.eventStatedumpProcessState();
-        if (eventStatedumpProcessState != null) {
-            builder.put(eventStatedumpProcessState, STATEDUMP_PROCESS_STATE_INDEX);
-        }
-
-        for (String eventSchedWakeup : layout.eventsSchedWakeup()) {
-            builder.put(eventSchedWakeup, SCHED_WAKEUP_INDEX);
-        }
-
-        return checkNotNull(builder.build());
-    }
-
-    // ------------------------------------------------------------------------
-    // IStateChangeInput
-    // ------------------------------------------------------------------------
-
-    @Override
-    public int getVersion() {
-        return VERSION;
-    }
-
-    @Override
-    public void assignTargetStateSystem(ITmfStateSystemBuilder ssb) {
-        /* We can only set up the locations once the state system is assigned */
-        super.assignTargetStateSystem(ssb);
-    }
-
-    @Override
-    public KernelStateProvider getNewInstance() {
-        return new KernelStateProvider(this.getTrace(), fLayout);
-    }
-
-    @Override
-    protected void eventHandle(@Nullable ITmfEvent event) {
-        if (event == null) {
-            return;
-        }
-
-        Object cpuObj = TmfTraceUtils.resolveEventAspectOfClassForEvent(event.getTrace(), TmfCpuAspect.class, event);
-        if (cpuObj == null) {
-            /* We couldn't find any CPU information, ignore this event */
-            return;
-        }
-        Integer cpu = (Integer) cpuObj;
-
-        final String eventName = event.getName();
-        final long ts = event.getTimestamp().getValue();
-
-        try {
-            final ITmfStateSystemBuilder ss = checkNotNull(getStateSystemBuilder());
-
-            /* Shortcut for the "current CPU" attribute node */
-            final int currentCPUNode = ss.getQuarkRelativeAndAdd(getNodeCPUs(ss), cpu.toString());
-
-            /*
-             * Shortcut for the "current thread" attribute node. It requires
-             * querying the current CPU's current thread.
-             */
-            int quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.CURRENT_THREAD);
-            ITmfStateValue value = ss.queryOngoingState(quark);
-            int thread = value.isNull() ? -1 : value.unboxInt();
-            final int currentThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), String.valueOf(thread));
-
-            /*
-             * Feed event to the history system if it's known to cause a state
-             * transition.
-             */
-            Integer idx = fEventNames.get(eventName);
-            int intval = (idx == null ? -1 : idx.intValue());
-            switch (intval) {
-
-            case IRQ_HANDLER_ENTRY_INDEX:
-            {
-                Integer irqId = ((Long) event.getContent().getField(fLayout.fieldIrq()).getValue()).intValue();
-
-                /* Mark this IRQ as active in the resource tree.
-                 * The state value = the CPU on which this IRQ is sitting */
-                quark = ss.getQuarkRelativeAndAdd(getNodeIRQs(ss), irqId.toString());
-                value = TmfStateValue.newValueInt(cpu.intValue());
-                ss.modifyAttribute(ts, value, quark);
-
-                /* Change the status of the running process to interrupted */
-                quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
-                value = StateValues.PROCESS_STATUS_INTERRUPTED_VALUE;
-                ss.modifyAttribute(ts, value, quark);
-
-                /* Change the status of the CPU to interrupted */
-                quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
-                value = StateValues.CPU_STATUS_IRQ_VALUE;
-                ss.modifyAttribute(ts, value, quark);
-            }
-                break;
-
-            case IRQ_HANDLER_EXIT_INDEX:
-            {
-                Integer irqId = ((Long) event.getContent().getField(fLayout.fieldIrq()).getValue()).intValue();
-
-                /* Put this IRQ back to inactive in the resource tree */
-                quark = ss.getQuarkRelativeAndAdd(getNodeIRQs(ss), irqId.toString());
-                value = TmfStateValue.nullValue();
-                ss.modifyAttribute(ts, value, quark);
-
-                /* Set the previous process back to running */
-                setProcessToRunning(ss, ts, currentThreadNode);
-
-                /* Set the CPU status back to running or "idle" */
-                cpuExitInterrupt(ss, ts, currentCPUNode, currentThreadNode);
-            }
-                break;
-
-            case SOFT_IRQ_ENTRY_INDEX:
-            {
-                Integer softIrqId = ((Long) event.getContent().getField(fLayout.fieldVec()).getValue()).intValue();
-
-                /* Mark this SoftIRQ as active in the resource tree.
-                 * The state value = the CPU on which this SoftIRQ is processed */
-                quark = ss.getQuarkRelativeAndAdd(getNodeSoftIRQs(ss), softIrqId.toString());
-                value = TmfStateValue.newValueInt(cpu.intValue());
-                ss.modifyAttribute(ts, value, quark);
-
-                /* Change the status of the running process to interrupted */
-                quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
-                value = StateValues.PROCESS_STATUS_INTERRUPTED_VALUE;
-                ss.modifyAttribute(ts, value, quark);
-
-                /* Change the status of the CPU to interrupted */
-                quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
-                value = StateValues.CPU_STATUS_SOFTIRQ_VALUE;
-                ss.modifyAttribute(ts, value, quark);
-            }
-                break;
-
-            case SOFT_IRQ_EXIT_INDEX:
-            {
-                Integer softIrqId = ((Long) event.getContent().getField(fLayout.fieldVec()).getValue()).intValue();
-
-                /* Put this SoftIRQ back to inactive (= -1) in the resource tree */
-                quark = ss.getQuarkRelativeAndAdd(getNodeSoftIRQs(ss), softIrqId.toString());
-                value = TmfStateValue.nullValue();
-                ss.modifyAttribute(ts, value, quark);
-
-                /* Set the previous process back to running */
-                setProcessToRunning(ss, ts, currentThreadNode);
-
-                /* Set the CPU status back to "busy" or "idle" */
-                cpuExitInterrupt(ss, ts, currentCPUNode, currentThreadNode);
-            }
-                break;
-
-            case SOFT_IRQ_RAISE_INDEX:
-            /* Fields: int32 vec */
-            {
-                Integer softIrqId = ((Long) event.getContent().getField(fLayout.fieldVec()).getValue()).intValue();
-
-                /* Mark this SoftIRQ as *raised* in the resource tree.
-                 * State value = -2 */
-                quark = ss.getQuarkRelativeAndAdd(getNodeSoftIRQs(ss), softIrqId.toString());
-                value = StateValues.SOFT_IRQ_RAISED_VALUE;
-                ss.modifyAttribute(ts, value, quark);
-            }
-                break;
-
-            case SCHED_SWITCH_INDEX:
-            {
-                ITmfEventField content = event.getContent();
-                Integer prevTid = ((Long) content.getField(fLayout.fieldPrevTid()).getValue()).intValue();
-                Long prevState = (Long) content.getField(fLayout.fieldPrevState()).getValue();
-                String nextProcessName = (String) content.getField(fLayout.fieldNextComm()).getValue();
-                Integer nextTid = ((Long) content.getField(fLayout.fieldNextTid()).getValue()).intValue();
-                Integer nextPrio = ((Long) content.getField(fLayout.fieldNextPrio()).getValue()).intValue();
-
-                Integer formerThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), prevTid.toString());
-                Integer newCurrentThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), nextTid.toString());
-
-                /* Set the status of the process that got scheduled out. */
-                quark = ss.getQuarkRelativeAndAdd(formerThreadNode, Attributes.STATUS);
-                if (prevState != 0) {
-                    value = StateValues.PROCESS_STATUS_WAIT_BLOCKED_VALUE;
-                } else {
-                    value = StateValues.PROCESS_STATUS_WAIT_FOR_CPU_VALUE;
-                }
-                ss.modifyAttribute(ts, value, quark);
-
-                /* Set the status of the new scheduled process */
-                setProcessToRunning(ss, ts, newCurrentThreadNode);
-
-                /* Set the exec name of the new process */
-                quark = ss.getQuarkRelativeAndAdd(newCurrentThreadNode, Attributes.EXEC_NAME);
-                value = TmfStateValue.newValueString(nextProcessName);
-                ss.modifyAttribute(ts, value, quark);
-
-                /* Set the current prio for the new process */
-                quark = ss.getQuarkRelativeAndAdd(newCurrentThreadNode, Attributes.PRIO);
-                value = TmfStateValue.newValueInt(nextPrio);
-                ss.modifyAttribute(ts, value, quark);
-
-                /* Make sure the PPID and system_call sub-attributes exist */
-                ss.getQuarkRelativeAndAdd(newCurrentThreadNode, Attributes.SYSTEM_CALL);
-                ss.getQuarkRelativeAndAdd(newCurrentThreadNode, Attributes.PPID);
-
-                /* Set the current scheduled process on the relevant CPU */
-                quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.CURRENT_THREAD);
-                value = TmfStateValue.newValueInt(nextTid);
-                ss.modifyAttribute(ts, value, quark);
-
-                /* Set the status of the CPU itself */
-                if (nextTid > 0) {
-                    /* Check if the entering process is in kernel or user mode */
-                    quark = ss.getQuarkRelativeAndAdd(newCurrentThreadNode, Attributes.SYSTEM_CALL);
-                    if (ss.queryOngoingState(quark).isNull()) {
-                        value = StateValues.CPU_STATUS_RUN_USERMODE_VALUE;
-                    } else {
-                        value = StateValues.CPU_STATUS_RUN_SYSCALL_VALUE;
-                    }
-                } else {
-                    value = StateValues.CPU_STATUS_IDLE_VALUE;
-                }
-                quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
-                ss.modifyAttribute(ts, value, quark);
-            }
-                break;
-
-            case SCHED_PI_SETPRIO_INDEX:
-            {
-                ITmfEventField content = event.getContent();
-                Integer tid = ((Long) content.getField(fLayout.fieldTid()).getValue()).intValue();
-                Integer prio = ((Long) content.getField(fLayout.fieldNewPrio()).getValue()).intValue();
-
-                Integer updateThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), tid.toString());
-
-                /* Set the current prio for the new process */
-                quark = ss.getQuarkRelativeAndAdd(updateThreadNode, Attributes.PRIO);
-                value = TmfStateValue.newValueInt(prio);
-                ss.modifyAttribute(ts, value, quark);
-            }
-                break;
-
-            case SCHED_PROCESS_FORK_INDEX:
-            {
-                ITmfEventField content = event.getContent();
-                // String parentProcessName = (String) event.getFieldValue("parent_comm");
-                String childProcessName = (String) content.getField(fLayout.fieldChildComm()).getValue();
-                // assert ( parentProcessName.equals(childProcessName) );
-
-                Integer parentTid = ((Long) content.getField(fLayout.fieldParentTid()).getValue()).intValue();
-                Integer childTid = ((Long) content.getField(fLayout.fieldChildTid()).getValue()).intValue();
-
-                Integer parentTidNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), parentTid.toString());
-                Integer childTidNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), childTid.toString());
-
-                /* Assign the PPID to the new process */
-                quark = ss.getQuarkRelativeAndAdd(childTidNode, Attributes.PPID);
-                value = TmfStateValue.newValueInt(parentTid);
-                ss.modifyAttribute(ts, value, quark);
-
-                /* Set the new process' exec_name */
-                quark = ss.getQuarkRelativeAndAdd(childTidNode, Attributes.EXEC_NAME);
-                value = TmfStateValue.newValueString(childProcessName);
-                ss.modifyAttribute(ts, value, quark);
-
-                /* Set the new process' status */
-                quark = ss.getQuarkRelativeAndAdd(childTidNode, Attributes.STATUS);
-                value = StateValues.PROCESS_STATUS_WAIT_FOR_CPU_VALUE;
-                ss.modifyAttribute(ts, value, quark);
-
-                /* Set the process' syscall name, to be the same as the parent's */
-                quark = ss.getQuarkRelativeAndAdd(parentTidNode, Attributes.SYSTEM_CALL);
-                value = ss.queryOngoingState(quark);
-                if (value.isNull()) {
-                    /*
-                     * Maybe we were missing info about the parent? At least we
-                     * will set the child right. Let's suppose "sys_clone".
-                     */
-                    value = TmfStateValue.newValueString(fLayout.eventSyscallEntryPrefix() + IKernelAnalysisEventLayout.INITIAL_SYSCALL_NAME);
-                }
-                quark = ss.getQuarkRelativeAndAdd(childTidNode, Attributes.SYSTEM_CALL);
-                ss.modifyAttribute(ts, value, quark);
-            }
-                break;
-
-            case SCHED_PROCESS_EXIT_INDEX:
-                break;
-
-            case SCHED_PROCESS_FREE_INDEX:
-            {
-                Integer tid = ((Long) event.getContent().getField(fLayout.fieldTid()).getValue()).intValue();
-                /*
-                 * Remove the process and all its sub-attributes from the
-                 * current state
-                 */
-                quark = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), tid.toString());
-                ss.removeAttribute(ts, quark);
-            }
-                break;
-
-            case STATEDUMP_PROCESS_STATE_INDEX:
-                /* LTTng-specific */
-            {
-                ITmfEventField content = event.getContent();
-                int tid = ((Long) content.getField("tid").getValue()).intValue(); //$NON-NLS-1$
-                int pid = ((Long) content.getField("pid").getValue()).intValue(); //$NON-NLS-1$
-                int ppid = ((Long) content.getField("ppid").getValue()).intValue(); //$NON-NLS-1$
-                int status = ((Long) content.getField("status").getValue()).intValue(); //$NON-NLS-1$
-                String name = (String) content.getField("name").getValue(); //$NON-NLS-1$
-                /*
-                 * "mode" could be interesting too, but it doesn't seem to be
-                 * populated with anything relevant for now.
-                 */
-
-                int curThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), String.valueOf(tid));
-
-                /* Set the process' name */
-                quark = ss.getQuarkRelativeAndAdd(curThreadNode, Attributes.EXEC_NAME);
-                if (ss.queryOngoingState(quark).isNull()) {
-                    /* If the value didn't exist previously, set it */
-                    value = TmfStateValue.newValueString(name);
-                    ss.modifyAttribute(ts, value, quark);
-                }
-
-                /* Set the process' PPID */
-                quark = ss.getQuarkRelativeAndAdd(curThreadNode, Attributes.PPID);
-                if (ss.queryOngoingState(quark).isNull()) {
-                    if (pid == tid) {
-                        /* We have a process. Use the 'PPID' field. */
-                        value = TmfStateValue.newValueInt(ppid);
-                    } else {
-                        /* We have a thread, use the 'PID' field for the parent. */
-                        value = TmfStateValue.newValueInt(pid);
-                    }
-                    ss.modifyAttribute(ts, value, quark);
-                }
-
-                /* Set the process' status */
-                quark = ss.getQuarkRelativeAndAdd(curThreadNode, Attributes.STATUS);
-                if (ss.queryOngoingState(quark).isNull()) {
-                    switch (status) {
-                    case LinuxValues.STATEDUMP_PROCESS_STATUS_WAIT_CPU:
-                        value = StateValues.PROCESS_STATUS_WAIT_FOR_CPU_VALUE;
-                        break;
-                    case LinuxValues.STATEDUMP_PROCESS_STATUS_WAIT:
-                        /*
-                         * We have no information on what the process is waiting
-                         * on (unlike a sched_switch for example), so we will
-                         * use the WAIT_UNKNOWN state instead of the "normal"
-                         * WAIT_BLOCKED state.
-                         */
-                        value = StateValues.PROCESS_STATUS_WAIT_UNKNOWN_VALUE;
-                        break;
-                    default:
-                        value = StateValues.PROCESS_STATUS_UNKNOWN_VALUE;
-                    }
-                    ss.modifyAttribute(ts, value, quark);
-                }
-            }
-                break;
-
-            case SCHED_WAKEUP_INDEX:
-            {
-                final int tid = ((Long) event.getContent().getField(fLayout.fieldTid()).getValue()).intValue();
-                final int prio = ((Long) event.getContent().getField(fLayout.fieldPrio()).getValue()).intValue();
-                final int threadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), String.valueOf(tid));
-
-                /*
-                 * The process indicated in the event's payload is now ready to
-                 * run. Assign it to the "wait for cpu" state, but only if it
-                 * was not already running.
-                 */
-                quark = ss.getQuarkRelativeAndAdd(threadNode, Attributes.STATUS);
-                int status = ss.queryOngoingState(quark).unboxInt();
-
-                if (status != StateValues.PROCESS_STATUS_RUN_SYSCALL &&
-                    status != StateValues.PROCESS_STATUS_RUN_USERMODE) {
-                    value = StateValues.PROCESS_STATUS_WAIT_FOR_CPU_VALUE;
-                    ss.modifyAttribute(ts, value, quark);
-                }
-
-                /*
-                 * When a user changes a threads prio (e.g. with pthread_setschedparam),
-                 * it shows in ftrace with a sched_wakeup.
-                 */
-                quark = ss.getQuarkRelativeAndAdd(threadNode, Attributes.PRIO);
-                value = TmfStateValue.newValueInt(prio);
-                ss.modifyAttribute(ts, value, quark);
-            }
-                break;
-
-            default:
-            /* Other event types not covered by the main switch */
-            {
-                if (eventName.startsWith(fLayout.eventSyscallEntryPrefix())
-                        || eventName.startsWith(fLayout.eventCompatSyscallEntryPrefix())) {
-
-                    /* Assign the new system call to the process */
-                    quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.SYSTEM_CALL);
-                    value = TmfStateValue.newValueString(eventName);
-                    ss.modifyAttribute(ts, value, quark);
-
-                    /* Put the process in system call mode */
-                    quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
-                    value = StateValues.PROCESS_STATUS_RUN_SYSCALL_VALUE;
-                    ss.modifyAttribute(ts, value, quark);
-
-                    /* Put the CPU in system call (kernel) mode */
-                    quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
-                    value = StateValues.CPU_STATUS_RUN_SYSCALL_VALUE;
-                    ss.modifyAttribute(ts, value, quark);
-
-                } else if (eventName.startsWith(fLayout.eventSyscallExitPrefix())) {
-
-                    /* Clear the current system call on the process */
-                    quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.SYSTEM_CALL);
-                    value = TmfStateValue.nullValue();
-                    ss.modifyAttribute(ts, value, quark);
-
-                    /* Put the process' status back to user mode */
-                    quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
-                    value = StateValues.PROCESS_STATUS_RUN_USERMODE_VALUE;
-                    ss.modifyAttribute(ts, value, quark);
-
-                    /* Put the CPU's status back to user mode */
-                    quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
-                    value = StateValues.CPU_STATUS_RUN_USERMODE_VALUE;
-                    ss.modifyAttribute(ts, value, quark);
-                }
-
-            }
-                break;
-            } // End of big switch
-
-        } catch (AttributeNotFoundException ae) {
-            /*
-             * This would indicate a problem with the logic of the manager here,
-             * so it shouldn't happen.
-             */
-            ae.printStackTrace();
-
-        } catch (TimeRangeException tre) {
-            /*
-             * This would happen if the events in the trace aren't ordered
-             * chronologically, which should never be the case ...
-             */
-            System.err.println("TimeRangeExcpetion caught in the state system's event manager."); //$NON-NLS-1$
-            System.err.println("Are the events in the trace correctly ordered?"); //$NON-NLS-1$
-            tre.printStackTrace();
-
-        } catch (StateValueTypeException sve) {
-            /*
-             * This would happen if we were trying to push/pop attributes not of
-             * type integer. Which, once again, should never happen.
-             */
-            sve.printStackTrace();
-        }
-    }
-
-    // ------------------------------------------------------------------------
-    // Convenience methods for commonly-used attribute tree locations
-    // ------------------------------------------------------------------------
-
-    private static int getNodeCPUs(ITmfStateSystemBuilder ssb) {
-        return ssb.getQuarkAbsoluteAndAdd(Attributes.CPUS);
-    }
-
-    private static int getNodeThreads(ITmfStateSystemBuilder ssb) {
-        return ssb.getQuarkAbsoluteAndAdd(Attributes.THREADS);
-    }
-
-    private static int getNodeIRQs(ITmfStateSystemBuilder ssb) {
-        return ssb.getQuarkAbsoluteAndAdd(Attributes.RESOURCES, Attributes.IRQS);
-    }
-
-    private static int getNodeSoftIRQs(ITmfStateSystemBuilder ssb) {
-        return ssb.getQuarkAbsoluteAndAdd(Attributes.RESOURCES, Attributes.SOFT_IRQS);
-    }
-
-    // ------------------------------------------------------------------------
-    // Advanced state-setting methods
-    // ------------------------------------------------------------------------
-
-    /**
-     * When we want to set a process back to a "running" state, first check
-     * its current System_call attribute. If there is a system call active, we
-     * put the process back in the syscall state. If not, we put it back in
-     * user mode state.
-     */
-    private static void setProcessToRunning(ITmfStateSystemBuilder ssb, long ts, int currentThreadNode)
-            throws AttributeNotFoundException, TimeRangeException,
-            StateValueTypeException {
-        int quark;
-        ITmfStateValue value;
-
-        quark = ssb.getQuarkRelativeAndAdd(currentThreadNode, Attributes.SYSTEM_CALL);
-        if (ssb.queryOngoingState(quark).isNull()) {
-            /* We were in user mode before the interruption */
-            value = StateValues.PROCESS_STATUS_RUN_USERMODE_VALUE;
-        } else {
-            /* We were previously in kernel mode */
-            value = StateValues.PROCESS_STATUS_RUN_SYSCALL_VALUE;
-        }
-        quark = ssb.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
-        ssb.modifyAttribute(ts, value, quark);
-    }
-
-    /**
-     * Similar logic as above, but to set the CPU's status when it's coming out
-     * of an interruption.
-     */
-    private static void cpuExitInterrupt(ITmfStateSystemBuilder ssb, long ts,
-            int currentCpuNode, int currentThreadNode)
-            throws StateValueTypeException, AttributeNotFoundException,
-            TimeRangeException {
-        int quark;
-        ITmfStateValue value;
-
-        quark = ssb.getQuarkRelativeAndAdd(currentCpuNode, Attributes.CURRENT_THREAD);
-        if (ssb.queryOngoingState(quark).unboxInt() > 0) {
-            /* There was a process on the CPU */
-            quark = ssb.getQuarkRelative(currentThreadNode, Attributes.SYSTEM_CALL);
-            if (ssb.queryOngoingState(quark).isNull()) {
-                /* That process was in user mode */
-                value = StateValues.CPU_STATUS_RUN_USERMODE_VALUE;
-            } else {
-                /* That process was in a system call */
-                value = StateValues.CPU_STATUS_RUN_SYSCALL_VALUE;
-            }
-        } else {
-            /* There was no real process scheduled, CPU was idle */
-            value = StateValues.CPU_STATUS_IDLE_VALUE;
-        }
-        quark = ssb.getQuarkRelativeAndAdd(currentCpuNode, Attributes.STATUS);
-        ssb.modifyAttribute(ts, value, quark);
-    }
-}
index 461481f73cff3e88ddbfb95a3fe53e401536659b..ab9692608f7c4b25051104d3a7875df109f926d1 100644 (file)
@@ -54,8 +54,9 @@ public final class KernelThreadInformationProvider {
      *            The timestamp at which we want the running process
      * @return The TID of the thread running on CPU cpuId at time ts or
      *         {@code null} if either no thread is running or we do not know.
+     * @since 1.0
      */
-    public static @Nullable Integer getThreadOnCpu(KernelAnalysis module, long cpuId, long ts) {
+    public static @Nullable Integer getThreadOnCpu(KernelAnalysisModule module, long cpuId, long ts) {
         ITmfStateSystem ss = module.getStateSystem();
         if (ss == null) {
             return null;
@@ -85,8 +86,9 @@ public final class KernelThreadInformationProvider {
      * @param module
      *            The lttng kernel analysis instance to run this method on
      * @return The set of TIDs corresponding to the threads
+     * @since 1.0
      */
-    public static Collection<Integer> getThreadIds(KernelAnalysis module) {
+    public static Collection<Integer> getThreadIds(KernelAnalysisModule module) {
         ITmfStateSystem ss = module.getStateSystem();
         if (ss == null) {
             return NonNullUtils.checkNotNull(Collections.EMPTY_SET);
@@ -114,8 +116,9 @@ public final class KernelThreadInformationProvider {
      * @param ts
      *            The timestamp at which to get the parent
      * @return The parent PID or {@code null} if the PPID is not found.
+     * @since 1.0
      */
-    public static @Nullable Integer getParentPid(KernelAnalysis module, Integer threadId, long ts) {
+    public static @Nullable Integer getParentPid(KernelAnalysisModule module, Integer threadId, long ts) {
         Integer ppid = null;
         ITmfStateSystem ss = module.getStateSystem();
         if (ss == null) {
@@ -154,8 +157,9 @@ public final class KernelThreadInformationProvider {
      *            The thread ID of the process for which to get the name
      * @return The last executable name of this process, or {@code null} if not
      *         found
+     * @since 1.0
      */
-    public static @Nullable String getExecutableName(KernelAnalysis module, Integer threadId) {
+    public static @Nullable String getExecutableName(KernelAnalysisModule module, Integer threadId) {
         String execName = null;
         ITmfStateSystem ss = module.getStateSystem();
         if (ss == null) {
@@ -198,7 +202,7 @@ public final class KernelThreadInformationProvider {
      * @return The priority of this thread, or {@code null} if not found
      * @since 1.0
      */
-    public static @Nullable Integer getThreadPrio(KernelAnalysis module, Integer threadId, long ts) {
+    public static @Nullable Integer getThreadPrio(KernelAnalysisModule module, Integer threadId, long ts) {
         Integer execPrio = null;
         ITmfStateSystem ss = module.getStateSystem();
         if (ss == null) {
@@ -235,8 +239,9 @@ public final class KernelThreadInformationProvider {
      * @return The list of status intervals for this thread, an empty list is
      *         returned if either the state system is {@code null} or the quark
      *         is not found
+     * @since 1.0
      */
-    public static List<ITmfStateInterval> getStatusIntervalsForThread(KernelAnalysis module, Integer threadId, long start, long end, long resolution, IProgressMonitor monitor) {
+    public static List<ITmfStateInterval> getStatusIntervalsForThread(KernelAnalysisModule module, Integer threadId, long start, long end, long resolution, IProgressMonitor monitor) {
         ITmfStateSystem ss = module.getStateSystem();
         if (ss == null) {
             return NonNullUtils.checkNotNull(Collections.EMPTY_LIST);
index 72d8bfe4e097ef0d33e8d33a24bf09925572c902..d3197ff64584c4d1f3df1df9b380fa51b5470ce6 100644 (file)
@@ -20,7 +20,7 @@ import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
 
 /**
  * This aspect finds the ID of the thread running from this event using the
- * {@link KernelAnalysis}.
+ * {@link KernelAnalysisModule}.
  *
  * @author Geneviève Bastien
  * @since 1.0
@@ -44,8 +44,8 @@ public final class KernelTidAspect extends LinuxTidAspect {
         Integer cpu = (Integer) cpuObj;
 
         /* Find the analysis module for the trace */
-        KernelAnalysis analysis = TmfTraceUtils.getAnalysisModuleOfClass(event.getTrace(),
-                KernelAnalysis.class, KernelAnalysis.ID);
+        KernelAnalysisModule analysis = TmfTraceUtils.getAnalysisModuleOfClass(event.getTrace(),
+                KernelAnalysisModule.class, KernelAnalysisModule.ID);
         if (analysis == null) {
             return null;
         }
index 68452b10d76496ccddc1ca250bc86d274c21cb8c..087abb4fa059a427b9e6a2e701237040d2008d14 100644 (file)
@@ -20,7 +20,7 @@ import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
 
 /**
  * This aspect finds the priority of the thread running from this event using
- * the {@link KernelAnalysis}.
+ * the {@link KernelAnalysisModule}.
  *
  * @author Christian Mansky
  * @since 1.0
@@ -45,7 +45,7 @@ public final class ThreadPriorityAspect implements ITmfEventAspect {
 
     @Override
     public @Nullable Integer resolve(ITmfEvent event) {
-        KernelAnalysis kernelAnalysis = TmfTraceUtils.getAnalysisModuleOfClass(event.getTrace(), KernelAnalysis.class, KernelAnalysis.ID);
+        KernelAnalysisModule kernelAnalysis = TmfTraceUtils.getAnalysisModuleOfClass(event.getTrace(), KernelAnalysisModule.class, KernelAnalysisModule.ID);
         if (kernelAnalysis == null) {
             return null;
         }
diff --git a/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernelanalysis/KernelStateProvider.java b/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernelanalysis/KernelStateProvider.java
new file mode 100644 (file)
index 0000000..605e275
--- /dev/null
@@ -0,0 +1,649 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 2015 Ericsson
+ * Copyright (c) 2010, 2011 École Polytechnique de Montréal
+ * Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
+ *
+ * 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.internal.analysis.os.linux.core.kernelanalysis;
+
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
+import java.util.Map;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.Attributes;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.StateValues;
+import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
+import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernelanalysis.LinuxValues;
+import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
+import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
+import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
+import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
+import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
+import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
+import org.eclipse.tracecompass.tmf.core.event.aspect.TmfCpuAspect;
+import org.eclipse.tracecompass.tmf.core.statesystem.AbstractTmfStateProvider;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * This is the state change input plugin for TMF's state system which handles
+ * the LTTng 2.0 kernel traces in CTF format.
+ *
+ * It uses the reference handler defined in CTFKernelHandler.java.
+ *
+ * @author alexmont
+ *
+ */
+public class KernelStateProvider extends AbstractTmfStateProvider {
+
+    // ------------------------------------------------------------------------
+    // Static fields
+    // ------------------------------------------------------------------------
+
+    /**
+     * Version number of this state provider. Please bump this if you modify the
+     * contents of the generated state history in some way.
+     */
+    private static final int VERSION = 7;
+
+    private static final int IRQ_HANDLER_ENTRY_INDEX = 1;
+    private static final int IRQ_HANDLER_EXIT_INDEX = 2;
+    private static final int SOFT_IRQ_ENTRY_INDEX = 3;
+    private static final int SOFT_IRQ_EXIT_INDEX = 4;
+    private static final int SOFT_IRQ_RAISE_INDEX = 5;
+    private static final int SCHED_SWITCH_INDEX = 6;
+    private static final int SCHED_PROCESS_FORK_INDEX = 7;
+    private static final int SCHED_PROCESS_EXIT_INDEX = 8;
+    private static final int SCHED_PROCESS_FREE_INDEX = 9;
+    private static final int STATEDUMP_PROCESS_STATE_INDEX = 10;
+    private static final int SCHED_WAKEUP_INDEX = 11;
+    private static final int SCHED_PI_SETPRIO_INDEX = 12;
+
+
+    // ------------------------------------------------------------------------
+    // Fields
+    // ------------------------------------------------------------------------
+
+    private final Map<String, Integer> fEventNames;
+    private final IKernelAnalysisEventLayout fLayout;
+
+    // ------------------------------------------------------------------------
+    // Constructor
+    // ------------------------------------------------------------------------
+
+    /**
+     * Instantiate a new state provider plugin.
+     *
+     * @param trace
+     *            The LTTng 2.0 kernel trace directory
+     * @param layout
+     *            The event layout to use for this state provider. Usually
+     *            depending on the tracer implementation.
+     */
+    public KernelStateProvider(ITmfTrace trace, IKernelAnalysisEventLayout layout) {
+        super(trace, "Kernel"); //$NON-NLS-1$
+        fLayout = layout;
+        fEventNames = buildEventNames(layout);
+    }
+
+    // ------------------------------------------------------------------------
+    // Event names management
+    // ------------------------------------------------------------------------
+
+    private static Map<String, Integer> buildEventNames(IKernelAnalysisEventLayout layout) {
+        ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder();
+
+        builder.put(layout.eventIrqHandlerEntry(), IRQ_HANDLER_ENTRY_INDEX);
+        builder.put(layout.eventIrqHandlerExit(), IRQ_HANDLER_EXIT_INDEX);
+        builder.put(layout.eventSoftIrqEntry(), SOFT_IRQ_ENTRY_INDEX);
+        builder.put(layout.eventSoftIrqExit(), SOFT_IRQ_EXIT_INDEX);
+        builder.put(layout.eventSoftIrqRaise(), SOFT_IRQ_RAISE_INDEX);
+        builder.put(layout.eventSchedSwitch(), SCHED_SWITCH_INDEX);
+        builder.put(layout.eventSchedPiSetprio(), SCHED_PI_SETPRIO_INDEX);
+        builder.put(layout.eventSchedProcessFork(), SCHED_PROCESS_FORK_INDEX);
+        builder.put(layout.eventSchedProcessExit(), SCHED_PROCESS_EXIT_INDEX);
+        builder.put(layout.eventSchedProcessFree(), SCHED_PROCESS_FREE_INDEX);
+
+        final String eventStatedumpProcessState = layout.eventStatedumpProcessState();
+        if (eventStatedumpProcessState != null) {
+            builder.put(eventStatedumpProcessState, STATEDUMP_PROCESS_STATE_INDEX);
+        }
+
+        for (String eventSchedWakeup : layout.eventsSchedWakeup()) {
+            builder.put(eventSchedWakeup, SCHED_WAKEUP_INDEX);
+        }
+
+        return checkNotNull(builder.build());
+    }
+
+    // ------------------------------------------------------------------------
+    // IStateChangeInput
+    // ------------------------------------------------------------------------
+
+    @Override
+    public int getVersion() {
+        return VERSION;
+    }
+
+    @Override
+    public void assignTargetStateSystem(ITmfStateSystemBuilder ssb) {
+        /* We can only set up the locations once the state system is assigned */
+        super.assignTargetStateSystem(ssb);
+    }
+
+    @Override
+    public KernelStateProvider getNewInstance() {
+        return new KernelStateProvider(this.getTrace(), fLayout);
+    }
+
+    @Override
+    protected void eventHandle(@Nullable ITmfEvent event) {
+        if (event == null) {
+            return;
+        }
+
+        Object cpuObj = TmfTraceUtils.resolveEventAspectOfClassForEvent(event.getTrace(), TmfCpuAspect.class, event);
+        if (cpuObj == null) {
+            /* We couldn't find any CPU information, ignore this event */
+            return;
+        }
+        Integer cpu = (Integer) cpuObj;
+
+        final String eventName = event.getName();
+        final long ts = event.getTimestamp().getValue();
+
+        try {
+            final ITmfStateSystemBuilder ss = checkNotNull(getStateSystemBuilder());
+
+            /* Shortcut for the "current CPU" attribute node */
+            final int currentCPUNode = ss.getQuarkRelativeAndAdd(getNodeCPUs(ss), cpu.toString());
+
+            /*
+             * Shortcut for the "current thread" attribute node. It requires
+             * querying the current CPU's current thread.
+             */
+            int quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.CURRENT_THREAD);
+            ITmfStateValue value = ss.queryOngoingState(quark);
+            int thread = value.isNull() ? -1 : value.unboxInt();
+            final int currentThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), String.valueOf(thread));
+
+            /*
+             * Feed event to the history system if it's known to cause a state
+             * transition.
+             */
+            Integer idx = fEventNames.get(eventName);
+            int intval = (idx == null ? -1 : idx.intValue());
+            switch (intval) {
+
+            case IRQ_HANDLER_ENTRY_INDEX:
+            {
+                Integer irqId = ((Long) event.getContent().getField(fLayout.fieldIrq()).getValue()).intValue();
+
+                /* Mark this IRQ as active in the resource tree.
+                 * The state value = the CPU on which this IRQ is sitting */
+                quark = ss.getQuarkRelativeAndAdd(getNodeIRQs(ss), irqId.toString());
+                value = TmfStateValue.newValueInt(cpu.intValue());
+                ss.modifyAttribute(ts, value, quark);
+
+                /* Change the status of the running process to interrupted */
+                quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
+                value = StateValues.PROCESS_STATUS_INTERRUPTED_VALUE;
+                ss.modifyAttribute(ts, value, quark);
+
+                /* Change the status of the CPU to interrupted */
+                quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
+                value = StateValues.CPU_STATUS_IRQ_VALUE;
+                ss.modifyAttribute(ts, value, quark);
+            }
+                break;
+
+            case IRQ_HANDLER_EXIT_INDEX:
+            {
+                Integer irqId = ((Long) event.getContent().getField(fLayout.fieldIrq()).getValue()).intValue();
+
+                /* Put this IRQ back to inactive in the resource tree */
+                quark = ss.getQuarkRelativeAndAdd(getNodeIRQs(ss), irqId.toString());
+                value = TmfStateValue.nullValue();
+                ss.modifyAttribute(ts, value, quark);
+
+                /* Set the previous process back to running */
+                setProcessToRunning(ss, ts, currentThreadNode);
+
+                /* Set the CPU status back to running or "idle" */
+                cpuExitInterrupt(ss, ts, currentCPUNode, currentThreadNode);
+            }
+                break;
+
+            case SOFT_IRQ_ENTRY_INDEX:
+            {
+                Integer softIrqId = ((Long) event.getContent().getField(fLayout.fieldVec()).getValue()).intValue();
+
+                /* Mark this SoftIRQ as active in the resource tree.
+                 * The state value = the CPU on which this SoftIRQ is processed */
+                quark = ss.getQuarkRelativeAndAdd(getNodeSoftIRQs(ss), softIrqId.toString());
+                value = TmfStateValue.newValueInt(cpu.intValue());
+                ss.modifyAttribute(ts, value, quark);
+
+                /* Change the status of the running process to interrupted */
+                quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
+                value = StateValues.PROCESS_STATUS_INTERRUPTED_VALUE;
+                ss.modifyAttribute(ts, value, quark);
+
+                /* Change the status of the CPU to interrupted */
+                quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
+                value = StateValues.CPU_STATUS_SOFTIRQ_VALUE;
+                ss.modifyAttribute(ts, value, quark);
+            }
+                break;
+
+            case SOFT_IRQ_EXIT_INDEX:
+            {
+                Integer softIrqId = ((Long) event.getContent().getField(fLayout.fieldVec()).getValue()).intValue();
+
+                /* Put this SoftIRQ back to inactive (= -1) in the resource tree */
+                quark = ss.getQuarkRelativeAndAdd(getNodeSoftIRQs(ss), softIrqId.toString());
+                value = TmfStateValue.nullValue();
+                ss.modifyAttribute(ts, value, quark);
+
+                /* Set the previous process back to running */
+                setProcessToRunning(ss, ts, currentThreadNode);
+
+                /* Set the CPU status back to "busy" or "idle" */
+                cpuExitInterrupt(ss, ts, currentCPUNode, currentThreadNode);
+            }
+                break;
+
+            case SOFT_IRQ_RAISE_INDEX:
+            /* Fields: int32 vec */
+            {
+                Integer softIrqId = ((Long) event.getContent().getField(fLayout.fieldVec()).getValue()).intValue();
+
+                /* Mark this SoftIRQ as *raised* in the resource tree.
+                 * State value = -2 */
+                quark = ss.getQuarkRelativeAndAdd(getNodeSoftIRQs(ss), softIrqId.toString());
+                value = StateValues.SOFT_IRQ_RAISED_VALUE;
+                ss.modifyAttribute(ts, value, quark);
+            }
+                break;
+
+            case SCHED_SWITCH_INDEX:
+            {
+                ITmfEventField content = event.getContent();
+                Integer prevTid = ((Long) content.getField(fLayout.fieldPrevTid()).getValue()).intValue();
+                Long prevState = (Long) content.getField(fLayout.fieldPrevState()).getValue();
+                String nextProcessName = (String) content.getField(fLayout.fieldNextComm()).getValue();
+                Integer nextTid = ((Long) content.getField(fLayout.fieldNextTid()).getValue()).intValue();
+                Integer nextPrio = ((Long) content.getField(fLayout.fieldNextPrio()).getValue()).intValue();
+
+                Integer formerThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), prevTid.toString());
+                Integer newCurrentThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), nextTid.toString());
+
+                /* Set the status of the process that got scheduled out. */
+                quark = ss.getQuarkRelativeAndAdd(formerThreadNode, Attributes.STATUS);
+                if (prevState != 0) {
+                    value = StateValues.PROCESS_STATUS_WAIT_BLOCKED_VALUE;
+                } else {
+                    value = StateValues.PROCESS_STATUS_WAIT_FOR_CPU_VALUE;
+                }
+                ss.modifyAttribute(ts, value, quark);
+
+                /* Set the status of the new scheduled process */
+                setProcessToRunning(ss, ts, newCurrentThreadNode);
+
+                /* Set the exec name of the new process */
+                quark = ss.getQuarkRelativeAndAdd(newCurrentThreadNode, Attributes.EXEC_NAME);
+                value = TmfStateValue.newValueString(nextProcessName);
+                ss.modifyAttribute(ts, value, quark);
+
+                /* Set the current prio for the new process */
+                quark = ss.getQuarkRelativeAndAdd(newCurrentThreadNode, Attributes.PRIO);
+                value = TmfStateValue.newValueInt(nextPrio);
+                ss.modifyAttribute(ts, value, quark);
+
+                /* Make sure the PPID and system_call sub-attributes exist */
+                ss.getQuarkRelativeAndAdd(newCurrentThreadNode, Attributes.SYSTEM_CALL);
+                ss.getQuarkRelativeAndAdd(newCurrentThreadNode, Attributes.PPID);
+
+                /* Set the current scheduled process on the relevant CPU */
+                quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.CURRENT_THREAD);
+                value = TmfStateValue.newValueInt(nextTid);
+                ss.modifyAttribute(ts, value, quark);
+
+                /* Set the status of the CPU itself */
+                if (nextTid > 0) {
+                    /* Check if the entering process is in kernel or user mode */
+                    quark = ss.getQuarkRelativeAndAdd(newCurrentThreadNode, Attributes.SYSTEM_CALL);
+                    if (ss.queryOngoingState(quark).isNull()) {
+                        value = StateValues.CPU_STATUS_RUN_USERMODE_VALUE;
+                    } else {
+                        value = StateValues.CPU_STATUS_RUN_SYSCALL_VALUE;
+                    }
+                } else {
+                    value = StateValues.CPU_STATUS_IDLE_VALUE;
+                }
+                quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
+                ss.modifyAttribute(ts, value, quark);
+            }
+                break;
+
+            case SCHED_PI_SETPRIO_INDEX:
+            {
+                ITmfEventField content = event.getContent();
+                Integer tid = ((Long) content.getField(fLayout.fieldTid()).getValue()).intValue();
+                Integer prio = ((Long) content.getField(fLayout.fieldNewPrio()).getValue()).intValue();
+
+                Integer updateThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), tid.toString());
+
+                /* Set the current prio for the new process */
+                quark = ss.getQuarkRelativeAndAdd(updateThreadNode, Attributes.PRIO);
+                value = TmfStateValue.newValueInt(prio);
+                ss.modifyAttribute(ts, value, quark);
+            }
+                break;
+
+            case SCHED_PROCESS_FORK_INDEX:
+            {
+                ITmfEventField content = event.getContent();
+                // String parentProcessName = (String) event.getFieldValue("parent_comm");
+                String childProcessName = (String) content.getField(fLayout.fieldChildComm()).getValue();
+                // assert ( parentProcessName.equals(childProcessName) );
+
+                Integer parentTid = ((Long) content.getField(fLayout.fieldParentTid()).getValue()).intValue();
+                Integer childTid = ((Long) content.getField(fLayout.fieldChildTid()).getValue()).intValue();
+
+                Integer parentTidNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), parentTid.toString());
+                Integer childTidNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), childTid.toString());
+
+                /* Assign the PPID to the new process */
+                quark = ss.getQuarkRelativeAndAdd(childTidNode, Attributes.PPID);
+                value = TmfStateValue.newValueInt(parentTid);
+                ss.modifyAttribute(ts, value, quark);
+
+                /* Set the new process' exec_name */
+                quark = ss.getQuarkRelativeAndAdd(childTidNode, Attributes.EXEC_NAME);
+                value = TmfStateValue.newValueString(childProcessName);
+                ss.modifyAttribute(ts, value, quark);
+
+                /* Set the new process' status */
+                quark = ss.getQuarkRelativeAndAdd(childTidNode, Attributes.STATUS);
+                value = StateValues.PROCESS_STATUS_WAIT_FOR_CPU_VALUE;
+                ss.modifyAttribute(ts, value, quark);
+
+                /* Set the process' syscall name, to be the same as the parent's */
+                quark = ss.getQuarkRelativeAndAdd(parentTidNode, Attributes.SYSTEM_CALL);
+                value = ss.queryOngoingState(quark);
+                if (value.isNull()) {
+                    /*
+                     * Maybe we were missing info about the parent? At least we
+                     * will set the child right. Let's suppose "sys_clone".
+                     */
+                    value = TmfStateValue.newValueString(fLayout.eventSyscallEntryPrefix() + IKernelAnalysisEventLayout.INITIAL_SYSCALL_NAME);
+                }
+                quark = ss.getQuarkRelativeAndAdd(childTidNode, Attributes.SYSTEM_CALL);
+                ss.modifyAttribute(ts, value, quark);
+            }
+                break;
+
+            case SCHED_PROCESS_EXIT_INDEX:
+                break;
+
+            case SCHED_PROCESS_FREE_INDEX:
+            {
+                Integer tid = ((Long) event.getContent().getField(fLayout.fieldTid()).getValue()).intValue();
+                /*
+                 * Remove the process and all its sub-attributes from the
+                 * current state
+                 */
+                quark = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), tid.toString());
+                ss.removeAttribute(ts, quark);
+            }
+                break;
+
+            case STATEDUMP_PROCESS_STATE_INDEX:
+                /* LTTng-specific */
+            {
+                ITmfEventField content = event.getContent();
+                int tid = ((Long) content.getField("tid").getValue()).intValue(); //$NON-NLS-1$
+                int pid = ((Long) content.getField("pid").getValue()).intValue(); //$NON-NLS-1$
+                int ppid = ((Long) content.getField("ppid").getValue()).intValue(); //$NON-NLS-1$
+                int status = ((Long) content.getField("status").getValue()).intValue(); //$NON-NLS-1$
+                String name = (String) content.getField("name").getValue(); //$NON-NLS-1$
+                /*
+                 * "mode" could be interesting too, but it doesn't seem to be
+                 * populated with anything relevant for now.
+                 */
+
+                int curThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), String.valueOf(tid));
+
+                /* Set the process' name */
+                quark = ss.getQuarkRelativeAndAdd(curThreadNode, Attributes.EXEC_NAME);
+                if (ss.queryOngoingState(quark).isNull()) {
+                    /* If the value didn't exist previously, set it */
+                    value = TmfStateValue.newValueString(name);
+                    ss.modifyAttribute(ts, value, quark);
+                }
+
+                /* Set the process' PPID */
+                quark = ss.getQuarkRelativeAndAdd(curThreadNode, Attributes.PPID);
+                if (ss.queryOngoingState(quark).isNull()) {
+                    if (pid == tid) {
+                        /* We have a process. Use the 'PPID' field. */
+                        value = TmfStateValue.newValueInt(ppid);
+                    } else {
+                        /* We have a thread, use the 'PID' field for the parent. */
+                        value = TmfStateValue.newValueInt(pid);
+                    }
+                    ss.modifyAttribute(ts, value, quark);
+                }
+
+                /* Set the process' status */
+                quark = ss.getQuarkRelativeAndAdd(curThreadNode, Attributes.STATUS);
+                if (ss.queryOngoingState(quark).isNull()) {
+                    switch (status) {
+                    case LinuxValues.STATEDUMP_PROCESS_STATUS_WAIT_CPU:
+                        value = StateValues.PROCESS_STATUS_WAIT_FOR_CPU_VALUE;
+                        break;
+                    case LinuxValues.STATEDUMP_PROCESS_STATUS_WAIT:
+                        /*
+                         * We have no information on what the process is waiting
+                         * on (unlike a sched_switch for example), so we will
+                         * use the WAIT_UNKNOWN state instead of the "normal"
+                         * WAIT_BLOCKED state.
+                         */
+                        value = StateValues.PROCESS_STATUS_WAIT_UNKNOWN_VALUE;
+                        break;
+                    default:
+                        value = StateValues.PROCESS_STATUS_UNKNOWN_VALUE;
+                    }
+                    ss.modifyAttribute(ts, value, quark);
+                }
+            }
+                break;
+
+            case SCHED_WAKEUP_INDEX:
+            {
+                final int tid = ((Long) event.getContent().getField(fLayout.fieldTid()).getValue()).intValue();
+                final int prio = ((Long) event.getContent().getField(fLayout.fieldPrio()).getValue()).intValue();
+                final int threadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), String.valueOf(tid));
+
+                /*
+                 * The process indicated in the event's payload is now ready to
+                 * run. Assign it to the "wait for cpu" state, but only if it
+                 * was not already running.
+                 */
+                quark = ss.getQuarkRelativeAndAdd(threadNode, Attributes.STATUS);
+                int status = ss.queryOngoingState(quark).unboxInt();
+
+                if (status != StateValues.PROCESS_STATUS_RUN_SYSCALL &&
+                    status != StateValues.PROCESS_STATUS_RUN_USERMODE) {
+                    value = StateValues.PROCESS_STATUS_WAIT_FOR_CPU_VALUE;
+                    ss.modifyAttribute(ts, value, quark);
+                }
+
+                /*
+                 * When a user changes a threads prio (e.g. with pthread_setschedparam),
+                 * it shows in ftrace with a sched_wakeup.
+                 */
+                quark = ss.getQuarkRelativeAndAdd(threadNode, Attributes.PRIO);
+                value = TmfStateValue.newValueInt(prio);
+                ss.modifyAttribute(ts, value, quark);
+            }
+                break;
+
+            default:
+            /* Other event types not covered by the main switch */
+            {
+                if (eventName.startsWith(fLayout.eventSyscallEntryPrefix())
+                        || eventName.startsWith(fLayout.eventCompatSyscallEntryPrefix())) {
+
+                    /* Assign the new system call to the process */
+                    quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.SYSTEM_CALL);
+                    value = TmfStateValue.newValueString(eventName);
+                    ss.modifyAttribute(ts, value, quark);
+
+                    /* Put the process in system call mode */
+                    quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
+                    value = StateValues.PROCESS_STATUS_RUN_SYSCALL_VALUE;
+                    ss.modifyAttribute(ts, value, quark);
+
+                    /* Put the CPU in system call (kernel) mode */
+                    quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
+                    value = StateValues.CPU_STATUS_RUN_SYSCALL_VALUE;
+                    ss.modifyAttribute(ts, value, quark);
+
+                } else if (eventName.startsWith(fLayout.eventSyscallExitPrefix())) {
+
+                    /* Clear the current system call on the process */
+                    quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.SYSTEM_CALL);
+                    value = TmfStateValue.nullValue();
+                    ss.modifyAttribute(ts, value, quark);
+
+                    /* Put the process' status back to user mode */
+                    quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
+                    value = StateValues.PROCESS_STATUS_RUN_USERMODE_VALUE;
+                    ss.modifyAttribute(ts, value, quark);
+
+                    /* Put the CPU's status back to user mode */
+                    quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
+                    value = StateValues.CPU_STATUS_RUN_USERMODE_VALUE;
+                    ss.modifyAttribute(ts, value, quark);
+                }
+
+            }
+                break;
+            } // End of big switch
+
+        } catch (AttributeNotFoundException ae) {
+            /*
+             * This would indicate a problem with the logic of the manager here,
+             * so it shouldn't happen.
+             */
+            ae.printStackTrace();
+
+        } catch (TimeRangeException tre) {
+            /*
+             * This would happen if the events in the trace aren't ordered
+             * chronologically, which should never be the case ...
+             */
+            System.err.println("TimeRangeExcpetion caught in the state system's event manager."); //$NON-NLS-1$
+            System.err.println("Are the events in the trace correctly ordered?"); //$NON-NLS-1$
+            tre.printStackTrace();
+
+        } catch (StateValueTypeException sve) {
+            /*
+             * This would happen if we were trying to push/pop attributes not of
+             * type integer. Which, once again, should never happen.
+             */
+            sve.printStackTrace();
+        }
+    }
+
+    // ------------------------------------------------------------------------
+    // Convenience methods for commonly-used attribute tree locations
+    // ------------------------------------------------------------------------
+
+    private static int getNodeCPUs(ITmfStateSystemBuilder ssb) {
+        return ssb.getQuarkAbsoluteAndAdd(Attributes.CPUS);
+    }
+
+    private static int getNodeThreads(ITmfStateSystemBuilder ssb) {
+        return ssb.getQuarkAbsoluteAndAdd(Attributes.THREADS);
+    }
+
+    private static int getNodeIRQs(ITmfStateSystemBuilder ssb) {
+        return ssb.getQuarkAbsoluteAndAdd(Attributes.RESOURCES, Attributes.IRQS);
+    }
+
+    private static int getNodeSoftIRQs(ITmfStateSystemBuilder ssb) {
+        return ssb.getQuarkAbsoluteAndAdd(Attributes.RESOURCES, Attributes.SOFT_IRQS);
+    }
+
+    // ------------------------------------------------------------------------
+    // Advanced state-setting methods
+    // ------------------------------------------------------------------------
+
+    /**
+     * When we want to set a process back to a "running" state, first check
+     * its current System_call attribute. If there is a system call active, we
+     * put the process back in the syscall state. If not, we put it back in
+     * user mode state.
+     */
+    private static void setProcessToRunning(ITmfStateSystemBuilder ssb, long ts, int currentThreadNode)
+            throws AttributeNotFoundException, TimeRangeException,
+            StateValueTypeException {
+        int quark;
+        ITmfStateValue value;
+
+        quark = ssb.getQuarkRelativeAndAdd(currentThreadNode, Attributes.SYSTEM_CALL);
+        if (ssb.queryOngoingState(quark).isNull()) {
+            /* We were in user mode before the interruption */
+            value = StateValues.PROCESS_STATUS_RUN_USERMODE_VALUE;
+        } else {
+            /* We were previously in kernel mode */
+            value = StateValues.PROCESS_STATUS_RUN_SYSCALL_VALUE;
+        }
+        quark = ssb.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
+        ssb.modifyAttribute(ts, value, quark);
+    }
+
+    /**
+     * Similar logic as above, but to set the CPU's status when it's coming out
+     * of an interruption.
+     */
+    private static void cpuExitInterrupt(ITmfStateSystemBuilder ssb, long ts,
+            int currentCpuNode, int currentThreadNode)
+            throws StateValueTypeException, AttributeNotFoundException,
+            TimeRangeException {
+        int quark;
+        ITmfStateValue value;
+
+        quark = ssb.getQuarkRelativeAndAdd(currentCpuNode, Attributes.CURRENT_THREAD);
+        if (ssb.queryOngoingState(quark).unboxInt() > 0) {
+            /* There was a process on the CPU */
+            quark = ssb.getQuarkRelative(currentThreadNode, Attributes.SYSTEM_CALL);
+            if (ssb.queryOngoingState(quark).isNull()) {
+                /* That process was in user mode */
+                value = StateValues.CPU_STATUS_RUN_USERMODE_VALUE;
+            } else {
+                /* That process was in a system call */
+                value = StateValues.CPU_STATUS_RUN_SYSCALL_VALUE;
+            }
+        } else {
+            /* There was no real process scheduled, CPU was idle */
+            value = StateValues.CPU_STATUS_IDLE_VALUE;
+        }
+        quark = ssb.getQuarkRelativeAndAdd(currentCpuNode, Attributes.STATUS);
+        ssb.modifyAttribute(ts, value, quark);
+    }
+}
index 98dcdde48859df420178d261671ad7bcd15e5431..88c15fdb236141e7edd4e09cdad4e5ba20ffbba9 100644 (file)
@@ -12,8 +12,6 @@
 
 package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernelanalysis;
 
-import org.eclipse.jdt.annotation.NonNullByDefault;
-
 /**
  * Definitions of values used in the Linux kernel code.
  *
@@ -23,7 +21,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
  * @author Alexandre Montplaisir
  */
 @SuppressWarnings("javadoc")
-@NonNullByDefault
 public interface LinuxValues {
 
     /*
diff --git a/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernelanalysis/package-info.java b/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernelanalysis/package-info.java
new file mode 100644 (file)
index 0000000..685c8f2
--- /dev/null
@@ -0,0 +1,14 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ *    Ericsson - Initial API and implementation
+ *******************************************************************************/
+
+@org.eclipse.jdt.annotation.NonNullByDefault
+package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernelanalysis;
index 11a0fd773484a5cfb979aaa9e568e374d3394c51..626f274e28a50c2b239501de21622a0d51782c39 100644 (file)
             class="org.eclipse.tracecompass.tmf.ui.analysis.TmfAnalysisViewOutput"
             id="org.eclipse.tracecompass.analysis.os.linux.views.controlflow">
          <analysisModuleClass
-               class="org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis">
+               class="org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule">
          </analysisModuleClass>
       </output>
       <output
             class="org.eclipse.tracecompass.tmf.ui.analysis.TmfAnalysisViewOutput"
             id="org.eclipse.tracecompass.analysis.os.linux.views.resources">
          <analysisModuleClass
-               class="org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis">
+               class="org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule">
          </analysisModuleClass>
       </output>
       <output
index 9c930f7a42b397eb48ea48eacd21609132de6e09..2a9b420eee65e450a4e2b82589c9cc7a94bcce55 100644 (file)
@@ -13,7 +13,7 @@
 package org.eclipse.tracecompass.analysis.os.linux.ui.views.controlflow;
 
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.Attributes;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.StateValues;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
@@ -81,7 +81,7 @@ public class ControlFlowCheckActiveProvider implements ITimeGraphEntryActiveProv
             }
 
             ITmfTrace trace = cfe.getTrace();
-            ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysis.ID);
+            ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysisModule.ID);
             if (ssq != null) {
                 beginTS = Math.max(beginTS, ssq.getStartTime());
                 endTS = Math.min(endTS, ssq.getCurrentEndTime());
index dfb7b9b8b18e28b0f9dd25f3adb56bc595078c1a..f41911eed0bb4e1b3c19690857172ad51a634e72 100644 (file)
@@ -22,7 +22,7 @@ import org.eclipse.swt.graphics.GC;
 import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.Attributes;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.StateValues;
 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
@@ -140,7 +140,7 @@ public class ControlFlowPresentationProvider extends TimeGraphPresentationProvid
             return retMap;
         }
         ControlFlowEntry entry = (ControlFlowEntry) event.getEntry();
-        ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(entry.getTrace(), KernelAnalysis.ID);
+        ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(entry.getTrace(), KernelAnalysisModule.ID);
         if (ssq == null) {
             return retMap;
         }
@@ -200,7 +200,7 @@ public class ControlFlowPresentationProvider extends TimeGraphPresentationProvid
             return;
         }
         ControlFlowEntry entry = (ControlFlowEntry) event.getEntry();
-        ITmfStateSystem ss = TmfStateSystemAnalysisModule.getStateSystem(entry.getTrace(), KernelAnalysis.ID);
+        ITmfStateSystem ss = TmfStateSystemAnalysisModule.getStateSystem(entry.getTrace(), KernelAnalysisModule.ID);
         if (ss == null) {
             return;
         }
index 943baeb4d4ec079ee135731673ef96c5691598da..041ea93389a866ef66196220e837ccb94f884c9c 100644 (file)
@@ -30,7 +30,7 @@ import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.Attributes;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelThreadInformationProvider;
 import org.eclipse.tracecompass.internal.analysis.os.linux.ui.Activator;
 import org.eclipse.tracecompass.internal.analysis.os.linux.ui.Messages;
@@ -241,7 +241,7 @@ public class ControlFlowView extends AbstractTimeGraphView {
 
     @Override
     protected void buildEventList(final ITmfTrace trace, ITmfTrace parentTrace, IProgressMonitor monitor) {
-        ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysis.ID);
+        ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysisModule.ID);
         if (ssq == null) {
             return;
         }
@@ -391,7 +391,7 @@ public class ControlFlowView extends AbstractTimeGraphView {
 
     private void buildStatusEvents(ITmfTrace trace, ControlFlowEntry entry, @NonNull IProgressMonitor monitor, long start, long end) {
         if (start < entry.getEndTime() && end > entry.getStartTime()) {
-            ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(entry.getTrace(), KernelAnalysis.ID);
+            ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(entry.getTrace(), KernelAnalysisModule.ID);
             if (ssq == null) {
                 return;
             }
@@ -430,7 +430,7 @@ public class ControlFlowView extends AbstractTimeGraphView {
         if (realEnd <= realStart) {
             return null;
         }
-        KernelAnalysis kernelAnalysis = TmfTraceUtils.getAnalysisModuleOfClass(entry.getTrace(), KernelAnalysis.class, KernelAnalysis.ID);
+        KernelAnalysisModule kernelAnalysis = TmfTraceUtils.getAnalysisModuleOfClass(entry.getTrace(), KernelAnalysisModule.class, KernelAnalysisModule.ID);
         if (kernelAnalysis == null) {
 //        ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(entry.getTrace(), KernelAnalysis.ID);
 //        if (ssq == null) {
@@ -484,7 +484,7 @@ public class ControlFlowView extends AbstractTimeGraphView {
             if (trace == null) {
                 continue;
             }
-            ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysis.ID);
+            ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysisModule.ID);
             if (ssq == null) {
                 continue;
             }
@@ -540,7 +540,7 @@ public class ControlFlowView extends AbstractTimeGraphView {
             if (trace == null) {
                 continue;
             }
-            ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysis.ID);
+            ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysisModule.ID);
             if (ssq == null) {
                 continue;
             }
index 77297f53381feb135c9993caa0f16caa4f9f5720..ec51353a92ef4b51e0441505e636d322f69660ce 100644 (file)
@@ -27,7 +27,7 @@ import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.KernelCpuUsageAnalysis;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.Attributes;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
 import org.eclipse.tracecompass.statesystem.core.StateSystemUtils;
 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
@@ -270,7 +270,7 @@ public class CpuUsageComposite extends AbstractTmfTreeViewer {
         if (trace == null) {
             return tid;
         }
-        ITmfStateSystem kernelSs = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysis.ID);
+        ITmfStateSystem kernelSs = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysisModule.ID);
         if (kernelSs == null) {
             return tid;
         }
index d66ccbb1bb8c6f0d02a689dc90ab15fb5ae72c87..a0ac390572512768beaa28168701323a386fd24f 100644 (file)
@@ -23,7 +23,7 @@ import org.eclipse.swt.graphics.GC;
 import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.Attributes;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.StateValues;
 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
@@ -165,7 +165,7 @@ public class ResourcesPresentationProvider extends TimeGraphPresentationProvider
             ResourcesEntry entry = (ResourcesEntry) event.getEntry();
 
             if (tcEvent.hasValue()) {
-                ITmfStateSystem ss = TmfStateSystemAnalysisModule.getStateSystem(entry.getTrace(), KernelAnalysis.ID);
+                ITmfStateSystem ss = TmfStateSystemAnalysisModule.getStateSystem(entry.getTrace(), KernelAnalysisModule.ID);
                 if (ss == null) {
                     return retMap;
                 }
@@ -304,7 +304,7 @@ public class ResourcesPresentationProvider extends TimeGraphPresentationProvider
             return;
         }
 
-        ITmfStateSystem ss = TmfStateSystemAnalysisModule.getStateSystem(entry.getTrace(), KernelAnalysis.ID);
+        ITmfStateSystem ss = TmfStateSystemAnalysisModule.getStateSystem(entry.getTrace(), KernelAnalysisModule.ID);
         if (ss == null) {
             return;
         }
index 2a5ad56aa142a43dfdbe14e70e1fe29b2b687be9..1d5b9025057a44927270b37dd4319f91f3b6e7d7 100644 (file)
@@ -23,7 +23,7 @@ import java.util.Map;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.Attributes;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.analysis.os.linux.ui.views.resources.ResourcesEntry.Type;
 import org.eclipse.tracecompass.internal.analysis.os.linux.ui.Messages;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
@@ -97,7 +97,7 @@ public class ResourcesView extends AbstractTimeGraphView {
 
     @Override
     protected void buildEventList(ITmfTrace trace, ITmfTrace parentTrace, IProgressMonitor monitor) {
-        ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysis.ID);
+        ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysisModule.ID);
         if (ssq == null) {
             return;
         }
@@ -205,7 +205,7 @@ public class ResourcesView extends AbstractTimeGraphView {
             long startTime, long endTime, long resolution,
             IProgressMonitor monitor) {
         ResourcesEntry resourcesEntry = (ResourcesEntry) entry;
-        ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(resourcesEntry.getTrace(), KernelAnalysis.ID);
+        ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(resourcesEntry.getTrace(), KernelAnalysisModule.ID);
         if (ssq == null) {
             return null;
         }
index 400fef8ce9450f66e37245c0c5a13d1dfb6f38e6..3233ccebee89d099825f8a52a19399b8e38e5e76 100644 (file)
@@ -21,7 +21,7 @@ import java.io.File;
 import org.eclipse.test.performance.Dimension;
 import org.eclipse.test.performance.Performance;
 import org.eclipse.test.performance.PerformanceMeter;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace;
 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
@@ -65,7 +65,7 @@ public class AnalysisBenchmark {
         for (int i = 0; i < LOOP_COUNT; i++) {
             IAnalysisModule module = null;
             try (LttngKernelTrace trace = new LttngKernelTrace()) {
-                module = new KernelAnalysis();
+                module = new KernelAnalysisModule();
                 module.setId("test");
                 trace.initTrace(null, testTrace.getPath(), CtfTmfEvent.class);
                 module.setTrace(trace);
index 6e79b73b34fb4482bc7423aa1416ef7abf4048e0..6d6a69706159c40dca1b28dc665d40757dcd68b1 100644 (file)
@@ -23,7 +23,7 @@ import static org.junit.Assume.assumeTrue;
 import java.util.List;
 import java.util.Set;
 
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.lttng2.control.core.session.SessionConfigStrings;
 import org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
@@ -44,14 +44,14 @@ import org.junit.Test;
 import com.google.common.collect.ImmutableSet;
 
 /**
- * Test the {@link KernelAnalysis} class
+ * Test the {@link KernelAnalysisModule} class
  *
  * @author Geneviève Bastien
  */
 public class LttngKernelAnalysisTest {
 
     private LttngKernelTrace fTrace;
-    private KernelAnalysis fKernelAnalysisModule;
+    private KernelAnalysisModule fKernelAnalysisModule;
 
     /**
      * Class setup
@@ -66,7 +66,7 @@ public class LttngKernelAnalysisTest {
      */
     @Before
     public void setUp() {
-        fKernelAnalysisModule = new KernelAnalysis();
+        fKernelAnalysisModule = new KernelAnalysisModule();
         fTrace = new LttngKernelTrace();
         try {
             fTrace.initTrace(null, CtfTmfTestTrace.KERNEL.getPath(), CtfTmfEvent.class);
@@ -134,7 +134,7 @@ public class LttngKernelAnalysisTest {
     }
 
     /**
-     * Test for {@link KernelAnalysis#getAnalysisRequirements()}
+     * Test for {@link KernelAnalysisModule#getAnalysisRequirements()}
      *
      * FIXME Ignored for now because the analysis does not provide any
      * requirements (it doesn't look for particular event names anymore).
index b5874092b567296e45c3657e47e6fc7576084d93..a63ca7fba94dc190c580e5d379b93c00f187e2b0 100644 (file)
@@ -17,12 +17,10 @@ import java.io.FileWriter;
 import java.io.PrintWriter;
 import java.util.List;
 
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelStateProvider;
-import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.LttngEventLayout;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
 import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
-import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
 import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
 import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
@@ -62,12 +60,7 @@ public class GenerateTestValues {
                 PrintWriter writer = new PrintWriter(new FileWriter(logFile), true);) {
 
             /* Build and query the state system */
-            TmfStateSystemAnalysisModule module = new TmfStateSystemAnalysisModule() {
-                @Override
-                protected ITmfStateProvider createStateProvider() {
-                    return new KernelStateProvider(trace, LttngEventLayout.getInstance());
-                }
-
+            TmfStateSystemAnalysisModule module = new KernelAnalysisModule() {
                 @Override
                 protected String getSsFileName() {
                     return "test-values";
diff --git a/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/kernel/statesystem/LttngKernelStateProviderTest.java b/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/kernel/statesystem/LttngKernelStateProviderTest.java
deleted file mode 100644 (file)
index 8afb16d..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2015 Ericsson
- * Copyright (c) 2010, 2011 École Polytechnique de Montréal
- * Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
- *
- * 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.lttng2.kernel.core.tests.analysis.kernel.statesystem;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assume.assumeTrue;
-
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelStateProvider;
-import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.LttngEventLayout;
-import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
-import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Tests for the {@link KernelStateProvider}
- *
- * @author Alexandre Montplaisir
- */
-public class LttngKernelStateProviderTest {
-
-    private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.TRACE2;
-
-    private static ITmfStateProvider input;
-
-    /**
-     * Set-up.
-     */
-    @BeforeClass
-    public static void initialize() {
-        assumeTrue(testTrace.exists());
-        input = new KernelStateProvider(testTrace.getTrace(), LttngEventLayout.getInstance());
-    }
-
-    /**
-     * Test loading the state provider.
-     */
-    @Test
-    public void testOpening() {
-        long testStartTime;
-        testStartTime = input.getStartTime();
-        assertEquals(testStartTime, StateSystemTest.startTime);
-    }
-
-}
index beafb5e8a38a9d724c15cae00dde4615390f40ba..80b5fe8b06f9c14cdf8f38e2fad41520bf20bd15 100644 (file)
@@ -12,7 +12,6 @@
 
 package org.eclipse.tracecompass.lttng2.kernel.core.tests.analysis.kernel.statesystem;
 
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -21,12 +20,9 @@ import java.io.File;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelStateProvider;
-import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.LttngEventLayout;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
-import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
-import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
@@ -155,7 +151,7 @@ public class PartialStateSystemTest extends StateSystemTest {
     }
 
     @NonNullByDefault
-    private static class TestLttngKernelAnalysisModule extends TmfStateSystemAnalysisModule {
+    private static class TestLttngKernelAnalysisModule extends KernelAnalysisModule {
 
         private final String htFileName;
 
@@ -177,11 +173,6 @@ public class PartialStateSystemTest extends StateSystemTest {
             return super.setTrace(trace);
         }
 
-        @Override
-        protected ITmfStateProvider createStateProvider() {
-            return new KernelStateProvider(checkNotNull(getTrace()), LttngEventLayout.getInstance());
-        }
-
         @Override
         protected StateSystemBackendType getBackendType() {
             return StateSystemBackendType.PARTIAL;
index 9a9a8216b121fa2f4648a96388acd7dc8feb8d91..ad4f25c0d0bb14e8ad247d66e3053adda5e7df12 100644 (file)
@@ -13,7 +13,6 @@
 
 package org.eclipse.tracecompass.lttng2.kernel.core.tests.analysis.kernel.statesystem;
 
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -24,12 +23,9 @@ import java.io.File;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelStateProvider;
-import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.LttngEventLayout;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
-import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
-import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
@@ -152,7 +148,7 @@ public class StateSystemFullHistoryTest extends StateSystemTest {
     }
 
     @NonNullByDefault
-    private static class TestLttngKernelAnalysisModule extends TmfStateSystemAnalysisModule {
+    private static class TestLttngKernelAnalysisModule extends KernelAnalysisModule {
 
         private final String htFileName;
 
@@ -174,11 +170,6 @@ public class StateSystemFullHistoryTest extends StateSystemTest {
             return super.setTrace(trace);
         }
 
-        @Override
-        protected ITmfStateProvider createStateProvider() {
-            return new KernelStateProvider(checkNotNull(getTrace()), LttngEventLayout.getInstance());
-        }
-
         @Override
         protected StateSystemBackendType getBackendType() {
             return StateSystemBackendType.FULL;
index b525107f59ed6d9f04f9503529cfe3a9d447108b..1840a7a5adad34b7d4c0e9c1b142ec97089d107f 100644 (file)
 
 package org.eclipse.tracecompass.lttng2.kernel.core.tests.analysis.kernel.statesystem;
 
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelStateProvider;
-import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.LttngEventLayout;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
-import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
-import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
 import org.junit.AfterClass;
@@ -74,7 +70,7 @@ public class StateSystemInMemoryTest extends StateSystemTest {
         fixture = null;
     }
 
-    private static class TestLttngKernelAnalysisModule extends TmfStateSystemAnalysisModule {
+    private static class TestLttngKernelAnalysisModule extends KernelAnalysisModule {
 
         /**
          * Constructor adding the views to the analysis
@@ -91,11 +87,6 @@ public class StateSystemInMemoryTest extends StateSystemTest {
             return super.setTrace(trace);
         }
 
-        @Override
-        protected ITmfStateProvider createStateProvider() {
-            return new KernelStateProvider(checkNotNull(getTrace()), LttngEventLayout.getInstance());
-        }
-
         @Override
         protected StateSystemBackendType getBackendType() {
             return StateSystemBackendType.INMEM;
index e62b064c7c55ae015727a9016510ee29b8d000e1..0fe407d7a65cb2760671092691e8562afcc1fc03 100644 (file)
@@ -20,7 +20,6 @@ import org.junit.runners.Suite;
  */
 @RunWith(Suite.class)
 @Suite.SuiteClasses({
-    LttngKernelStateProviderTest.class,
     PartialStateSystemTest.class,
     StateSystemFullHistoryTest.class,
     StateSystemInMemoryTest.class
index 469b840e63078b518167eb7d423ef1fb4c8a74d5..499b14e0e5ed96eeb348e078f9acd09fb6fac334 100644 (file)
@@ -22,7 +22,7 @@ import java.util.Collection;
 import java.util.List;
 
 import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.vm.VcpuStateValues;
 import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.vm.VmAttributes;
 import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.vm.module.VirtualMachineCpuAnalysis;
@@ -98,7 +98,7 @@ public class VirtualMachineAnalysisTest {
          */
         for (ITmfTrace trace : experiment.getTraces()) {
             trace = checkNotNull(trace);
-            for (KernelAnalysis module : TmfTraceUtils.getAnalysisModulesOfClass(trace, KernelAnalysis.class)) {
+            for (KernelAnalysisModule module : TmfTraceUtils.getAnalysisModulesOfClass(trace, KernelAnalysisModule.class)) {
                 module.schedule();
                 module.waitForCompletion();
             }
index f641e41137029af0b15281f8d3a9ccd1125cb12b..c39cd65f87e26f4cac86dc81f2a999aa366234c2 100644 (file)
@@ -19,7 +19,7 @@ import java.util.Map.Entry;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelThreadInformationProvider;
 import org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread;
 import org.eclipse.tracecompass.common.core.NonNullUtils;
@@ -124,7 +124,7 @@ public class QemuKvmVmModel implements IVirtualMachineModel {
          * Maybe the parent of the current thread has a VM associated, see if we
          * can infer the VM for this thread
          */
-        KernelAnalysis module = getLttngKernelModuleFor(ht.getHost());
+        KernelAnalysisModule module = getLttngKernelModuleFor(ht.getHost());
         if (module == null) {
             return null;
         }
@@ -228,7 +228,7 @@ public class QemuKvmVmModel implements IVirtualMachineModel {
                  * We found the VM being run, let's associate it with the thread
                  * ID
                  */
-                KernelAnalysis module = getLttngKernelModuleFor(hostId);
+                KernelAnalysisModule module = getLttngKernelModuleFor(hostId);
                 if (module == null) {
                     break;
                 }
@@ -256,8 +256,8 @@ public class QemuKvmVmModel implements IVirtualMachineModel {
         }
     }
 
-    private @Nullable KernelAnalysis getLttngKernelModuleFor(String hostId) {
-        return TmfExperimentUtils.getAnalysisModuleOfClassForHost(fExperiment, hostId, KernelAnalysis.class);
+    private @Nullable KernelAnalysisModule getLttngKernelModuleFor(String hostId) {
+        return TmfExperimentUtils.getAnalysisModuleOfClassForHost(fExperiment, hostId, KernelAnalysisModule.class);
     }
 
 }
index 2a916375371eae037227596f0f2e02db33c7596f..6cc1155b8abdd8a61fdbdd89e00a7e8fa166444e 100644 (file)
@@ -22,7 +22,7 @@ import java.util.Set;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelThreadInformationProvider;
 import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.vm.VcpuStateValues;
@@ -97,7 +97,7 @@ public class VirtualMachineCpuAnalysis extends TmfStateSystemAnalysisModule {
         /* Depends on the LTTng Kernel analysis modules */
         for (ITmfTrace trace : TmfTraceManager.getTraceSet(getTrace())) {
             trace = checkNotNull(trace);
-            for (KernelAnalysis module : TmfTraceUtils.getAnalysisModulesOfClass(trace, KernelAnalysis.class)) {
+            for (KernelAnalysisModule module : TmfTraceUtils.getAnalysisModulesOfClass(trace, KernelAnalysisModule.class)) {
                 modules.add(module);
             }
         }
@@ -185,7 +185,7 @@ public class VirtualMachineCpuAnalysis extends TmfStateSystemAnalysisModule {
         }
 
         String vmHostId = NonNullUtils.checkNotNull(ss.getAttributeName(vmQuark));
-        KernelAnalysis kernelModule = TmfExperimentUtils.getAnalysisModuleOfClassForHost((TmfExperiment) trace, vmHostId, KernelAnalysis.class);
+        KernelAnalysisModule kernelModule = TmfExperimentUtils.getAnalysisModuleOfClassForHost((TmfExperiment) trace, vmHostId, KernelAnalysisModule.class);
         if (kernelModule == null) {
             return map;
         }
index b2a0a6da487709bd25490a9d2969263a6af66bae..0fc3c44d7d3824ed5c4d1d045d9b85f30b46e925 100644 (file)
@@ -18,7 +18,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelThreadInformationProvider;
 import org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread;
 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
@@ -346,7 +346,7 @@ public class VirtualMachineStateProvider extends AbstractTmfStateProvider {
     private @Nullable HostThread getCurrentHostThread(ITmfEvent event, long ts) {
         /* Get the LTTng kernel analysis for the host */
         String hostId = event.getTrace().getHostId();
-        KernelAnalysis module = TmfExperimentUtils.getAnalysisModuleOfClassForHost(getTrace(), hostId, KernelAnalysis.class);
+        KernelAnalysisModule module = TmfExperimentUtils.getAnalysisModuleOfClassForHost(getTrace(), hostId, KernelAnalysisModule.class);
         if (module == null) {
             return null;
         }
This page took 0.080543 seconds and 5 git commands to generate.