os.linux: Add Linux-specific static definitions
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 12 Mar 2015 18:31:24 +0000 (14:31 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 23 Mar 2015 17:55:32 +0000 (13:55 -0400)
And replace some magic numbers in KernelStateProvider with values
from this file.

It includes some LTTng-specific definitions, but since the statedump
events are handled in this plugin (and not in something lttng2.kernel)
it makes sense for now to put them there.

Change-Id: If47a13ca277a9da0220066b03024fca1f403beb4
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/43758
Reviewed-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
org.eclipse.tracecompass.analysis.os.linux.core/META-INF/MANIFEST.MF
org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelanalysis/KernelStateProvider.java
org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernelanalysis/LinuxValues.java [new file with mode: 0644]

index 5869d2e8552edac6271a010d1b5985ee88f393a2..d0394f65926a0c69c028e8188163049734b16d61 100644 (file)
@@ -19,4 +19,5 @@ Export-Package: org.eclipse.tracecompass.analysis.os.linux.core.cpuusage,
  org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis,
  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;x-internal:=true,
+ org.eclipse.tracecompass.internal.analysis.os.linux.core.kernelanalysis;x-internal:=true
index 2e5410b4622f4de98209b84a6d28765905522144..4e41d4141dbeffa2cee998e6339b113e82e678a8 100644 (file)
@@ -18,6 +18,7 @@ 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;
@@ -447,12 +448,17 @@ public class KernelStateProvider extends AbstractTmfStateProvider {
                 /* Set the process' status */
                 quark = ss.getQuarkRelativeAndAdd(curThreadNode, Attributes.STATUS);
                 if (ss.queryOngoingState(quark).isNull()) {
-                     /* "2" here means "WAIT_FOR_CPU", and "5" "WAIT_BLOCKED" in the Linux kernel. */
                     switch (status) {
-                    case 2:
+                    case LinuxValues.STATEDUMP_PROCESS_STATUS_WAIT_CPU:
                         value = StateValues.PROCESS_STATUS_WAIT_FOR_CPU_VALUE;
                         break;
-                    case 5:
+                    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:
diff --git a/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernelanalysis/LinuxValues.java b/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernelanalysis/LinuxValues.java
new file mode 100644 (file)
index 0000000..98dcdde
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
+ *
+ * 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:
+ *    Alexandre Montplaisir - Initial API and implementation
+ *******************************************************************************/
+
+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.
+ *
+ * Instead of using "magic numbers" in state providers, the definitions should
+ * be added here first.
+ *
+ * @author Alexandre Montplaisir
+ */
+@SuppressWarnings("javadoc")
+@NonNullByDefault
+public interface LinuxValues {
+
+    /*
+     * Process states found in scheduler events.
+     *
+     * From include/linux/sched.h
+     *
+     * #define TASK_RUNNING 0
+     * #define TASK_INTERRUPTIBLE 1
+     * #define TASK_UNINTERRUPTIBLE 2
+     * #define __TASK_STOPPED 4
+     * #define __TASK_TRACED 8
+     * #define EXIT_DEAD 16
+     * #define EXIT_ZOMBIE 32
+     * #define EXIT_TRACE (EXIT_ZOMBIE | EXIT_DEAD)
+     * #define TASK_DEAD 64
+     * #define TASK_WAKEKILL 128
+     * #define TASK_WAKING 256
+     * #define TASK_PARKED 512
+     * #define TASK_STATE_MAX 1024
+     */
+    int TASK_STATE_RUNNING = 0;
+    int TASK_STATE_MAX = 1024;
+
+    /*
+     * Process statuses, used in LTTng statedump events.
+     *
+     * This is LTTng-specific, but the statedump are handled at this level, so
+     * it makes sense to add those definitions here.
+     *
+     * Taken from lttng-module's lttng-statedump-impl.c:
+     *
+     * enum lttng_process_status {
+     *     LTTNG_UNNAMED = 0,
+     *     LTTNG_WAIT_FORK = 1,
+     *     LTTNG_WAIT_CPU = 2,
+     *     LTTNG_EXIT = 3,
+     *     LTTNG_ZOMBIE = 4,
+     *     LTTNG_WAIT = 5,
+     *     LTTNG_RUN = 6,
+     *     LTTNG_DEAD = 7,
+     * };
+     */
+    int STATEDUMP_PROCESS_STATUS_WAIT_CPU = 2;
+    int STATEDUMP_PROCESS_STATUS_WAIT = 5;
+}
This page took 0.028876 seconds and 5 git commands to generate.