lttng: Add the dependency graph model and handlers for an LTTng kernel
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / internal / analysis / os / linux / core / kernelanalysis / KernelStateProvider.java
index e9e4cd771a582283135f3877a920942c5582b4f3..8eb5df45a5d2fc997dee40f9d306699595f1d8aa 100644 (file)
@@ -18,9 +18,9 @@ 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.LinuxValues;
 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;
@@ -55,7 +55,7 @@ public class KernelStateProvider extends AbstractTmfStateProvider {
      * 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 VERSION = 9;
 
     private static final int IRQ_HANDLER_ENTRY_INDEX = 1;
     private static final int IRQ_HANDLER_EXIT_INDEX = 2;
@@ -289,17 +289,32 @@ public class KernelStateProvider extends AbstractTmfStateProvider {
                 Integer formerThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), prevTid.toString());
                 Integer newCurrentThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(ss), nextTid.toString());
 
+                /*
+                 * Empirical observations and look into the linux code have
+                 * shown that the TASK_STATE_MAX flag is used internally and
+                 * |'ed with other states, most often the running state, so it
+                 * is ignored from the prevState value.
+                 */
+                prevState = prevState & ~(LinuxValues.TASK_STATE_MAX);
+
                 /* Set the status of the process that got scheduled out. */
-                quark = ss.getQuarkRelativeAndAdd(formerThreadNode, Attributes.STATUS);
-                if (prevState != 0) {
-                    if (prevState == LinuxValues.TASK_STATE_DEAD) {
-                        value = TmfStateValue.nullValue();
-                    } else {
-                        value = StateValues.PROCESS_STATUS_WAIT_BLOCKED_VALUE;
-                    }
-                } else {
+                switch (prevState.intValue()) {
+                case LinuxValues.TASK_STATE_RUNNING:
                     value = StateValues.PROCESS_STATUS_WAIT_FOR_CPU_VALUE;
+                    break;
+                case LinuxValues.TASK_INTERRUPTIBLE:
+                case LinuxValues.TASK_UNINTERRUPTIBLE:
+                    value = StateValues.PROCESS_STATUS_WAIT_BLOCKED_VALUE;
+                    break;
+                case LinuxValues.TASK_DEAD:
+                    value = TmfStateValue.nullValue();
+                    break;
+                default:
+                    value = StateValues.PROCESS_STATUS_WAIT_UNKNOWN_VALUE;
+                    break;
                 }
+
+                quark = ss.getQuarkRelativeAndAdd(formerThreadNode, Attributes.STATUS);
                 ss.modifyAttribute(ts, value, quark);
 
                 /* Set the status of the new scheduled process */
This page took 0.024485 seconds and 5 git commands to generate.