diff options
author | Matthew Khouzam | 2017-09-15 19:15:33 +0000 |
---|---|---|
committer | Matthew Khouzam | 2017-09-16 02:08:01 +0000 |
commit | 766225da345a6798b6fd012756ca1934a6f13c14 (patch) | |
tree | f755cd34a742c045913611c389c5b619002e2f66 | |
parent | 81e537c91d9a288592a4efdad78dea709e95d283 (diff) | |
download | org.eclipse.tracecompass-766225da345a6798b6fd012756ca1934a6f13c14.tar.gz org.eclipse.tracecompass-766225da345a6798b6fd012756ca1934a6f13c14.tar.xz org.eclipse.tracecompass-766225da345a6798b6fd012756ca1934a6f13c14.zip |
tmf.ctf: handle when fTrace is disposed.
Change-Id: I0d11125a2056ccba3e19929a80f9b86e4489198c
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/105245
Reviewed-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Tested-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Reviewed-by: Yonni Chen <yonni.chen.kuang.piao@ericsson.com>
Reviewed-by: Hudson CI
-rw-r--r-- | ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java | 90 |
1 files changed, 64 insertions, 26 deletions
diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java index 758dbe8dd9..4ede155bd1 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java @@ -449,11 +449,14 @@ public class CtfTmfTrace extends TmfTrace */ @Override public String getHostId() { - CTFClock clock = fTrace.getClock(); - if (clock != null) { - String clockHost = (String) clock.getProperty(CLOCK_HOST_PROPERTY); - if (clockHost != null) { - return clockHost; + CTFTrace trace = fTrace; + if (trace != null) { + CTFClock clock = trace.getClock(); + if (clock != null) { + String clockHost = (String) clock.getProperty(CLOCK_HOST_PROPERTY); + if (clockHost != null) { + return clockHost; + } } } return super.getHostId(); @@ -468,11 +471,14 @@ public class CtfTmfTrace extends TmfTrace * @since 3.0 */ public @Nullable CtfTmfCallsite getCallsite(String eventName) { - for (ICTFStream stream : fTrace.getStreams()) { - for (IEventDeclaration eventDeclaration : stream.getEventDeclarations()) { - if (eventDeclaration != null && Objects.equals(eventDeclaration.getName(), eventName) && - !eventDeclaration.getCallsites().isEmpty()) { - return new CtfTmfCallsite(eventDeclaration.getCallsites().get(0)); + CTFTrace trace = fTrace; + if (trace != null) { + for (ICTFStream stream : fTrace.getStreams()) { + for (IEventDeclaration eventDeclaration : stream.getEventDeclarations()) { + if (eventDeclaration != null && Objects.equals(eventDeclaration.getName(), eventName) && + !eventDeclaration.getCallsites().isEmpty()) { + return new CtfTmfCallsite(eventDeclaration.getCallsites().get(0)); + } } } } @@ -492,12 +498,15 @@ public class CtfTmfTrace extends TmfTrace */ public @Nullable CtfTmfCallsite getCallsite(String eventName, long ip) { CtfTmfCallsite callsite = null; - for (ICTFStream stream : fTrace.getStreams()) { - for (IEventDeclaration eventDeclaration : stream.getEventDeclarations()) { - if (eventDeclaration != null && Objects.equals(eventDeclaration.getName(), eventName)) { - for (CTFCallsite cs : eventDeclaration.getCallsites()) { - if (cs.getIp() >= ip && (callsite == null || cs.getIp() < callsite.getIntructionPointer())) { - callsite = new CtfTmfCallsite(cs); + CTFTrace trace = fTrace; + if (trace != null) { + for (ICTFStream stream : trace.getStreams()) { + for (IEventDeclaration eventDeclaration : stream.getEventDeclarations()) { + if (eventDeclaration != null && Objects.equals(eventDeclaration.getName(), eventName)) { + for (CTFCallsite cs : eventDeclaration.getCallsites()) { + if (cs.getIp() >= ip && (callsite == null || cs.getIp() < callsite.getIntructionPointer())) { + callsite = new CtfTmfCallsite(cs); + } } } } @@ -513,7 +522,11 @@ public class CtfTmfTrace extends TmfTrace * @return The CTF environment */ public Map<String, String> getEnvironment() { - return fTrace.getEnvironment(); + CTFTrace trace = fTrace; + if (trace == null) { + return Collections.emptyMap(); + } + return trace.getEnvironment(); } /** @@ -521,7 +534,11 @@ public class CtfTmfTrace extends TmfTrace */ @Override public UUID getUUID() { - UUID uuid = fTrace.getUUID(); + CTFTrace trace = fTrace; + if (trace == null) { + return null; + } + UUID uuid = trace.getUUID(); return uuid == null ? super.getUUID() : uuid; } @@ -535,8 +552,12 @@ public class CtfTmfTrace extends TmfTrace @Override public Map<String, String> getProperties() { Map<String, String> properties = new HashMap<>(); - properties.putAll(fTrace.getEnvironment()); - properties.put(CLOCK_OFFSET, Long.toUnsignedString(fTrace.getOffset())); + CTFTrace trace = fTrace; + if( trace == null) { + return properties; + } + properties.putAll(trace.getEnvironment()); + properties.put(CLOCK_OFFSET, Long.toUnsignedString(trace.getOffset())); properties.put(Messages.CtfTmfTrace_HostID, getHostId()); return properties; } @@ -551,8 +572,9 @@ public class CtfTmfTrace extends TmfTrace * @return the clock offset with respect to POSIX.1 Epoch in cycles */ public long getOffset() { - if (fTrace != null) { - return fTrace.getOffset(); + CTFTrace trace = fTrace; + if (trace != null) { + return trace.getOffset(); } return 0; } @@ -566,7 +588,11 @@ public class CtfTmfTrace extends TmfTrace * @return The timestamp in nanoseconds, relative to POSIX.1 Epoch */ public long timestampCyclesToNanos(long cycles) { - return fTrace.timestampCyclesToNanos(cycles); + CTFTrace trace = fTrace; + if (trace != null) { + return trace.timestampCyclesToNanos(cycles); + } + return 0; } /** @@ -578,7 +604,11 @@ public class CtfTmfTrace extends TmfTrace * @return The timestamp in cycles, relative to the clock offset */ public long timestampNanoToCycles(long nanos) { - return fTrace.timestampNanoToCycles(nanos); + CTFTrace trace = fTrace; + if( trace != null) { + return trace.timestampNanoToCycles(nanos); + } + return 0; } /** @@ -805,7 +835,11 @@ public class CtfTmfTrace extends TmfTrace @Override public long cyclesToNanos(long cycles) { // CTFTrace adds the clock offset in cycles to the input - return fTrace.timestampCyclesToNanos(cycles - fTrace.getOffset()); + CTFTrace trace = fTrace; + if (trace != null) { + return fTrace.timestampCyclesToNanos(cycles - trace.getOffset()); + } + return 0; } /** @@ -814,7 +848,11 @@ public class CtfTmfTrace extends TmfTrace @Override public long nanosToCycles(long nanos) { // CTFTrace subtracts the clock offset in cycles from the output - return fTrace.timestampNanoToCycles(nanos) + fTrace.getOffset(); + CTFTrace trace = fTrace; + if (trace != null) { + return trace.timestampNanoToCycles(nanos) + fTrace.getOffset(); + } + return 0; } /** |