package org.eclipse.tracecompass.lttng2.ust.core.trace;
+import java.util.Collection;
import java.util.Map;
import org.eclipse.core.resources.IProject;
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
*/
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());
}
/**
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();
return LttngUst20EventLayout.getInstance();
}
+ @Override
+ public Iterable<ITmfEventAspect> getEventAspects() {
+ return LTTNG_UST_ASPECTS;
+ }
+
/**
* {@inheritDoc}
* <p>