From: Alexandre Montplaisir Date: Thu, 12 Mar 2015 18:31:24 +0000 (-0400) Subject: os.linux: Add Linux-specific static definitions X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=03bd936a2d760e40ee867771affb6a02b33985db;p=deliverable%2Ftracecompass.git os.linux: Add Linux-specific static definitions 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 Reviewed-on: https://git.eclipse.org/r/43758 Reviewed-by: Hudson CI Reviewed-by: Marc-Andre Laperle Tested-by: Marc-Andre Laperle --- diff --git a/org.eclipse.tracecompass.analysis.os.linux.core/META-INF/MANIFEST.MF b/org.eclipse.tracecompass.analysis.os.linux.core/META-INF/MANIFEST.MF index 5869d2e855..d0394f6592 100644 --- a/org.eclipse.tracecompass.analysis.os.linux.core/META-INF/MANIFEST.MF +++ b/org.eclipse.tracecompass.analysis.os.linux.core/META-INF/MANIFEST.MF @@ -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 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 index 2e5410b462..4e41d4141d 100644 --- 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 @@ -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 index 0000000000..98dcdde488 --- /dev/null +++ b/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernelanalysis/LinuxValues.java @@ -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; +}