import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.analysis.os.linux.core.kernel.LinuxValues;
import org.eclipse.tracecompass.analysis.os.linux.core.kernel.StateValues;
import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
@Override
public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) throws AttributeNotFoundException {
ITmfEventField content = event.getContent();
- Integer cpu = KernelEventHandlerUtils.getCpu(event);
+ Integer eventCpu = KernelEventHandlerUtils.getCpu(event);
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 = checkNotNull((String) content.getField("name").getValue()); //$NON-NLS-1$
+ /* Only present in LTTng 2.10+ */
+ @Nullable Long cpuField = content.getFieldValue(Long.class, "cpu"); //$NON-NLS-1$
/*
* "mode" could be interesting too, but it doesn't seem to be populated
* with anything relevant for now.
*/
- String threadAttributeName = Attributes.buildThreadAttributeName(tid, cpu);
+ String threadAttributeName = Attributes.buildThreadAttributeName(tid, eventCpu);
if (threadAttributeName == null) {
return;
}
setPpid(ss, tid, pid, ppid, curThreadNode, timestamp);
/* Set the process' status */
- setStatus(ss, status, curThreadNode, timestamp);
+ setStatus(ss, status, curThreadNode, cpuField, timestamp);
}
- private static void setStatus(ITmfStateSystemBuilder ss, int status, int curThreadNode, long timestamp) {
+ private static void setStatus(ITmfStateSystemBuilder ss, int status, int curThreadNode, @Nullable Long cpu, long timestamp) {
ITmfStateValue value;
if (ss.queryOngoingState(curThreadNode).isNull()) {
switch (status) {
case LinuxValues.STATEDUMP_PROCESS_STATUS_WAIT_CPU:
value = StateValues.PROCESS_STATUS_WAIT_FOR_CPU_VALUE;
+ setRunQueue(ss, curThreadNode, cpu, timestamp);
break;
case LinuxValues.STATEDUMP_PROCESS_STATUS_WAIT:
/*
}
}
+ private static void setRunQueue(ITmfStateSystemBuilder ss, int curThreadNode, @Nullable Long cpu, long timestamp) {
+ if (cpu != null) {
+ int quark = ss.getQuarkRelativeAndAdd(curThreadNode, Attributes.CURRENT_CPU_RQ);
+ ITmfStateValue value = TmfStateValue.newValueInt(cpu.intValue());
+ ss.modifyAttribute(timestamp, value, quark);
+ }
+ }
+
private static void setPpid(ITmfStateSystemBuilder ss, int tid, int pid, int ppid, int curThreadNode, long timestamp) {
ITmfStateValue value;
int quark;