From f332660b9dd7a89752a8f130ab0ddf778d498d2d Mon Sep 17 00:00:00 2001 From: Matthew Khouzam Date: Thu, 19 Dec 2013 14:55:23 -0500 Subject: [PATCH] tmf: Add additional check for callsites Change-Id: I41b4dfb24290a71ec33e4a57469dcf3e7739a481 Signed-off-by: Matthew Khouzam Reviewed-on: https://git.eclipse.org/r/20074 Reviewed-by: Alexandre Montplaisir IP-Clean: Alexandre Montplaisir Tested-by: Hudson CI --- .../tmf/core/ctfadaptor/CtfTmfEvent.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java index 59423d37be..57e26caeb2 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java @@ -18,6 +18,7 @@ import java.util.Set; import org.eclipse.linuxtools.ctf.core.event.CTFCallsite; import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration; +import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; import org.eclipse.linuxtools.tmf.core.event.ITmfCustomAttributes; import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; import org.eclipse.linuxtools.tmf.core.event.ITmfEventType; @@ -28,8 +29,8 @@ import org.eclipse.linuxtools.tmf.core.event.lookup.ITmfSourceLookup; import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; /** - * A wrapper class around CTF's Event Definition/Declaration that maps all - * types of Declaration to native Java types. + * A wrapper class around CTF's Event Definition/Declaration that maps all types + * of Declaration to native Java types. * * @version 1.0 * @author Alexandre Montplaisir @@ -138,7 +139,10 @@ public class CtfTmfEvent extends TmfEvent @Override public CtfTmfTrace getTrace() { - /* Should be of the right type, since we take a CtfTmfTrace at the constructor */ + /* + * Should be of the right type, since we take a CtfTmfTrace at the + * constructor + */ return (CtfTmfTrace) super.getTrace(); } @@ -183,18 +187,24 @@ public class CtfTmfEvent extends TmfEvent @Override public CtfTmfCallsite getCallsite() { CTFCallsite callsite = null; - if (getTrace() == null) { + CtfTmfTrace trace = getTrace(); + if (trace == null) { + return null; + } + CTFTrace ctfTrace = trace.getCTFTrace(); + /* Should not happen, but it is a good check */ + if (ctfTrace == null) { return null; } if (getContent() != null) { ITmfEventField ipField = getContent().getField(CtfConstants.CONTEXT_FIELD_PREFIX + CtfConstants.IP_KEY); if (ipField != null && ipField.getValue() instanceof Long) { long ip = (Long) ipField.getValue(); - callsite = getTrace().getCTFTrace().getCallsite(eventName, ip); + callsite = ctfTrace.getCallsite(eventName, ip); } } if (callsite == null) { - callsite = getTrace().getCTFTrace().getCallsite(eventName); + callsite = ctfTrace.getCallsite(eventName); } if (callsite != null) { return new CtfTmfCallsite(callsite); -- 2.34.1