import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelTidAspect;
import org.eclipse.tracecompass.common.core.NonNullUtils;
import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
-import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers.KernelEventHandlerUtils;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
/* Find the CPU this event is run on */
cpu = TmfTraceUtils.resolveIntEventAspectOfClassForEvent(trace, TmfCpuAspect.class, event);
}
- int execPrioQuark = ss.getQuarkAbsolute(Attributes.THREADS, KernelEventHandlerUtils.buildThreadAttributeName(tid, cpu), Attributes.PRIO);
+ int execPrioQuark = ss.getQuarkAbsolute(Attributes.THREADS, Attributes.buildThreadAttributeName(tid, cpu), Attributes.PRIO);
ITmfStateInterval interval = ss.querySingleState(ts, execPrioQuark);
ITmfStateValue prioValue = interval.getStateValue();
/* We know the prio must be an Integer */
package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.tmf.core.util.Pair;
+
/**
* This file defines all the attribute names used in the handler. Both the
* construction and query steps should use them.
* be done on the viewer side.
*
* @author Alexandre Montplaisir
- * @since 2.0
*/
-@SuppressWarnings({"nls", "javadoc"})
+@SuppressWarnings({ "nls", "javadoc" })
public interface Attributes {
/* First-level attributes */
/* Sub-attributes of the Thread nodes */
String PPID = "PPID";
- //static final String STATUS = "Status"
+ // static final String STATUS = "Status"
String EXEC_NAME = "Exec_name";
- /** @since 1.0 */
String PRIO = "Prio";
String SYSTEM_CALL = "System_call";
String UNKNOWN = "Unknown";
String THREAD_0_PREFIX = "0_";
String THREAD_0_SEPARATOR = "_";
+
+ /**
+ * Build the thread attribute name.
+ *
+ * For all threads except "0" this is the string representation of the
+ * threadId. For thread "0" which is the idle thread and can be running
+ * concurrently on multiple CPUs, append "_cpuId".
+ *
+ * @param threadId
+ * the thread id
+ * @param cpuId
+ * the cpu id
+ * @return the thread attribute name null if the threadId is zero and the
+ * cpuId is null
+ */
+ public static @Nullable String buildThreadAttributeName(int threadId, @Nullable Integer cpuId) {
+ if (threadId == 0) {
+ if (cpuId == null) {
+ return null;
+ }
+ return Attributes.THREAD_0_PREFIX + String.valueOf(cpuId);
+ }
+
+ return String.valueOf(threadId);
+ }
+
+ /**
+ * Parse the thread id and CPU id from the thread attribute name string
+ *
+ * For thread "0" the attribute name is in the form "threadId_cpuId",
+ * extract both values from the string.
+ *
+ * For all other threads, the attribute name is the string representation of
+ * the threadId and there is no cpuId.
+ *
+ * @param threadAttributeName
+ * the thread attribute name
+ * @return the thread id and cpu id
+ */
+ public static Pair<Integer, Integer> parseThreadAttributeName(String threadAttributeName) {
+ Integer threadId = -1;
+ Integer cpuId = -1;
+
+ try {
+ if (threadAttributeName.startsWith(Attributes.THREAD_0_PREFIX)) {
+ threadId = 0;
+ String[] tokens = threadAttributeName.split(Attributes.THREAD_0_SEPARATOR);
+ cpuId = Integer.parseInt(tokens[1]);
+ } else {
+ threadId = Integer.parseInt(threadAttributeName);
+ }
+ } catch (NumberFormatException e1) {
+ // pass
+ }
+
+ return new Pair<>(threadId, cpuId);
+ }
}
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.event.aspect.TmfCpuAspect;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
-import org.eclipse.tracecompass.tmf.core.util.Pair;
/**
* Kernel Event Handler Utils is a collection of static methods to be used in
int quark = ss.getQuarkRelativeAndAdd(getCurrentCPUNode(cpuNumber, ss), Attributes.CURRENT_THREAD);
ITmfStateValue value = ss.queryOngoingState(quark);
int thread = value.isNull() ? -1 : value.unboxInt();
- return ss.getQuarkRelativeAndAdd(getNodeThreads(ss), buildThreadAttributeName(thread, cpuNumber));
+ return ss.getQuarkRelativeAndAdd(getNodeThreads(ss), Attributes.buildThreadAttributeName(thread, cpuNumber));
}
/**
StateValues.CPU_STATUS_RUN_USERMODE_VALUE :
StateValues.CPU_STATUS_RUN_SYSCALL_VALUE);
}
-
- /**
- * Build the thread attribute name.
- *
- * For all threads except "0" this is the string representation of the threadId.
- * For thread "0" which is the idle thread and can be running concurrently on multiple
- * CPUs, append "_cpuId".
- *
- * @param threadId
- * the thread id
- * @param cpuId
- * the cpu id
- *
- * @return the thread attribute name
- * null if the threadId is zero and the cpuId is null
- */
- public static @Nullable String buildThreadAttributeName(int threadId, @Nullable Integer cpuId) {
-
- if (threadId == 0) {
- if (cpuId == null) {
- return null;
- }
- return Attributes.THREAD_0_PREFIX + String.valueOf(cpuId);
- }
-
- return String.valueOf(threadId);
- }
-
- /**
- * Parse the thread id and CPU id from the thread attribute name string
- *
- * For thread "0" the attribute name is in the form "threadId_cpuId", extract both
- * values from the string.
- *
- * For all other threads, the attribute name is the string representation of the
- * threadId and there is no cpuId.
- *
- * @param threadAttributeName
- * the thread attribute name
- * @return the thread id and cpu id
- */
- public static Pair<Integer, Integer> parseThreadAttributeName(String threadAttributeName) {
- Integer threadId = -1;
- Integer cpuId = -1;
-
- try {
- if (threadAttributeName.startsWith(Attributes.THREAD_0_PREFIX)) {
- threadId = 0;
- String[] tokens = threadAttributeName.split(Attributes.THREAD_0_SEPARATOR);
- cpuId = Integer.parseInt(tokens[1]);
- } else {
- threadId = Integer.parseInt(threadAttributeName);
- }
- } catch (NumberFormatException e1) {
- //pass
- }
-
- return new Pair<>(threadId, cpuId);
- }
}
Integer tid = ((Long) content.getField(getLayout().fieldTid()).getValue()).intValue();
Integer prio = ((Long) content.getField(getLayout().fieldNewPrio()).getValue()).intValue();
- String threadAttributeName = KernelEventHandlerUtils.buildThreadAttributeName(tid, cpu);
+ String threadAttributeName = Attributes.buildThreadAttributeName(tid, cpu);
if (threadAttributeName == null) {
return;
}
Integer parentTid = ((Long) content.getField(getLayout().fieldParentTid()).getValue()).intValue();
Integer childTid = ((Long) content.getField(getLayout().fieldChildTid()).getValue()).intValue();
- String parentThreadAttributeName = KernelEventHandlerUtils.buildThreadAttributeName(parentTid, cpu);
+ String parentThreadAttributeName = Attributes.buildThreadAttributeName(parentTid, cpu);
if (parentThreadAttributeName == null) {
return;
}
- String childThreadAttributeName = KernelEventHandlerUtils.buildThreadAttributeName(childTid, cpu);
+ String childThreadAttributeName = Attributes.buildThreadAttributeName(childTid, cpu);
if (childThreadAttributeName == null) {
return;
}
package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers;
import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
+import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
Integer cpu = KernelEventHandlerUtils.getCpu(event);
Integer tid = ((Long) event.getContent().getField(getLayout().fieldTid()).getValue()).intValue();
- String threadAttributeName = KernelEventHandlerUtils.buildThreadAttributeName(tid, cpu);
+ String threadAttributeName = Attributes.buildThreadAttributeName(tid, cpu);
if (threadAttributeName == null) {
return;
}
Integer nextPrio = ((Long) content.getField(getLayout().fieldNextPrio()).getValue()).intValue();
/* Will never return null since "cpu" is null checked */
- String formerThreadAttributeName = KernelEventHandlerUtils.buildThreadAttributeName(prevTid, cpu);
- String currenThreadAttributeName = KernelEventHandlerUtils.buildThreadAttributeName(nextTid, cpu);
+ String formerThreadAttributeName = Attributes.buildThreadAttributeName(prevTid, cpu);
+ String currenThreadAttributeName = Attributes.buildThreadAttributeName(nextTid, cpu);
int nodeThreads = KernelEventHandlerUtils.getNodeThreads(ss);
int formerThreadNode = ss.getQuarkRelativeAndAdd(nodeThreads, formerThreadAttributeName);
final int tid = ((Long) event.getContent().getField(getLayout().fieldTid()).getValue()).intValue();
final int prio = ((Long) event.getContent().getField(getLayout().fieldPrio()).getValue()).intValue();
- String threadAttributeName = KernelEventHandlerUtils.buildThreadAttributeName(tid, cpu);
+ String threadAttributeName = Attributes.buildThreadAttributeName(tid, cpu);
if (threadAttributeName == null) {
return;
}
* with anything relevant for now.
*/
- String threadAttributeName = KernelEventHandlerUtils.buildThreadAttributeName(tid, cpu);
+ String threadAttributeName = Attributes.buildThreadAttributeName(tid, cpu);
if (threadAttributeName == null) {
return;
}
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule;
import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
-import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers.KernelEventHandlerUtils;
import org.eclipse.tracecompass.internal.analysis.os.linux.ui.Activator;
import org.eclipse.tracecompass.internal.analysis.os.linux.ui.Messages;
import org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions.FollowThreadAction;
for (int threadQuark : threadQuarks) {
String threadAttributeName = ssq.getAttributeName(threadQuark);
- Pair<Integer, Integer> entryKey = KernelEventHandlerUtils.parseThreadAttributeName(threadAttributeName);
+ Pair<Integer, Integer> entryKey = Attributes.parseThreadAttributeName(threadAttributeName);
int threadId = entryKey.getFirst();
if (threadId < 0) { // ignore the 'unknown' (-1) thread