</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">
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;
* 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);
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
- KernelThreadInformationProviderTest.class,
- KernelTidAspectTest.class
+ KernelStateProviderTest.class,
+ KernelThreadInformationProviderTest.class,
+ KernelTidAspectTest.class
})
public class AllTests {
--- /dev/null
+/*******************************************************************************
+ * 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);
+ }
+
+}
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;
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
*/
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 */
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;
}
/**
* 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);
/**
* 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);
}
/**
- * 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);
/**
* 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;
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;
/* 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);
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"
<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">
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;
* 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;
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;
}
+++ /dev/null
-/*******************************************************************************
- * 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;
- }
-}
--- /dev/null
+/*******************************************************************************
+ * 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;
+ }
+}
+++ /dev/null
-/*******************************************************************************
- * 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);
- }
-}
* 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;
* @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);
* @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) {
* 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) {
* @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) {
* @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);
/**
* 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
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;
}
/**
* 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
@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;
}
--- /dev/null
+/*******************************************************************************
+ * 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);
+ }
+}
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.
*
* @author Alexandre Montplaisir
*/
@SuppressWarnings("javadoc")
-@NonNullByDefault
public interface LinuxValues {
/*
--- /dev/null
+/*******************************************************************************
+ * 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;
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
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;
}
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());
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;
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;
}
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;
}
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;
@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;
}
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;
}
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) {
if (trace == null) {
continue;
}
- ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysis.ID);
+ ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysisModule.ID);
if (ssq == null) {
continue;
}
if (trace == null) {
continue;
}
- ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysis.ID);
+ ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysisModule.ID);
if (ssq == null) {
continue;
}
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;
if (trace == null) {
return tid;
}
- ITmfStateSystem kernelSs = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysis.ID);
+ ITmfStateSystem kernelSs = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysisModule.ID);
if (kernelSs == null) {
return tid;
}
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;
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;
}
return;
}
- ITmfStateSystem ss = TmfStateSystemAnalysisModule.getStateSystem(entry.getTrace(), KernelAnalysis.ID);
+ ITmfStateSystem ss = TmfStateSystemAnalysisModule.getStateSystem(entry.getTrace(), KernelAnalysisModule.ID);
if (ss == null) {
return;
}
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;
@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;
}
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;
}
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;
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);
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;
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
*/
@Before
public void setUp() {
- fKernelAnalysisModule = new KernelAnalysis();
+ fKernelAnalysisModule = new KernelAnalysisModule();
fTrace = new LttngKernelTrace();
try {
fTrace.initTrace(null, CtfTmfTestTrace.KERNEL.getPath(), CtfTmfEvent.class);
}
/**
- * 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).
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;
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";
+++ /dev/null
-/*******************************************************************************
- * 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);
- }
-
-}
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.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;
}
@NonNullByDefault
- private static class TestLttngKernelAnalysisModule extends TmfStateSystemAnalysisModule {
+ private static class TestLttngKernelAnalysisModule extends KernelAnalysisModule {
private final String htFileName;
return super.setTrace(trace);
}
- @Override
- protected ITmfStateProvider createStateProvider() {
- return new KernelStateProvider(checkNotNull(getTrace()), LttngEventLayout.getInstance());
- }
-
@Override
protected StateSystemBackendType getBackendType() {
return StateSystemBackendType.PARTIAL;
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;
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;
}
@NonNullByDefault
- private static class TestLttngKernelAnalysisModule extends TmfStateSystemAnalysisModule {
+ private static class TestLttngKernelAnalysisModule extends KernelAnalysisModule {
private final String htFileName;
return super.setTrace(trace);
}
- @Override
- protected ITmfStateProvider createStateProvider() {
- return new KernelStateProvider(checkNotNull(getTrace()), LttngEventLayout.getInstance());
- }
-
@Override
protected StateSystemBackendType getBackendType() {
return StateSystemBackendType.FULL;
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;
fixture = null;
}
- private static class TestLttngKernelAnalysisModule extends TmfStateSystemAnalysisModule {
+ private static class TestLttngKernelAnalysisModule extends KernelAnalysisModule {
/**
* Constructor adding the views to the analysis
return super.setTrace(trace);
}
- @Override
- protected ITmfStateProvider createStateProvider() {
- return new KernelStateProvider(checkNotNull(getTrace()), LttngEventLayout.getInstance());
- }
-
@Override
protected StateSystemBackendType getBackendType() {
return StateSystemBackendType.INMEM;
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
- LttngKernelStateProviderTest.class,
PartialStateSystemTest.class,
StateSystemFullHistoryTest.class,
StateSystemInMemoryTest.class
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;
*/
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();
}
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;
* 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;
}
* 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;
}
}
}
- 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);
}
}
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;
/* 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);
}
}
}
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;
}
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;
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;
}