lttng: Add a Binary Callsite aspect to the debug-info analysis
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.ust.core / src / org / eclipse / tracecompass / lttng2 / ust / core / trace / LttngUstTrace.java
CommitLineData
91fc3690 1/**********************************************************************
60ae41e1 2 * Copyright (c) 2013, 2014 Ericsson
91fc3690
AM
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Matthew Khouzam - Initial API and implementation
1c6660ca 11 * Alexandre Montplaisir - Add UST callstack state system
af015d44 12 * Marc-Andre Laperle - Handle BufferOverflowException (Bug 420203)
91fc3690
AM
13 **********************************************************************/
14
9bc60be7 15package org.eclipse.tracecompass.lttng2.ust.core.trace;
91fc3690 16
ef7f180d 17import java.util.Collection;
747fd87b 18import java.util.Map;
1c6660ca 19
91fc3690 20import org.eclipse.core.resources.IProject;
7443de72 21import org.eclipse.core.resources.IResource;
91fc3690
AM
22import org.eclipse.core.runtime.IStatus;
23import org.eclipse.core.runtime.Status;
7443de72
AM
24import org.eclipse.jdt.annotation.NonNull;
25import org.eclipse.jdt.annotation.Nullable;
ef7f180d 26import org.eclipse.tracecompass.common.core.NonNullUtils;
9bc60be7 27import org.eclipse.tracecompass.internal.lttng2.ust.core.Activator;
7443de72
AM
28import org.eclipse.tracecompass.internal.lttng2.ust.core.trace.layout.LttngUst20EventLayout;
29import org.eclipse.tracecompass.internal.lttng2.ust.core.trace.layout.LttngUst27EventLayout;
ef7f180d 30import org.eclipse.tracecompass.internal.lttng2.ust.core.trace.layout.LttngUst28EventLayout;
df993132 31import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoBinaryAspect;
a103fe67 32import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoSourceAspect;
7443de72
AM
33import org.eclipse.tracecompass.lttng2.ust.core.trace.layout.ILttngUstEventLayout;
34import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
ef7f180d 35import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
7443de72 36import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
2bdf0193 37import org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus;
9722e5d7 38import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
747fd87b 39import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTraceValidationStatus;
542ddfb3 40import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfUtils;
91fc3690 41
ef7f180d
AM
42import com.google.common.collect.ImmutableSet;
43
91fc3690
AM
44/**
45 * Class to contain LTTng-UST traces
46 *
47 * @author Matthew Khouzam
91fc3690
AM
48 */
49public class LttngUstTrace extends CtfTmfTrace {
50
ef7f180d
AM
51 /**
52 * Name of the tracer that generates this trace type, as found in the CTF
53 * metadata.
54 *
55 * @since 2.0
56 */
57 public static final String TRACER_NAME = "lttng-ust"; //$NON-NLS-1$
58
cd43d683
PT
59 private static final int CONFIDENCE = 100;
60
ef7f180d
AM
61 private static final @NonNull Collection<ITmfEventAspect> LTTNG_UST_ASPECTS;
62
63 static {
64 ImmutableSet.Builder<ITmfEventAspect> builder = ImmutableSet.builder();
65 builder.addAll(CtfTmfTrace.CTF_ASPECTS);
df993132 66 builder.add(UstDebugInfoBinaryAspect.INSTANCE);
a103fe67 67 builder.add(UstDebugInfoSourceAspect.INSTANCE);
ef7f180d
AM
68 LTTNG_UST_ASPECTS = NonNullUtils.checkNotNull(builder.build());
69 }
70
7443de72
AM
71 private @Nullable ILttngUstEventLayout fLayout = null;
72
91fc3690
AM
73 /**
74 * Default constructor
75 */
76 public LttngUstTrace() {
5c82e602 77 super(LttngUstEventFactory.instance());
91fc3690
AM
78 }
79
7443de72
AM
80 /**
81 * Get the event layout to use with this trace. This normally depends on the
82 * tracer's version.
83 *
84 * @return The event layout
85 * @since 2.0
86 */
87 public @NonNull ILttngUstEventLayout getEventLayout() {
88 ILttngUstEventLayout layout = fLayout;
89 if (layout == null) {
90 throw new IllegalStateException("Cannot get the layout of a non-initialized trace!"); //$NON-NLS-1$
91 }
92 return layout;
93 }
94
95 @Override
96 public void initTrace(IResource resource, String path,
97 Class<? extends ITmfEvent> eventType) throws TmfTraceException {
98 super.initTrace(resource, path, eventType);
99
100 /* Determine the event layout to use from the tracer's version */
542ddfb3 101 fLayout = getLayoutFromEnv();
7443de72
AM
102 }
103
542ddfb3
AM
104 private @NonNull ILttngUstEventLayout getLayoutFromEnv() {
105 String tracerName = CtfUtils.getTracerName(this);
106 int tracerMajor = CtfUtils.getTracerMajorVersion(this);
107 int tracerMinor = CtfUtils.getTracerMinorVersion(this);
7443de72 108
ef7f180d 109 if (TRACER_NAME.equals(tracerName)) {
542ddfb3 110 if (tracerMajor >= 2) {
ef7f180d
AM
111 if (tracerMinor >= 8) {
112 return LttngUst28EventLayout.getInstance();
113 } else if (tracerMinor >= 7) {
7443de72
AM
114 return LttngUst27EventLayout.getInstance();
115 }
116 return LttngUst20EventLayout.getInstance();
117 }
118 }
119
120 /* Fallback to the UST 2.0 layout and hope for the best */
121 return LttngUst20EventLayout.getInstance();
122 }
123
ef7f180d
AM
124 @Override
125 public Iterable<ITmfEventAspect> getEventAspects() {
126 return LTTNG_UST_ASPECTS;
127 }
128
cd43d683
PT
129 /**
130 * {@inheritDoc}
131 * <p>
132 * This implementation sets the confidence to 100 if the trace is a valid
133 * CTF trace in the "ust" domain.
134 */
91fc3690 135 @Override
b562a24f 136 public IStatus validate(final IProject project, final String path) {
747fd87b
PT
137 IStatus status = super.validate(project, path);
138 if (status instanceof CtfTraceValidationStatus) {
139 Map<String, String> environment = ((CtfTraceValidationStatus) status).getEnvironment();
dd9752d5 140 /* Make sure the domain is "ust" in the trace's env vars */
747fd87b
PT
141 String domain = environment.get("domain"); //$NON-NLS-1$
142 if (domain == null || !domain.equals("\"ust\"")) { //$NON-NLS-1$
143 return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngUstTrace_DomainError);
dd9752d5 144 }
747fd87b 145 return new TraceValidationStatus(CONFIDENCE, Activator.PLUGIN_ID);
91fc3690 146 }
747fd87b 147 return status;
91fc3690
AM
148 }
149}
This page took 0.086176 seconds and 5 git commands to generate.