import java.util.List;
import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.CtfKernelStateProvider;
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
/* Read a trace and build the state system */
try {
File newStateFile = new File("/tmp/helloworldctf.ht");
- ITmfStateProvider input = new CtfKernelStateProvider(CtfTmfTestTraces.getTestTrace(1));
+ ITmfStateProvider input = new LttngKernelStateProvider(CtfTmfTestTraces.getTestTrace(1));
ITmfStateSystem ss = TmfStateSystemFactory.newFullHistory(newStateFile, input, true);
requestExample(ss);
import java.io.PrintWriter;
import java.util.List;
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.CtfKernelStateProvider;
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
PrintWriter writer = new PrintWriter(new FileWriter(logFile), true);
/* Build and query the state system */
- ITmfStateProvider input = new CtfKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX));
+ ITmfStateProvider input = new LttngKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX));
ITmfStateSystem ssq = TmfStateSystemFactory.newFullHistory(stateFile, input, true);
List<ITmfStateInterval> fullState = ssq.queryFullState(targetTimestamp);
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 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.linuxtools.lttng2.kernel.core.tests.stateprovider;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assume.assumeTrue;
-
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.CtfKernelStateProvider;
-import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
-import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Tests for the {@link CtfKernelStateProvider}
- *
- * @author Alexandre Montplaisir
- */
-public class CtfKernelStateProviderTest {
-
- private final static int TRACE_INDEX = 1;
-
- private static ITmfStateProvider input;
-
- /**
- * Set-up.
- */
- @BeforeClass
- public static void initialize() {
- assumeTrue(CtfTmfTestTraces.tracesExist());
- input = new CtfKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX));
-
- }
-
- /**
- * Test loading the state provider.
- */
- @Test
- public void testOpening() {
- long testStartTime;
- testStartTime = input.getStartTime();
- assertEquals(testStartTime, StateSystemTest.startTime);
- }
-
-}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 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.linuxtools.lttng2.kernel.core.tests.stateprovider;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assume.assumeTrue;
+
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
+import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
+import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests for the {@link LttngKernelStateProvider}
+ *
+ * @author Alexandre Montplaisir
+ */
+public class LttngKernelStateProviderTest {
+
+ private final static int TRACE_INDEX = 1;
+
+ private static ITmfStateProvider input;
+
+ /**
+ * Set-up.
+ */
+ @BeforeClass
+ public static void initialize() {
+ assumeTrue(CtfTmfTestTraces.tracesExist());
+ input = new LttngKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX));
+
+ }
+
+ /**
+ * Test loading the state provider.
+ */
+ @Test
+ public void testOpening() {
+ long testStartTime;
+ testStartTime = input.getStartTime();
+ assertEquals(testStartTime, StateSystemTest.startTime);
+ }
+
+}
import java.io.File;
import java.io.IOException;
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.CtfKernelStateProvider;
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory;
stateFile = File.createTempFile("test-partial", ".ht");
stateFile.deleteOnExit();
- input = new CtfKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX));
+ input = new LttngKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX));
ssq = TmfStateSystemFactory.newPartialHistory(stateFile, input, true);
} catch (IOException e) {
e.printStackTrace();
import java.io.File;
import java.io.IOException;
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.CtfKernelStateProvider;
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
stateFile = File.createTempFile("test", ".ht");
stateFileBenchmark = File.createTempFile("test", ".ht.benchmark");
- input = new CtfKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX));
+ input = new LttngKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX));
ssq = TmfStateSystemFactory.newFullHistory(stateFile, input, true);
} catch (IOException e) {
e.printStackTrace();
@Test
public void testBuild() {
try {
- ITmfStateProvider input2 = new CtfKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX));
+ ITmfStateProvider input2 = new LttngKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX));
ITmfStateSystem ssb2 = TmfStateSystemFactory.newFullHistory(stateFileBenchmark, input2, true);
assertEquals(startTime, ssb2.getStartTime());
import static org.junit.Assume.assumeTrue;
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.CtfKernelStateProvider;
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory;
import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces;
import org.junit.BeforeClass;
@BeforeClass
public static void initialize() {
assumeTrue(CtfTmfTestTraces.tracesExist());
- input = new CtfKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX));
+ input = new LttngKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX));
ssq = TmfStateSystemFactory.newInMemHistory(input, true);
}
}
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
- CtfKernelStateProviderTest.class,
+ LttngKernelStateProviderTest.class,
PartialStateSystemTest.class,
StateSystemFullHistoryTest.class,
StateSystemInMemoryTest.class
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 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.linuxtools.internal.lttng2.kernel.core.stateprovider;
-
-import java.util.HashMap;
-
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.LttngStrings;
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.StateValues;
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
-import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
-import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
-import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
-import org.eclipse.linuxtools.tmf.core.statesystem.AbstractTmfStateProvider;
-import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystemBuilder;
-import org.eclipse.linuxtools.tmf.core.statevalue.ITmfStateValue;
-import org.eclipse.linuxtools.tmf.core.statevalue.TmfStateValue;
-
-/**
- * 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 CtfKernelStateProvider extends AbstractTmfStateProvider {
-
- /**
- * Version number of this state provider. Please bump this if you modify the
- * contents of the generated state history in some way.
- */
- private static final int VERSION = 2;
-
- /* Event names HashMap. TODO: This can be discarded once we move to Java 7 */
- private final HashMap<String, Integer> knownEventNames;
-
- // ------------------------------------------------------------------------
- // Constructor
- // ------------------------------------------------------------------------
-
- /**
- * Instantiate a new state provider plugin.
- *
- * @param trace
- * The LTTng 2.0 kernel trace directory
- */
- public CtfKernelStateProvider(CtfTmfTrace trace) {
- super(trace, CtfTmfEvent.class, "LTTng Kernel"); //$NON-NLS-1$
- knownEventNames = fillEventNames();
- }
-
- // ------------------------------------------------------------------------
- // 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 CtfKernelStateProvider getNewInstance() {
- return new CtfKernelStateProvider((CtfTmfTrace) this.getTrace());
- }
-
- @Override
- protected void eventHandle(ITmfEvent ev) {
- /*
- * AbstractStateChangeInput should have already checked for the correct
- * class type
- */
- CtfTmfEvent event = (CtfTmfEvent) ev;
-
- int quark;
- ITmfStateValue value;
-
- final ITmfEventField content = event.getContent();
- final String eventName = event.getEventName();
- final long ts = event.getTimestamp().getValue();
-
- try {
- /* Shortcut for the "current CPU" attribute node */
- final Integer currentCPUNode = ss.getQuarkRelativeAndAdd(getNodeCPUs(), String.valueOf(event.getCPU()));
-
- /*
- * Shortcut for the "current thread" attribute node. It requires
- * querying the current CPU's current thread.
- */
- quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.CURRENT_THREAD);
- value = ss.queryOngoingState(quark);
- int thread = value.unboxInt();
- final Integer currentThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(), String.valueOf(thread));
-
- /*
- * Feed event to the history system if it's known to cause a state
- * transition.
- */
- switch (getEventIndex(eventName)) {
-
- case 1: // "exit_syscall":
- /* Fields: int64 ret */
- {
- /* 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 = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_RUN_USERMODE);
- ss.modifyAttribute(ts, value, quark);
-
- /* Put the CPU's status back to user mode */
- quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_USERMODE);
- ss.modifyAttribute(ts, value, quark);
- }
- break;
-
- case 2: // "irq_handler_entry":
- /* Fields: int32 irq, string name */
- {
- Integer irqId = ((Long) content.getField(LttngStrings.IRQ).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(), irqId.toString());
- value = TmfStateValue.newValueInt(event.getCPU());
- ss.modifyAttribute(ts, value, quark);
-
- /* Change the status of the running process to interrupted */
- quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_INTERRUPTED);
- ss.modifyAttribute(ts, value, quark);
-
- /* Change the status of the CPU to interrupted */
- quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_IRQ);
- ss.modifyAttribute(ts, value, quark);
- }
- break;
-
- case 3: // "irq_handler_exit":
- /* Fields: int32 irq, int32 ret */
- {
- Integer irqId = ((Long) content.getField(LttngStrings.IRQ).getValue()).intValue();
-
- /* Put this IRQ back to inactive in the resource tree */
- quark = ss.getQuarkRelativeAndAdd(getNodeIRQs(), irqId.toString());
- value = TmfStateValue.nullValue();
- ss.modifyAttribute(ts, value, quark);
-
- /* Set the previous process back to running */
- setProcessToRunning(ts, currentThreadNode);
-
- /* Set the CPU status back to running or "idle" */
- cpuExitInterrupt(ts, currentCPUNode, currentThreadNode);
- }
- break;
-
- case 4: // "softirq_entry":
- /* Fields: int32 vec */
- {
- Integer softIrqId = ((Long) content.getField(LttngStrings.VEC).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(), softIrqId.toString());
- value = TmfStateValue.newValueInt(event.getCPU());
- ss.modifyAttribute(ts, value, quark);
-
- /* Change the status of the running process to interrupted */
- quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_INTERRUPTED);
- ss.modifyAttribute(ts, value, quark);
-
- /* Change the status of the CPU to interrupted */
- quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_SOFTIRQ);
- ss.modifyAttribute(ts, value, quark);
- }
- break;
-
- case 5: // "softirq_exit":
- /* Fields: int32 vec */
- {
- Integer softIrqId = ((Long) content.getField(LttngStrings.VEC).getValue()).intValue();
-
- /* Put this SoftIRQ back to inactive (= -1) in the resource tree */
- quark = ss.getQuarkRelativeAndAdd(getNodeSoftIRQs(), softIrqId.toString());
- value = TmfStateValue.nullValue();
- ss.modifyAttribute(ts, value, quark);
-
- /* Set the previous process back to running */
- setProcessToRunning(ts, currentThreadNode);
-
- /* Set the CPU status back to "busy" or "idle" */
- cpuExitInterrupt(ts, currentCPUNode, currentThreadNode);
- }
- break;
-
- case 6: // "softirq_raise":
- /* Fields: int32 vec */
- {
- Integer softIrqId = ((Long) content.getField(LttngStrings.VEC).getValue()).intValue();
-
- /* Mark this SoftIRQ as *raised* in the resource tree.
- * State value = -2 */
- quark = ss.getQuarkRelativeAndAdd(getNodeSoftIRQs(), softIrqId.toString());
- value = TmfStateValue.newValueInt(StateValues.SOFT_IRQ_RAISED);
- ss.modifyAttribute(ts, value, quark);
- }
- break;
-
- case 7: // "sched_switch":
- /*
- * Fields: string prev_comm, int32 prev_tid, int32 prev_prio, int64 prev_state,
- * string next_comm, int32 next_tid, int32 next_prio
- */
- {
- Integer prevTid = ((Long) content.getField(LttngStrings.PREV_TID).getValue()).intValue();
- Long prevState = (Long) content.getField(LttngStrings.PREV_STATE).getValue();
- String nextProcessName = (String) content.getField(LttngStrings.NEXT_COMM).getValue();
- Integer nextTid = ((Long) content.getField(LttngStrings.NEXT_TID).getValue()).intValue();
-
- Integer formerThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(), prevTid.toString());
- Integer newCurrentThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(), nextTid.toString());
-
- /* Set the status of the process that got scheduled out. */
- quark = ss.getQuarkRelativeAndAdd(formerThreadNode, Attributes.STATUS);
- if (prevState != 0) {
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_BLOCKED);
- } else {
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_FOR_CPU);
- }
- ss.modifyAttribute(ts, value, quark);
-
- /* Set the status of the new scheduled process */
- setProcessToRunning(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);
-
- /* 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 = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_USERMODE);
- } else {
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_SYSCALL);
- }
- } else {
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_IDLE);
- }
- quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
- ss.modifyAttribute(ts, value, quark);
- }
- break;
-
- case 8: // "sched_process_fork":
- /* Fields: string parent_comm, int32 parent_tid,
- * string child_comm, int32 child_tid */
- {
- // String parentProcessName = (String) event.getFieldValue("parent_comm");
- String childProcessName = (String) content.getField(LttngStrings.CHILD_COMM).getValue();
- // assert ( parentProcessName.equals(childProcessName) );
-
- Integer parentTid = ((Long) content.getField(LttngStrings.PARENT_TID).getValue()).intValue();
- Integer childTid = ((Long) content.getField(LttngStrings.CHILD_TID).getValue()).intValue();
-
- Integer parentTidNode = ss.getQuarkRelativeAndAdd(getNodeThreads(), parentTid.toString());
- Integer childTidNode = ss.getQuarkRelativeAndAdd(getNodeThreads(), 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 = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_FOR_CPU);
- 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(LttngStrings.SYS_CLONE);
- }
- quark = ss.getQuarkRelativeAndAdd(childTidNode, Attributes.SYSTEM_CALL);
- ss.modifyAttribute(ts, value, quark);
- }
- break;
-
- case 9: // "sched_process_exit":
- /* Fields: string comm, int32 tid, int32 prio */
- break;
-
- case 10: // "sched_process_free":
- /* Fields: string comm, int32 tid, int32 prio */
- /*
- * A sched_process_free will always happen after the sched_switch
- * that will remove the process from the cpu for the last time. So
- * this is when we should delete everything wrt to the process.
- */
- {
- Integer tid = ((Long) content.getField(LttngStrings.TID).getValue()).intValue();
- /*
- * Remove the process and all its sub-attributes from the
- * current state
- */
- quark = ss.getQuarkRelativeAndAdd(getNodeThreads(), tid.toString());
- ss.removeAttribute(ts, quark);
- }
- break;
-
- case 11: // "lttng_statedump_process_state":
- /* Fields:
- * int32 type, int32 mode, int32 pid, int32 submode, int32 vpid,
- * int32 ppid, int32 tid, string name, int32 status, int32 vtid */
- {
- Integer tid = ((Long) content.getField(LttngStrings.TID).getValue()).intValue();
- int ppid = ((Long) content.getField(LttngStrings.PPID).getValue()).intValue();
- int status = ((Long) content.getField(LttngStrings.STATUS).getValue()).intValue();
- String name = (String) content.getField(LttngStrings.NAME).getValue();
- /*
- * "mode" could be interesting too, but it doesn't seem to be
- * populated with anything relevant for now.
- */
-
- int curThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(), tid.toString());
-
- /* 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()) {
- value = TmfStateValue.newValueInt(ppid);
- ss.modifyAttribute(ts, value, quark);
- }
-
- /* Set the process' status */
- quark = ss.getQuarkRelativeAndAdd(curThreadNode, Attributes.STATUS);
- if (ss.queryOngoingState(quark).isNull()) {
- /* "2" here means "WAIT_FOR_CPU", and "5" "WAIT_BLOCKED" in the LTTng kernel. */
- if (status == 2) {
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_FOR_CPU);
- } else if (status == 5) {
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_BLOCKED);
- } else {
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_UNKNOWN);
- }
- ss.modifyAttribute(ts, value, quark);
- }
- }
- break;
-
- case 12: // "sched_wakeup":
- case 13: // "sched_wakeup_new":
- /* Fields (same fields for both types):
- * string comm, int32 pid, int32 prio, int32 success,
- * int32 target_cpu */
- {
- final int tid = ((Long) content.getField(LttngStrings.TID).getValue()).intValue();
- final int threadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(), String.valueOf(tid));
-
- /*
- * The process indicated in the event's payload is now ready to
- * run. Assign it to the "wait for cpu" state.
- */
- quark = ss.getQuarkRelativeAndAdd(threadNode, Attributes.STATUS);
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_FOR_CPU);
- ss.modifyAttribute(ts, value, quark);
- }
- break;
-
- default:
- /* Other event types not covered by the main switch */
- {
- if (eventName.startsWith(LttngStrings.SYSCALL_PREFIX)
- || eventName.startsWith(LttngStrings.COMPAT_SYSCALL_PREFIX)) {
- /*
- * This is a replacement for the old sys_enter event. Now
- * syscall names are listed into the event type
- */
-
- /* 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 = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_RUN_SYSCALL);
- ss.modifyAttribute(ts, value, quark);
-
- /* Put the CPU in system call (kernel) mode */
- quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_SYSCALL);
- 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 int getNodeCPUs() {
- return ss.getQuarkAbsoluteAndAdd(Attributes.CPUS);
- }
-
- private int getNodeThreads() {
- return ss.getQuarkAbsoluteAndAdd(Attributes.THREADS);
- }
-
- private int getNodeIRQs() {
- return ss.getQuarkAbsoluteAndAdd(Attributes.RESOURCES, Attributes.IRQS);
- }
-
- private int getNodeSoftIRQs() {
- return ss.getQuarkAbsoluteAndAdd(Attributes.RESOURCES, Attributes.SOFT_IRQS);
- }
-
- // ------------------------------------------------------------------------
- // Workaround for the lack of switch-on-strings in Java < 7
- // ------------------------------------------------------------------------
-
- private static HashMap<String, Integer> fillEventNames() {
- /*
- * TODO Replace with straight strings in the switch/case once we move to
- * Java 7
- */
- HashMap<String, Integer> map = new HashMap<String, Integer>();
-
- map.put(LttngStrings.EXIT_SYSCALL, 1);
- map.put(LttngStrings.IRQ_HANDLER_ENTRY, 2);
- map.put(LttngStrings.IRQ_HANDLER_EXIT, 3);
- map.put(LttngStrings.SOFTIRQ_ENTRY, 4);
- map.put(LttngStrings.SOFTIRQ_EXIT, 5);
- map.put(LttngStrings.SOFTIRQ_RAISE, 6);
- map.put(LttngStrings.SCHED_SWITCH, 7);
- map.put(LttngStrings.SCHED_PROCESS_FORK, 8);
- map.put(LttngStrings.SCHED_PROCESS_EXIT, 9);
- map.put(LttngStrings.SCHED_PROCESS_FREE, 10);
- map.put(LttngStrings.STATEDUMP_PROCESS_STATE, 11);
- map.put(LttngStrings.SCHED_WAKEUP, 12);
- map.put(LttngStrings.SCHED_WAKEUP_NEW, 13);
-
- return map;
- }
-
- private int getEventIndex(String eventName) {
- Integer ret = knownEventNames.get(eventName);
- return (ret != null) ? ret : -1;
- }
-
- // ------------------------------------------------------------------------
- // 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 void setProcessToRunning(long ts, int currentThreadNode)
- throws AttributeNotFoundException, TimeRangeException,
- StateValueTypeException {
- int quark;
- ITmfStateValue value;
-
- quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.SYSTEM_CALL);
- if (ss.queryOngoingState(quark).isNull()) {
- /* We were in user mode before the interruption */
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_RUN_USERMODE);
- } else {
- /* We were previously in kernel mode */
- value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_RUN_SYSCALL);
- }
- quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
- ss.modifyAttribute(ts, value, quark);
- }
-
- /**
- * Similar logic as above, but to set the CPU's status when it's coming out
- * of an interruption.
- */
- private void cpuExitInterrupt(long ts, int currentCpuNode, int currentThreadNode)
- throws StateValueTypeException, AttributeNotFoundException,
- TimeRangeException {
- int quark;
- ITmfStateValue value;
-
- quark = ss.getQuarkRelativeAndAdd(currentCpuNode, Attributes.CURRENT_THREAD);
- if (ss.queryOngoingState(quark).unboxInt() > 0) {
- /* There was a process on the CPU */
- quark = ss.getQuarkRelative(currentThreadNode, Attributes.SYSTEM_CALL);
- if (ss.queryOngoingState(quark).isNull()) {
- /* That process was in user mode */
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_USERMODE);
- } else {
- /* That process was in a system call */
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_SYSCALL);
- }
- } else {
- /* There was no real process scheduled, CPU was idle */
- value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_IDLE);
- }
- quark = ss.getQuarkRelativeAndAdd(currentCpuNode, Attributes.STATUS);
- ss.modifyAttribute(ts, value, quark);
- }
-}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 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.linuxtools.internal.lttng2.kernel.core.stateprovider;
+
+import java.util.HashMap;
+
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.LttngStrings;
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.StateValues;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
+import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
+import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
+import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
+import org.eclipse.linuxtools.tmf.core.statesystem.AbstractTmfStateProvider;
+import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystemBuilder;
+import org.eclipse.linuxtools.tmf.core.statevalue.ITmfStateValue;
+import org.eclipse.linuxtools.tmf.core.statevalue.TmfStateValue;
+
+/**
+ * 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 LttngKernelStateProvider extends AbstractTmfStateProvider {
+
+ /**
+ * Version number of this state provider. Please bump this if you modify the
+ * contents of the generated state history in some way.
+ */
+ private static final int VERSION = 2;
+
+ /* Event names HashMap. TODO: This can be discarded once we move to Java 7 */
+ private final HashMap<String, Integer> knownEventNames;
+
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+
+ /**
+ * Instantiate a new state provider plugin.
+ *
+ * @param trace
+ * The LTTng 2.0 kernel trace directory
+ */
+ public LttngKernelStateProvider(CtfTmfTrace trace) {
+ super(trace, CtfTmfEvent.class, "LTTng Kernel"); //$NON-NLS-1$
+ knownEventNames = fillEventNames();
+ }
+
+ // ------------------------------------------------------------------------
+ // 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 LttngKernelStateProvider getNewInstance() {
+ return new LttngKernelStateProvider((CtfTmfTrace) this.getTrace());
+ }
+
+ @Override
+ protected void eventHandle(ITmfEvent ev) {
+ /*
+ * AbstractStateChangeInput should have already checked for the correct
+ * class type
+ */
+ CtfTmfEvent event = (CtfTmfEvent) ev;
+
+ int quark;
+ ITmfStateValue value;
+
+ final ITmfEventField content = event.getContent();
+ final String eventName = event.getEventName();
+ final long ts = event.getTimestamp().getValue();
+
+ try {
+ /* Shortcut for the "current CPU" attribute node */
+ final Integer currentCPUNode = ss.getQuarkRelativeAndAdd(getNodeCPUs(), String.valueOf(event.getCPU()));
+
+ /*
+ * Shortcut for the "current thread" attribute node. It requires
+ * querying the current CPU's current thread.
+ */
+ quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.CURRENT_THREAD);
+ value = ss.queryOngoingState(quark);
+ int thread = value.unboxInt();
+ final Integer currentThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(), String.valueOf(thread));
+
+ /*
+ * Feed event to the history system if it's known to cause a state
+ * transition.
+ */
+ switch (getEventIndex(eventName)) {
+
+ case 1: // "exit_syscall":
+ /* Fields: int64 ret */
+ {
+ /* 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 = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_RUN_USERMODE);
+ ss.modifyAttribute(ts, value, quark);
+
+ /* Put the CPU's status back to user mode */
+ quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
+ value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_USERMODE);
+ ss.modifyAttribute(ts, value, quark);
+ }
+ break;
+
+ case 2: // "irq_handler_entry":
+ /* Fields: int32 irq, string name */
+ {
+ Integer irqId = ((Long) content.getField(LttngStrings.IRQ).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(), irqId.toString());
+ value = TmfStateValue.newValueInt(event.getCPU());
+ ss.modifyAttribute(ts, value, quark);
+
+ /* Change the status of the running process to interrupted */
+ quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
+ value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_INTERRUPTED);
+ ss.modifyAttribute(ts, value, quark);
+
+ /* Change the status of the CPU to interrupted */
+ quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
+ value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_IRQ);
+ ss.modifyAttribute(ts, value, quark);
+ }
+ break;
+
+ case 3: // "irq_handler_exit":
+ /* Fields: int32 irq, int32 ret */
+ {
+ Integer irqId = ((Long) content.getField(LttngStrings.IRQ).getValue()).intValue();
+
+ /* Put this IRQ back to inactive in the resource tree */
+ quark = ss.getQuarkRelativeAndAdd(getNodeIRQs(), irqId.toString());
+ value = TmfStateValue.nullValue();
+ ss.modifyAttribute(ts, value, quark);
+
+ /* Set the previous process back to running */
+ setProcessToRunning(ts, currentThreadNode);
+
+ /* Set the CPU status back to running or "idle" */
+ cpuExitInterrupt(ts, currentCPUNode, currentThreadNode);
+ }
+ break;
+
+ case 4: // "softirq_entry":
+ /* Fields: int32 vec */
+ {
+ Integer softIrqId = ((Long) content.getField(LttngStrings.VEC).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(), softIrqId.toString());
+ value = TmfStateValue.newValueInt(event.getCPU());
+ ss.modifyAttribute(ts, value, quark);
+
+ /* Change the status of the running process to interrupted */
+ quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
+ value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_INTERRUPTED);
+ ss.modifyAttribute(ts, value, quark);
+
+ /* Change the status of the CPU to interrupted */
+ quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
+ value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_SOFTIRQ);
+ ss.modifyAttribute(ts, value, quark);
+ }
+ break;
+
+ case 5: // "softirq_exit":
+ /* Fields: int32 vec */
+ {
+ Integer softIrqId = ((Long) content.getField(LttngStrings.VEC).getValue()).intValue();
+
+ /* Put this SoftIRQ back to inactive (= -1) in the resource tree */
+ quark = ss.getQuarkRelativeAndAdd(getNodeSoftIRQs(), softIrqId.toString());
+ value = TmfStateValue.nullValue();
+ ss.modifyAttribute(ts, value, quark);
+
+ /* Set the previous process back to running */
+ setProcessToRunning(ts, currentThreadNode);
+
+ /* Set the CPU status back to "busy" or "idle" */
+ cpuExitInterrupt(ts, currentCPUNode, currentThreadNode);
+ }
+ break;
+
+ case 6: // "softirq_raise":
+ /* Fields: int32 vec */
+ {
+ Integer softIrqId = ((Long) content.getField(LttngStrings.VEC).getValue()).intValue();
+
+ /* Mark this SoftIRQ as *raised* in the resource tree.
+ * State value = -2 */
+ quark = ss.getQuarkRelativeAndAdd(getNodeSoftIRQs(), softIrqId.toString());
+ value = TmfStateValue.newValueInt(StateValues.SOFT_IRQ_RAISED);
+ ss.modifyAttribute(ts, value, quark);
+ }
+ break;
+
+ case 7: // "sched_switch":
+ /*
+ * Fields: string prev_comm, int32 prev_tid, int32 prev_prio, int64 prev_state,
+ * string next_comm, int32 next_tid, int32 next_prio
+ */
+ {
+ Integer prevTid = ((Long) content.getField(LttngStrings.PREV_TID).getValue()).intValue();
+ Long prevState = (Long) content.getField(LttngStrings.PREV_STATE).getValue();
+ String nextProcessName = (String) content.getField(LttngStrings.NEXT_COMM).getValue();
+ Integer nextTid = ((Long) content.getField(LttngStrings.NEXT_TID).getValue()).intValue();
+
+ Integer formerThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(), prevTid.toString());
+ Integer newCurrentThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(), nextTid.toString());
+
+ /* Set the status of the process that got scheduled out. */
+ quark = ss.getQuarkRelativeAndAdd(formerThreadNode, Attributes.STATUS);
+ if (prevState != 0) {
+ value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_BLOCKED);
+ } else {
+ value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_FOR_CPU);
+ }
+ ss.modifyAttribute(ts, value, quark);
+
+ /* Set the status of the new scheduled process */
+ setProcessToRunning(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);
+
+ /* 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 = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_USERMODE);
+ } else {
+ value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_SYSCALL);
+ }
+ } else {
+ value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_IDLE);
+ }
+ quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
+ ss.modifyAttribute(ts, value, quark);
+ }
+ break;
+
+ case 8: // "sched_process_fork":
+ /* Fields: string parent_comm, int32 parent_tid,
+ * string child_comm, int32 child_tid */
+ {
+ // String parentProcessName = (String) event.getFieldValue("parent_comm");
+ String childProcessName = (String) content.getField(LttngStrings.CHILD_COMM).getValue();
+ // assert ( parentProcessName.equals(childProcessName) );
+
+ Integer parentTid = ((Long) content.getField(LttngStrings.PARENT_TID).getValue()).intValue();
+ Integer childTid = ((Long) content.getField(LttngStrings.CHILD_TID).getValue()).intValue();
+
+ Integer parentTidNode = ss.getQuarkRelativeAndAdd(getNodeThreads(), parentTid.toString());
+ Integer childTidNode = ss.getQuarkRelativeAndAdd(getNodeThreads(), 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 = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_FOR_CPU);
+ 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(LttngStrings.SYS_CLONE);
+ }
+ quark = ss.getQuarkRelativeAndAdd(childTidNode, Attributes.SYSTEM_CALL);
+ ss.modifyAttribute(ts, value, quark);
+ }
+ break;
+
+ case 9: // "sched_process_exit":
+ /* Fields: string comm, int32 tid, int32 prio */
+ break;
+
+ case 10: // "sched_process_free":
+ /* Fields: string comm, int32 tid, int32 prio */
+ /*
+ * A sched_process_free will always happen after the sched_switch
+ * that will remove the process from the cpu for the last time. So
+ * this is when we should delete everything wrt to the process.
+ */
+ {
+ Integer tid = ((Long) content.getField(LttngStrings.TID).getValue()).intValue();
+ /*
+ * Remove the process and all its sub-attributes from the
+ * current state
+ */
+ quark = ss.getQuarkRelativeAndAdd(getNodeThreads(), tid.toString());
+ ss.removeAttribute(ts, quark);
+ }
+ break;
+
+ case 11: // "lttng_statedump_process_state":
+ /* Fields:
+ * int32 type, int32 mode, int32 pid, int32 submode, int32 vpid,
+ * int32 ppid, int32 tid, string name, int32 status, int32 vtid */
+ {
+ Integer tid = ((Long) content.getField(LttngStrings.TID).getValue()).intValue();
+ int ppid = ((Long) content.getField(LttngStrings.PPID).getValue()).intValue();
+ int status = ((Long) content.getField(LttngStrings.STATUS).getValue()).intValue();
+ String name = (String) content.getField(LttngStrings.NAME).getValue();
+ /*
+ * "mode" could be interesting too, but it doesn't seem to be
+ * populated with anything relevant for now.
+ */
+
+ int curThreadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(), tid.toString());
+
+ /* 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()) {
+ value = TmfStateValue.newValueInt(ppid);
+ ss.modifyAttribute(ts, value, quark);
+ }
+
+ /* Set the process' status */
+ quark = ss.getQuarkRelativeAndAdd(curThreadNode, Attributes.STATUS);
+ if (ss.queryOngoingState(quark).isNull()) {
+ /* "2" here means "WAIT_FOR_CPU", and "5" "WAIT_BLOCKED" in the LTTng kernel. */
+ if (status == 2) {
+ value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_FOR_CPU);
+ } else if (status == 5) {
+ value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_BLOCKED);
+ } else {
+ value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_UNKNOWN);
+ }
+ ss.modifyAttribute(ts, value, quark);
+ }
+ }
+ break;
+
+ case 12: // "sched_wakeup":
+ case 13: // "sched_wakeup_new":
+ /* Fields (same fields for both types):
+ * string comm, int32 pid, int32 prio, int32 success,
+ * int32 target_cpu */
+ {
+ final int tid = ((Long) content.getField(LttngStrings.TID).getValue()).intValue();
+ final int threadNode = ss.getQuarkRelativeAndAdd(getNodeThreads(), String.valueOf(tid));
+
+ /*
+ * The process indicated in the event's payload is now ready to
+ * run. Assign it to the "wait for cpu" state.
+ */
+ quark = ss.getQuarkRelativeAndAdd(threadNode, Attributes.STATUS);
+ value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_WAIT_FOR_CPU);
+ ss.modifyAttribute(ts, value, quark);
+ }
+ break;
+
+ default:
+ /* Other event types not covered by the main switch */
+ {
+ if (eventName.startsWith(LttngStrings.SYSCALL_PREFIX)
+ || eventName.startsWith(LttngStrings.COMPAT_SYSCALL_PREFIX)) {
+ /*
+ * This is a replacement for the old sys_enter event. Now
+ * syscall names are listed into the event type
+ */
+
+ /* 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 = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_RUN_SYSCALL);
+ ss.modifyAttribute(ts, value, quark);
+
+ /* Put the CPU in system call (kernel) mode */
+ quark = ss.getQuarkRelativeAndAdd(currentCPUNode, Attributes.STATUS);
+ value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_SYSCALL);
+ 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 int getNodeCPUs() {
+ return ss.getQuarkAbsoluteAndAdd(Attributes.CPUS);
+ }
+
+ private int getNodeThreads() {
+ return ss.getQuarkAbsoluteAndAdd(Attributes.THREADS);
+ }
+
+ private int getNodeIRQs() {
+ return ss.getQuarkAbsoluteAndAdd(Attributes.RESOURCES, Attributes.IRQS);
+ }
+
+ private int getNodeSoftIRQs() {
+ return ss.getQuarkAbsoluteAndAdd(Attributes.RESOURCES, Attributes.SOFT_IRQS);
+ }
+
+ // ------------------------------------------------------------------------
+ // Workaround for the lack of switch-on-strings in Java < 7
+ // ------------------------------------------------------------------------
+
+ private static HashMap<String, Integer> fillEventNames() {
+ /*
+ * TODO Replace with straight strings in the switch/case once we move to
+ * Java 7
+ */
+ HashMap<String, Integer> map = new HashMap<String, Integer>();
+
+ map.put(LttngStrings.EXIT_SYSCALL, 1);
+ map.put(LttngStrings.IRQ_HANDLER_ENTRY, 2);
+ map.put(LttngStrings.IRQ_HANDLER_EXIT, 3);
+ map.put(LttngStrings.SOFTIRQ_ENTRY, 4);
+ map.put(LttngStrings.SOFTIRQ_EXIT, 5);
+ map.put(LttngStrings.SOFTIRQ_RAISE, 6);
+ map.put(LttngStrings.SCHED_SWITCH, 7);
+ map.put(LttngStrings.SCHED_PROCESS_FORK, 8);
+ map.put(LttngStrings.SCHED_PROCESS_EXIT, 9);
+ map.put(LttngStrings.SCHED_PROCESS_FREE, 10);
+ map.put(LttngStrings.STATEDUMP_PROCESS_STATE, 11);
+ map.put(LttngStrings.SCHED_WAKEUP, 12);
+ map.put(LttngStrings.SCHED_WAKEUP_NEW, 13);
+
+ return map;
+ }
+
+ private int getEventIndex(String eventName) {
+ Integer ret = knownEventNames.get(eventName);
+ return (ret != null) ? ret : -1;
+ }
+
+ // ------------------------------------------------------------------------
+ // 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 void setProcessToRunning(long ts, int currentThreadNode)
+ throws AttributeNotFoundException, TimeRangeException,
+ StateValueTypeException {
+ int quark;
+ ITmfStateValue value;
+
+ quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.SYSTEM_CALL);
+ if (ss.queryOngoingState(quark).isNull()) {
+ /* We were in user mode before the interruption */
+ value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_RUN_USERMODE);
+ } else {
+ /* We were previously in kernel mode */
+ value = TmfStateValue.newValueInt(StateValues.PROCESS_STATUS_RUN_SYSCALL);
+ }
+ quark = ss.getQuarkRelativeAndAdd(currentThreadNode, Attributes.STATUS);
+ ss.modifyAttribute(ts, value, quark);
+ }
+
+ /**
+ * Similar logic as above, but to set the CPU's status when it's coming out
+ * of an interruption.
+ */
+ private void cpuExitInterrupt(long ts, int currentCpuNode, int currentThreadNode)
+ throws StateValueTypeException, AttributeNotFoundException,
+ TimeRangeException {
+ int quark;
+ ITmfStateValue value;
+
+ quark = ss.getQuarkRelativeAndAdd(currentCpuNode, Attributes.CURRENT_THREAD);
+ if (ss.queryOngoingState(quark).unboxInt() > 0) {
+ /* There was a process on the CPU */
+ quark = ss.getQuarkRelative(currentThreadNode, Attributes.SYSTEM_CALL);
+ if (ss.queryOngoingState(quark).isNull()) {
+ /* That process was in user mode */
+ value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_USERMODE);
+ } else {
+ /* That process was in a system call */
+ value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_RUN_SYSCALL);
+ }
+ } else {
+ /* There was no real process scheduled, CPU was idle */
+ value = TmfStateValue.newValueInt(StateValues.CPU_STATUS_IDLE);
+ }
+ quark = ss.getQuarkRelativeAndAdd(currentCpuNode, Attributes.STATUS);
+ ss.modifyAttribute(ts, value, quark);
+ }
+}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 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:
- * Alexandre Montplaisir - Initial API and implementation
- * Matthew Khouzam - Improved validation
- ******************************************************************************/
-
-package org.eclipse.linuxtools.lttng2.kernel.core.trace;
-
-import java.io.File;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
-import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.Activator;
-import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.CtfKernelStateProvider;
-import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
-import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
-import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory;
-
-/**
- * This is the specification of CtfTmfTrace for use with LTTng 2.x kernel
- * traces. It uses the CtfKernelStateInput to generate the state history.
- *
- * @version 1.0
- * @author Alexandre Montplaisir
- */
-public class CtfKernelTrace extends CtfTmfTrace {
-
- /**
- * The file name of the History Tree
- */
- public final static String HISTORY_TREE_FILE_NAME = "stateHistory.ht"; //$NON-NLS-1$
-
- /**
- * ID of the state system we will build
- * @since 2.0
- * */
- public static final String STATE_ID = "org.eclipse.linuxtools.lttng2.kernel"; //$NON-NLS-1$
-
- /**
- * Default constructor
- */
- public CtfKernelTrace() {
- super();
- }
-
- /**
- * @since 2.0
- */
- @Override
- public IStatus validate(final IProject project, final String path) {
- CTFTrace temp;
- IStatus validStatus;
- /*
- * Make sure the trace is openable as a CTF trace. We do this here
- * instead of calling super.validate() to keep the reference to "temp".
- */
- try {
- temp = new CTFTrace(path);
- } catch (CTFReaderException e) {
- validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
- return validStatus;
- } catch (NullPointerException e){
- validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
- return validStatus;
- }
-
- /* Make sure the domain is "kernel" in the trace's env vars */
- String dom = temp.getEnvironment().get("domain"); //$NON-NLS-1$
- temp.dispose();
- if (dom != null && dom.equals("\"kernel\"")) { //$NON-NLS-1$
- return Status.OK_STATUS;
- }
- validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CtfKernelTrace_DomainError);
- return validStatus;
- }
-
- @Override
- protected void buildStateSystem() throws TmfTraceException {
- super.buildStateSystem();
-
- /* Set up the path to the history tree file we'll use */
- IResource resource = this.getResource();
- String supplDirectory = null;
-
- try {
- // get the directory where the history file will be stored.
- supplDirectory = resource.getPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER);
- } catch (CoreException e) {
- throw new TmfTraceException(e.toString(), e);
- }
-
- final File htFile = new File(supplDirectory + File.separator + HISTORY_TREE_FILE_NAME);
- final ITmfStateProvider htInput = new CtfKernelStateProvider(this);
-
- ITmfStateSystem ss = TmfStateSystemFactory.newFullHistory(htFile, htInput, false);
- fStateSystems.put(STATE_ID, ss);
- }
-
-}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 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:
+ * Alexandre Montplaisir - Initial API and implementation
+ * Matthew Khouzam - Improved validation
+ ******************************************************************************/
+
+package org.eclipse.linuxtools.lttng2.kernel.core.trace;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
+import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.Activator;
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
+import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
+import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
+import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory;
+
+/**
+ * This is the specification of CtfTmfTrace for use with LTTng 2.x kernel
+ * traces. It uses the CtfKernelStateInput to generate the state history.
+ *
+ * @author Alexandre Montplaisir
+ * @since 2.0
+ */
+public class LttngKernelTrace extends CtfTmfTrace {
+
+ /**
+ * The file name of the History Tree
+ */
+ public final static String HISTORY_TREE_FILE_NAME = "stateHistory.ht"; //$NON-NLS-1$
+
+ /**
+ * ID of the state system we will build
+ * @since 2.0
+ * */
+ public static final String STATE_ID = "org.eclipse.linuxtools.lttng2.kernel"; //$NON-NLS-1$
+
+ /**
+ * Default constructor
+ */
+ public LttngKernelTrace() {
+ super();
+ }
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public IStatus validate(final IProject project, final String path) {
+ CTFTrace temp;
+ IStatus validStatus;
+ /*
+ * Make sure the trace is openable as a CTF trace. We do this here
+ * instead of calling super.validate() to keep the reference to "temp".
+ */
+ try {
+ temp = new CTFTrace(path);
+ } catch (CTFReaderException e) {
+ validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
+ return validStatus;
+ } catch (NullPointerException e){
+ validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
+ return validStatus;
+ }
+
+ /* Make sure the domain is "kernel" in the trace's env vars */
+ String dom = temp.getEnvironment().get("domain"); //$NON-NLS-1$
+ temp.dispose();
+ if (dom != null && dom.equals("\"kernel\"")) { //$NON-NLS-1$
+ return Status.OK_STATUS;
+ }
+ validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngKernelTrace_DomainError);
+ return validStatus;
+ }
+
+ @Override
+ protected void buildStateSystem() throws TmfTraceException {
+ super.buildStateSystem();
+
+ /* Set up the path to the history tree file we'll use */
+ IResource resource = this.getResource();
+ String supplDirectory = null;
+
+ try {
+ // get the directory where the history file will be stored.
+ supplDirectory = resource.getPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER);
+ } catch (CoreException e) {
+ throw new TmfTraceException(e.toString(), e);
+ }
+
+ final File htFile = new File(supplDirectory + File.separator + HISTORY_TREE_FILE_NAME);
+ final ITmfStateProvider htInput = new LttngKernelStateProvider(this);
+
+ ITmfStateSystem ss = TmfStateSystemFactory.newFullHistory(htFile, htInput, false);
+ fStateSystems.put(STATE_ID, ss);
+ }
+
+}
/**
* The domain is not "kernel"
*/
- public static String CtfKernelTrace_DomainError;
+ public static String LttngKernelTrace_DomainError;
static {
// initialize resource bundle
# Ericsson - Initial API and implementation
###############################################################################
-CtfKernelTrace_DomainError=Domain mismatch, make sure the environment is 'kernel'
+LttngKernelTrace_DomainError=Domain mismatch, the environment should be 'kernel'.
controlflow.view.name = Control Flow
resources.view.name = Resources
-tracetype.category.lttng = LTTng 2.0
-tracetype.type.kernel = Kernel Trace
+tracetype.type.kernel = LTTng Kernel Trace
icon="icons/obj16/garland16.png"
id="org.eclipse.linuxtools.lttng2.kernel.tracetype"
name="%tracetype.type.kernel"
- trace_type="org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace">
+ trace_type="org.eclipse.linuxtools.lttng2.kernel.core.trace.LttngKernelTrace">
<eventsTableType
class="org.eclipse.linuxtools.internal.lttng2.kernel.ui.viewers.events.LTTng2EventsTable">
</eventsTableType>
import java.util.Iterator;
import java.util.List;
-import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;
+import org.eclipse.linuxtools.lttng2.kernel.core.trace.LttngKernelTrace;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.EventIterator;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
*/
public class ControlFlowEntry implements ITimeGraphEntry {
private final int fThreadQuark;
- private final CtfKernelTrace fTrace;
+ private final LttngKernelTrace fTrace;
private ControlFlowEntry fParent = null;
private final ArrayList<ControlFlowEntry> fChildren = new ArrayList<ControlFlowEntry>();
private String fName;
* @param endTime
* The end time of this process
*/
- public ControlFlowEntry(int threadQuark, CtfKernelTrace trace, String execName, int threadId, int parentThreadId, long startTime, long endTime) {
+ public ControlFlowEntry(int threadQuark, LttngKernelTrace trace, String execName, int threadId, int parentThreadId, long startTime, long endTime) {
fThreadQuark = threadQuark;
fTrace = trace;
fName = execName;
*
* @return The trace
*/
- public CtfKernelTrace getTrace() {
+ public LttngKernelTrace getTrace() {
return fTrace;
}
import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
import org.eclipse.linuxtools.internal.lttng2.kernel.core.StateValues;
import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
-import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;
+import org.eclipse.linuxtools.lttng2.kernel.core.trace.LttngKernelTrace;
import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
Map<String, String> retMap = new LinkedHashMap<String, String>();
if (event instanceof ControlFlowEvent) {
ControlFlowEntry entry = (ControlFlowEntry) event.getEntry();
- ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
int tid = entry.getThreadId();
try {
return;
}
ControlFlowEntry entry = (ControlFlowEntry) event.getEntry();
- ITmfStateSystem ss = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ss = entry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
int status = ((ControlFlowEvent) event).getStatus();
if (status != StateValues.PROCESS_STATUS_RUN_SYSCALL) {
return;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
-import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;
+import org.eclipse.linuxtools.lttng2.kernel.core.trace.LttngKernelTrace;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp;
import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
if (thread > 0) {
break;
}
- if (trace instanceof CtfKernelTrace) {
- CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) trace;
- ITmfStateSystem ssq = ctfKernelTrace.getStateSystems().get(CtfKernelTrace.STATE_ID);
+ if (trace instanceof LttngKernelTrace) {
+ LttngKernelTrace ctfKernelTrace = (LttngKernelTrace) trace;
+ ITmfStateSystem ssq = ctfKernelTrace.getStateSystems().get(LttngKernelTrace.STATE_ID);
if (time >= ssq.getStartTime() && time <= ssq.getCurrentEndTime()) {
List<Integer> currentThreadQuarks = ssq.getQuarks(Attributes.CPUS, "*", Attributes.CURRENT_THREAD); //$NON-NLS-1$
for (int currentThreadQuark : currentThreadQuarks) {
if (monitor.isCanceled()) {
return;
}
- if (aTrace instanceof CtfKernelTrace) {
+ if (aTrace instanceof LttngKernelTrace) {
ArrayList<ControlFlowEntry> entryList = new ArrayList<ControlFlowEntry>();
- CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) aTrace;
- ITmfStateSystem ssq = ctfKernelTrace.getStateSystems().get(CtfKernelTrace.STATE_ID);
+ LttngKernelTrace ctfKernelTrace = (LttngKernelTrace) aTrace;
+ ITmfStateSystem ssq = ctfKernelTrace.getStateSystems().get(LttngKernelTrace.STATE_ID);
if (!ssq.waitUntilBuilt()) {
return;
}
}
private void buildStatusEvents(ITmfTrace trace, ControlFlowEntry entry, IProgressMonitor monitor) {
- ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
long start = ssq.getStartTime();
long end = ssq.getCurrentEndTime() + 1;
long resolution = Math.max(1, (end - start) / fDisplayWidth);
if (realEnd <= realStart) {
return null;
}
- ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
List<ITimeEvent> eventList = null;
try {
int statusQuark = ssq.getQuarkRelative(entry.getThreadQuark(), Attributes.STATUS);
import java.util.Iterator;
import java.util.List;
-import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;
+import org.eclipse.linuxtools.lttng2.kernel.core.trace.LttngKernelTrace;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.EventIterator;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
SOFT_IRQ }
private final int fQuark;
- private final CtfKernelTrace fTrace;
+ private final LttngKernelTrace fTrace;
private ITimeGraphEntry fParent = null;
private final List<ITimeGraphEntry> children = null;
private final String fName;
* @param id
* The integer id associated with this entry or row
*/
- public ResourcesEntry(int quark, CtfKernelTrace trace, Type type, int id) {
+ public ResourcesEntry(int quark, LttngKernelTrace trace, Type type, int id) {
fQuark = quark;
fTrace = trace;
fType = type;
*
* @return The LTTng 2 kernel trace
*/
- public CtfKernelTrace getTrace() {
+ public LttngKernelTrace getTrace() {
return fTrace;
}
import org.eclipse.linuxtools.internal.lttng2.kernel.core.StateValues;
import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources.ResourcesEntry.Type;
-import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;
+import org.eclipse.linuxtools.lttng2.kernel.core.trace.LttngKernelTrace;
import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
if (status == StateValues.CPU_STATUS_IRQ) {
// In IRQ state get the IRQ that caused the interruption
ResourcesEntry entry = (ResourcesEntry) event.getEntry();
- ITmfStateSystem ss = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ss = entry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
int cpu = entry.getId();
try {
} else if (status == StateValues.CPU_STATUS_SOFTIRQ) {
// In SOFT_IRQ state get the SOFT_IRQ that caused the interruption
ResourcesEntry entry = (ResourcesEntry) event.getEntry();
- ITmfStateSystem ss = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ss = entry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
int cpu = entry.getId();
try {
} else if (status == StateValues.CPU_STATUS_RUN_USERMODE || status == StateValues.CPU_STATUS_RUN_SYSCALL){
// In running state get the current tid
ResourcesEntry entry = (ResourcesEntry) event.getEntry();
- ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
try {
retMap.put(Messages.ResourcesView_attributeHoverTime, Utils.formatTime(hoverTime, TimeFormat.CALENDAR, Resolution.NANOSEC));
return;
}
ResourcesEntry entry = (ResourcesEntry) event.getEntry();
- ITmfStateSystem ss = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ss = entry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
long time = event.getTime();
try {
while (time < event.getTime() + event.getDuration()) {
import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources.ResourcesEntry.Type;
-import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;
+import org.eclipse.linuxtools.lttng2.kernel.core.trace.LttngKernelTrace;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp;
import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
private class TraceEntry implements ITimeGraphEntry {
// The Trace
- private final CtfKernelTrace fKernelTrace;
+ private final LttngKernelTrace fKernelTrace;
// The start time
private final long fTraceStartTime;
// The end time
// The name of entry
private final String fName;
- public TraceEntry(CtfKernelTrace trace, String name, long startTime, long endTime) {
+ public TraceEntry(LttngKernelTrace trace, String name, long startTime, long endTime) {
fKernelTrace = trace;
fChildren = new ArrayList<ResourcesEntry>();
fName = name;
return null;
}
- public CtfKernelTrace getTrace() {
+ public LttngKernelTrace getTrace() {
return fKernelTrace;
}
}
long resolution = Math.max(1, (fZoomEndTime - fZoomStartTime) / fDisplayWidth);
for (TraceEntry traceEntry : fZoomEntryList) {
- if (!traceEntry.fKernelTrace.getStateSystems().get(CtfKernelTrace.STATE_ID).waitUntilBuilt()) {
+ if (!traceEntry.fKernelTrace.getStateSystems().get(LttngKernelTrace.STATE_ID).waitUntilBuilt()) {
return;
}
for (ITimeGraphEntry child : traceEntry.getChildren()) {
if (monitor.isCanceled()) {
return;
}
- if (aTrace instanceof CtfKernelTrace) {
- CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) aTrace;
- ITmfStateSystem ssq = ctfKernelTrace.getStateSystems().get(CtfKernelTrace.STATE_ID);
+ if (aTrace instanceof LttngKernelTrace) {
+ LttngKernelTrace ctfKernelTrace = (LttngKernelTrace) aTrace;
+ ITmfStateSystem ssq = ctfKernelTrace.getStateSystems().get(LttngKernelTrace.STATE_ID);
if (!ssq.waitUntilBuilt()) {
return;
}
if (monitor.isCanceled()) {
return;
}
- CtfKernelTrace ctfKernelTrace = traceEntry.getTrace();
- ITmfStateSystem ssq = ctfKernelTrace.getStateSystems().get(CtfKernelTrace.STATE_ID);
+ LttngKernelTrace ctfKernelTrace = traceEntry.getTrace();
+ ITmfStateSystem ssq = ctfKernelTrace.getStateSystems().get(LttngKernelTrace.STATE_ID);
long startTime = ssq.getStartTime();
long endTime = ssq.getCurrentEndTime() + 1;
long resolution = (endTime - startTime) / fDisplayWidth;
private static List<ITimeEvent> getEventList(ResourcesEntry entry,
long startTime, long endTime, long resolution, boolean includeNull,
IProgressMonitor monitor) {
- ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(LttngKernelTrace.STATE_ID);
final long realStart = Math.max(startTime, ssq.getStartTime());
final long realEnd = Math.min(endTime, ssq.getCurrentEndTime() + 1);
if (realEnd <= realStart) {