diff --git a/tracetypes/org.eclipse.tracecompass.incubator.traceevent.core/src/org/eclipse/tracecompass/incubator/internal/traceevent/core/event/TraceEventAspects.java b/tracetypes/org.eclipse.tracecompass.incubator.traceevent.core/src/org/eclipse/tracecompass/incubator/internal/traceevent/core/event/TraceEventAspects.java index 0981f3788..eb9a16e35 100644 --- a/tracetypes/org.eclipse.tracecompass.incubator.traceevent.core/src/org/eclipse/tracecompass/incubator/internal/traceevent/core/event/TraceEventAspects.java +++ b/tracetypes/org.eclipse.tracecompass.incubator.traceevent.core/src/org/eclipse/tracecompass/incubator/internal/traceevent/core/event/TraceEventAspects.java @@ -159,7 +159,14 @@ public boolean isHiddenByDefault() { @Override public @Nullable Integer resolve(@NonNull ITmfEvent event) { if (event instanceof TraceEventEvent) { - return ((TraceEventEvent) event).getField().getTid(); + Object tid = ((TraceEventEvent) event).getField().getTid(); + if (tid instanceof Integer) { + return (Integer) tid; + } + if (tid != null) { + return tid.hashCode(); + } + } return null; } diff --git a/tracetypes/org.eclipse.tracecompass.incubator.traceevent.core/src/org/eclipse/tracecompass/incubator/internal/traceevent/core/event/TraceEventField.java b/tracetypes/org.eclipse.tracecompass.incubator.traceevent.core/src/org/eclipse/tracecompass/incubator/internal/traceevent/core/event/TraceEventField.java index 6782ca143..a3c4f2678 100644 --- a/tracetypes/org.eclipse.tracecompass.incubator.traceevent.core/src/org/eclipse/tracecompass/incubator/internal/traceevent/core/event/TraceEventField.java +++ b/tracetypes/org.eclipse.tracecompass.incubator.traceevent.core/src/org/eclipse/tracecompass/incubator/internal/traceevent/core/event/TraceEventField.java @@ -51,7 +51,7 @@ public class TraceEventField { private final String fName; private ITmfEventField fContent; private final @Nullable Map fArgs; - private final @Nullable Integer fTid; + private final @Nullable Object fTid; private final @Nullable String fCategory; private final @Nullable String fId; private final @Nullable Long fDuration; @@ -91,10 +91,7 @@ public class TraceEventField { } // We differentiate between the duration exit and the other exits for some reason String name = String.valueOf(optString(root, ITraceEventConstants.NAME, TraceEventPhases.DURATION_END.equals(phase) ? UNKNOWN_DURATION_EXIT_EVENT : UNKNOWN_EXIT_EVENT)); - Integer tid = optInt(root, ITraceEventConstants.TID); - if (tid == Integer.MIN_VALUE) { - tid = null; - } + String tid = optString(root, ITraceEventConstants.TID, null); JsonElement jsonElement = root.get(ITraceEventConstants.PID); JsonPrimitive primitive = jsonElement == null ? null : jsonElement.isJsonPrimitive() ? jsonElement.getAsJsonPrimitive() : null; Object pid = primitive == null ? null : primitive.isNumber() ? primitive.getAsNumber() : primitive.isString() ? primitive.getAsString() : null; @@ -143,11 +140,6 @@ private static double optDouble(JsonObject root, String key) { return jsonElement != null ? jsonElement.getAsDouble() : Double.NaN; } - private static int optInt(JsonObject root, String key) { - JsonElement jsonElement = root.get(key); - return jsonElement != null ? jsonElement.getAsInt() : Integer.MIN_VALUE; - } - private static @Nullable JsonObject optJSONObject(JsonObject root, String key) { JsonElement jsonElement = root.get(key); return jsonElement != null ? jsonElement.getAsJsonObject() : null; @@ -184,7 +176,7 @@ private static int optInt(JsonObject root, String key) { * @param fields * event fields (arguments) */ - protected TraceEventField(String name, long ts, String phase, @Nullable Object pid, @Nullable Integer tid, @Nullable String category, @Nullable String id, @Nullable Double duration, Map fields) { + protected TraceEventField(String name, long ts, String phase, @Nullable Object pid, @Nullable Object tid, @Nullable String category, @Nullable String id, @Nullable Double duration, Map fields) { fName = name; fPid = pid; fTid = tid; @@ -258,7 +250,7 @@ public char getPhase() { * * @return the event TID */ - public @Nullable Integer getTid() { + public @Nullable Object getTid() { return fTid; } 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 475aed544..5f94c969d 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 @@ -289,6 +289,7 @@ private void parseMetadata(TraceEventField field) { return; } Map<@NonNull String, @NonNull String> properties = fProperties; + Object tid = field.getTid(); switch (name) { case PROCESS_NAME: String procName = (String) args.get(NAME_ARG); @@ -311,15 +312,17 @@ private void parseMetadata(TraceEventField field) { break; case THREAD_NAME: String threadName = (String) args.get(NAME_ARG); - fTidNames.put(field.getTid(), threadName); + if (tid instanceof Integer) { + fTidNames.put((Integer) tid, threadName); + } if (threadName != null) { - properties.put(TID_PREFIX + field.getTid(), threadName); + properties.put(TID_PREFIX + tid, threadName); } break; case THREAD_SORT_INDEX: sortIndex = (String) args.get(SORT_INDEX); if (sortIndex != null) { - properties.put(name + '-' + field.getTid(), sortIndex); + properties.put(name + '-' + tid, sortIndex); } break; default: @@ -355,8 +358,12 @@ public class ThreadNameAspect extends org.eclipse.tracecompass.incubator.analysi public @Nullable String resolve(@NonNull ITmfEvent event) { if (event instanceof TraceEventEvent) { TraceEventField field = ((TraceEventEvent) event).getField(); - if (field.getTid() != null) { - return fTidNames.get(field.getTid()); + Object tid = field.getTid(); + if (tid != null) { + String tidName = fTidNames.get(tid); + if (tidName == null) { + return String.valueOf(tid); + } } } return null;