linux.core: Make prev_comm optional in sched_switch
bug: 573812
Traces like ftrace don't have the prev_comm field, make it optional.
[fixed] handle traces with missing prev_comm fields
Change-Id: Id0b005a1d137b9fd1c79075447d918711906e167
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/181114
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/handlers/SchedSwitchHandler.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/handlers/SchedSwitchHandler.java
index 6c5f010..a3ae88c 100644
--- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/handlers/SchedSwitchHandler.java
+++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/handlers/SchedSwitchHandler.java
@@ -14,8 +14,6 @@
package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers;
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
import org.eclipse.tracecompass.analysis.os.linux.core.kernel.StateValues;
import org.eclipse.tracecompass.analysis.os.linux.core.model.ProcessStatus;
import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
@@ -50,7 +48,7 @@
}
ITmfEventField content = event.getContent();
- String prevProcessName = checkNotNull((String) content.getField(getLayout().fieldPrevComm()).getValue());
+ String prevProcessName = content.getFieldValue(String.class, getLayout().fieldPrevComm());
Integer prevTid = content.getFieldValue(Integer.class, getLayout().fieldPrevTid());
Long prevState = content.getFieldValue(Long.class, getLayout().fieldPrevState());
Integer prevPrio = content.getFieldValue(Integer.class, getLayout().fieldPrevPrio());
@@ -88,7 +86,9 @@
ss.modifyAttribute(timestamp, cpu, quark);
/* Set the exec name of the former process */
- setProcessExecName(ss, prevProcessName, formerThreadNode, timestamp);
+ if (prevProcessName != null) {
+ setProcessExecName(ss, prevProcessName, formerThreadNode, timestamp);
+ }
/* Set the exec name of the new process */
if (nextProcessName != null) {