Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Khouzam2018-04-12 14:19:47 -0400
committerMatthew Khouzam2018-07-03 15:25:28 -0400
commit0828db344f34d1d743be4bc1614fbfa9f3a6c2e8 (patch)
tree0797996fa2b2c4eacc0b3000420904f6f2700a3f
parentb47a40fed508b16904609d57edab0b1f9bc5bb76 (diff)
downloadorg.eclipse.tracecompass.incubator-0828db344f34d1d743be4bc1614fbfa9f3a6c2e8.tar.gz
org.eclipse.tracecompass.incubator-0828db344f34d1d743be4bc1614fbfa9f3a6c2e8.tar.xz
org.eclipse.tracecompass.incubator-0828db344f34d1d743be4bc1614fbfa9f3a6c2e8.zip
ftrace: fix NPE on last line
Fix NPE on small traces. Also fix parsing error for long ints, like timestamps. Change-Id: I42cca94d7412b0dee9ba4c94fdbb12241d0f78ba Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Reviewed-on: https://git.eclipse.org/r/121096 Tested-by: CI Bot Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.ftrace.core/src/org/eclipse/tracecompass/incubator/internal/ftrace/core/event/GenericFtraceField.java2
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.ftrace.core/src/org/eclipse/tracecompass/incubator/internal/ftrace/core/trace/GenericFtrace.java8
2 files changed, 8 insertions, 2 deletions
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.ftrace.core/src/org/eclipse/tracecompass/incubator/internal/ftrace/core/event/GenericFtraceField.java b/tracetypes/org.eclipse.tracecompass.incubator.ftrace.core/src/org/eclipse/tracecompass/incubator/internal/ftrace/core/event/GenericFtraceField.java
index d5bfe764..263c7592 100644
--- a/tracetypes/org.eclipse.tracecompass.incubator.ftrace.core/src/org/eclipse/tracecompass/incubator/internal/ftrace/core/event/GenericFtraceField.java
+++ b/tracetypes/org.eclipse.tracecompass.incubator.ftrace.core/src/org/eclipse/tracecompass/incubator/internal/ftrace/core/event/GenericFtraceField.java
@@ -135,7 +135,7 @@ public class GenericFtraceField {
if (key.equals("prev_state")) { //$NON-NLS-1$
fields.put(key, PREV_STATE_LUT.getOrDefault(value.charAt(0), 0L));
} else if (StringUtils.isNumeric(value)) {
- fields.put(key, Long.parseLong(value));
+ fields.put(key, Long.parseUnsignedLong(value));
} else {
fields.put(key, value);
}
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.ftrace.core/src/org/eclipse/tracecompass/incubator/internal/ftrace/core/trace/GenericFtrace.java b/tracetypes/org.eclipse.tracecompass.incubator.ftrace.core/src/org/eclipse/tracecompass/incubator/internal/ftrace/core/trace/GenericFtrace.java
index 85c5a7fd..30187ea7 100644
--- a/tracetypes/org.eclipse.tracecompass.incubator.ftrace.core/src/org/eclipse/tracecompass/incubator/internal/ftrace/core/trace/GenericFtrace.java
+++ b/tracetypes/org.eclipse.tracecompass.incubator.ftrace.core/src/org/eclipse/tracecompass/incubator/internal/ftrace/core/trace/GenericFtrace.java
@@ -107,11 +107,17 @@ public abstract class GenericFtrace extends TmfTrace implements IKernelTrace {
if (location == null) {
fFileInput.seek(0);
long lineStartOffset = fFileInput.getFilePointer();
- String line = fFileInput.readLine();
+ @Nullable String line = fFileInput.readLine();
+ if (line == null) {
+ return context;
+ }
Matcher matcher = IGenericFtraceConstants.FTRACE_PATTERN.matcher(line);
while (!matcher.matches()) {
lineStartOffset = fFileInput.getFilePointer();
line = fFileInput.readLine();
+ if (line == null) {
+ break;
+ }
matcher = IGenericFtraceConstants.FTRACE_PATTERN.matcher(line);
}
fFileInput.seek(lineStartOffset);

Back to the top