tmf: Add additional check for callsites
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Thu, 19 Dec 2013 19:55:23 +0000 (14:55 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Tue, 14 Jan 2014 16:02:12 +0000 (11:02 -0500)
Change-Id: I41b4dfb24290a71ec33e4a57469dcf3e7739a481
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/20074
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Tested-by: Hudson CI
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java

index 59423d37be0e26525316809cebe48e3080a1716e..57e26caeb236b16d2b12e750f57914f5a08ab185 100644 (file)
@@ -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);
This page took 0.051421 seconds and 5 git commands to generate.