Remove unneeded checkNotNull() calls
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.ust.core / src / org / eclipse / tracecompass / lttng2 / ust / core / trace / LttngUstTrace.java
index dd437a8eee36a02e617c38eb03056e9c4ac345ca..6e9345cd4c69bc0f1d292ad187ecdd35769c13ba 100644 (file)
@@ -14,6 +14,7 @@
 
 package org.eclipse.tracecompass.lttng2.ust.core.trace;
 
+import java.util.Collection;
 import java.util.Map;
 
 import org.eclipse.core.resources.IProject;
@@ -25,12 +26,19 @@ import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.lttng2.ust.core.Activator;
 import org.eclipse.tracecompass.internal.lttng2.ust.core.trace.layout.LttngUst20EventLayout;
 import org.eclipse.tracecompass.internal.lttng2.ust.core.trace.layout.LttngUst27EventLayout;
+import org.eclipse.tracecompass.internal.lttng2.ust.core.trace.layout.LttngUst28EventLayout;
+import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoBinaryAspect;
+import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoSourceAspect;
 import org.eclipse.tracecompass.lttng2.ust.core.trace.layout.ILttngUstEventLayout;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus;
 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTraceValidationStatus;
+import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfUtils;
+
+import com.google.common.collect.ImmutableSet;
 
 /**
  * Class to contain LTTng-UST traces
@@ -39,15 +47,33 @@ import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTraceValidationStatus;
  */
 public class LttngUstTrace extends CtfTmfTrace {
 
+    /**
+     * Name of the tracer that generates this trace type, as found in the CTF
+     * metadata.
+     *
+     * @since 2.0
+     */
+    public static final String TRACER_NAME = "lttng-ust"; //$NON-NLS-1$
+
     private static final int CONFIDENCE = 100;
 
+    private static final @NonNull Collection<ITmfEventAspect> LTTNG_UST_ASPECTS;
+
+    static {
+        ImmutableSet.Builder<ITmfEventAspect> builder = ImmutableSet.builder();
+        builder.addAll(CtfTmfTrace.CTF_ASPECTS);
+        builder.add(UstDebugInfoBinaryAspect.INSTANCE);
+        builder.add(UstDebugInfoSourceAspect.INSTANCE);
+        LTTNG_UST_ASPECTS = builder.build();
+    }
+
     private @Nullable ILttngUstEventLayout fLayout = null;
 
     /**
      * Default constructor
      */
     public LttngUstTrace() {
-        super();
+        super(LttngUstEventFactory.instance());
     }
 
     /**
@@ -71,17 +97,19 @@ public class LttngUstTrace extends CtfTmfTrace {
         super.initTrace(resource, path, eventType);
 
         /* Determine the event layout to use from the tracer's version */
-        fLayout = getLayoutFromEnv(this.getEnvironment());
+        fLayout = getLayoutFromEnv();
     }
 
-    private static @NonNull ILttngUstEventLayout getLayoutFromEnv(Map<String, String> traceEnv) {
-        String tracerName = traceEnv.get("tracer_name"); //$NON-NLS-1$
-        String tracerMajor = traceEnv.get("tracer_major"); //$NON-NLS-1$
-        String tracerMinor = traceEnv.get("tracer_minor"); //$NON-NLS-1$
+    private @NonNull ILttngUstEventLayout getLayoutFromEnv() {
+        String tracerName = CtfUtils.getTracerName(this);
+        int tracerMajor = CtfUtils.getTracerMajorVersion(this);
+        int tracerMinor = CtfUtils.getTracerMinorVersion(this);
 
-        if ("\"lttng-ust\"".equals(tracerName) && tracerMajor != null && tracerMinor != null) { //$NON-NLS-1$
-            if (Integer.valueOf(tracerMajor) >= 2) {
-                if (Integer.valueOf(tracerMinor) >= 7) {
+        if (TRACER_NAME.equals(tracerName)) {
+            if (tracerMajor >= 2) {
+                if (tracerMinor >= 8) {
+                    return LttngUst28EventLayout.getInstance();
+                } else if (tracerMinor >= 7) {
                     return LttngUst27EventLayout.getInstance();
                 }
                 return LttngUst20EventLayout.getInstance();
@@ -92,6 +120,11 @@ public class LttngUstTrace extends CtfTmfTrace {
         return LttngUst20EventLayout.getInstance();
     }
 
+    @Override
+    public Iterable<ITmfEventAspect> getEventAspects() {
+        return LTTNG_UST_ASPECTS;
+    }
+
     /**
      * {@inheritDoc}
      * <p>
This page took 0.027434 seconds and 5 git commands to generate.