Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Khouzam2018-07-10 10:42:25 -0400
committerMatthew Khouzam2018-07-10 14:47:55 -0400
commit95327d9c961e6a4bd0c65840b2cf38f617bc524d (patch)
tree75a8f254eb1f148a662db0ae29e19a45867a18e2
parenta843bbaa844461a9c1f96ab0f4a58a31952219fb (diff)
downloadorg.eclipse.tracecompass.incubator-95327d9c961e6a4bd0c65840b2cf38f617bc524d.tar.gz
org.eclipse.tracecompass.incubator-95327d9c961e6a4bd0c65840b2cf38f617bc524d.tar.xz
org.eclipse.tracecompass.incubator-95327d9c961e6a4bd0c65840b2cf38f617bc524d.zip
traceevent.core: Handle validating prettied JSON
Also don't load the entire trace in ram if it is one line. Change-Id: I5940a93fca4cda030644855f13082f0fec3ee623 Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Reviewed-on: https://git.eclipse.org/r/125884 Tested-by: CI Bot Reviewed-by: Simon Delisle <simon.delisle@ericsson.com>
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.traceevent.core/src/org/eclipse/tracecompass/incubator/internal/traceevent/core/trace/TraceEventTrace.java26
1 files changed, 22 insertions, 4 deletions
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.traceevent.core/src/org/eclipse/tracecompass/incubator/internal/traceevent/core/trace/TraceEventTrace.java b/tracetypes/org.eclipse.tracecompass.incubator.traceevent.core/src/org/eclipse/tracecompass/incubator/internal/traceevent/core/trace/TraceEventTrace.java
index 5c12fe23..4a30c8d5 100644
--- a/tracetypes/org.eclipse.tracecompass.incubator.traceevent.core/src/org/eclipse/tracecompass/incubator/internal/traceevent/core/trace/TraceEventTrace.java
+++ b/tracetypes/org.eclipse.tracecompass.incubator.traceevent.core/src/org/eclipse/tracecompass/incubator/internal/traceevent/core/trace/TraceEventTrace.java
@@ -13,9 +13,11 @@ import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.NavigableMap;
+import java.util.Set;
import java.util.TreeMap;
import org.eclipse.core.resources.IProject;
@@ -156,11 +158,27 @@ public class TraceEventTrace extends JsonTrace {
@Override
public void goToCorrectStart(RandomAccessFile rafile) throws IOException {
// skip start if it's {"traceEvents":
- String readLine = rafile.readLine();
- if (readLine == null) {
- return;
+ String traceEventsKey = "\"traceEvents\""; //$NON-NLS-1$
+ StringBuilder sb = new StringBuilder();
+ int val = rafile.read();
+ /*
+ * Skip list contains all the odd control characters
+ */
+ Set<Integer> skipList = new HashSet<>();
+ skipList.add((int) ':');
+ skipList.add((int) '\t');
+ skipList.add((int) '\n');
+ skipList.add((int) '\r');
+ skipList.add((int) ' ');
+ skipList.add((int) '\b');
+ skipList.add((int) '\f');
+ while (val != -1 && val != ':' && sb.length() < 14) {
+ if (!skipList.contains(val)) {
+ sb.append(val);
+ }
+ val = rafile.read();
}
- if (readLine.startsWith("{\"traceEvents\":")) { //$NON-NLS-1$
+ if (sb.toString().startsWith('{' + traceEventsKey) && rafile.length() > 14) {
rafile.seek(14);
} else {
rafile.seek(0);

Back to the top