1 /**********************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
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
10 * Matthew Khouzam - Initial API and implementation
11 * Alexandre Montplaisir - Add UST callstack state system
12 * Marc-Andre Laperle - Handle BufferOverflowException (Bug 420203)
13 **********************************************************************/
15 package org
.eclipse
.tracecompass
.lttng2
.ust
.core
.trace
;
19 import org
.eclipse
.core
.resources
.IProject
;
20 import org
.eclipse
.core
.resources
.IResource
;
21 import org
.eclipse
.core
.runtime
.IStatus
;
22 import org
.eclipse
.core
.runtime
.Status
;
23 import org
.eclipse
.jdt
.annotation
.NonNull
;
24 import org
.eclipse
.jdt
.annotation
.Nullable
;
25 import org
.eclipse
.tracecompass
.internal
.lttng2
.ust
.core
.Activator
;
26 import org
.eclipse
.tracecompass
.internal
.lttng2
.ust
.core
.trace
.layout
.LttngUst20EventLayout
;
27 import org
.eclipse
.tracecompass
.internal
.lttng2
.ust
.core
.trace
.layout
.LttngUst27EventLayout
;
28 import org
.eclipse
.tracecompass
.lttng2
.ust
.core
.trace
.layout
.ILttngUstEventLayout
;
29 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
30 import org
.eclipse
.tracecompass
.tmf
.core
.exceptions
.TmfTraceException
;
31 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TraceValidationStatus
;
32 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.trace
.CtfTmfTrace
;
33 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.trace
.CtfTraceValidationStatus
;
34 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.trace
.CtfUtils
;
37 * Class to contain LTTng-UST traces
39 * @author Matthew Khouzam
41 public class LttngUstTrace
extends CtfTmfTrace
{
43 private static final int CONFIDENCE
= 100;
45 private @Nullable ILttngUstEventLayout fLayout
= null;
50 public LttngUstTrace() {
55 * Get the event layout to use with this trace. This normally depends on the
58 * @return The event layout
61 public @NonNull ILttngUstEventLayout
getEventLayout() {
62 ILttngUstEventLayout layout
= fLayout
;
64 throw new IllegalStateException("Cannot get the layout of a non-initialized trace!"); //$NON-NLS-1$
70 public void initTrace(IResource resource
, String path
,
71 Class
<?
extends ITmfEvent
> eventType
) throws TmfTraceException
{
72 super.initTrace(resource
, path
, eventType
);
74 /* Determine the event layout to use from the tracer's version */
75 fLayout
= getLayoutFromEnv();
78 private @NonNull ILttngUstEventLayout
getLayoutFromEnv() {
79 String tracerName
= CtfUtils
.getTracerName(this);
80 int tracerMajor
= CtfUtils
.getTracerMajorVersion(this);
81 int tracerMinor
= CtfUtils
.getTracerMinorVersion(this);
83 if ("lttng-ust".equals(tracerName
)) { //$NON-NLS-1$
84 if (tracerMajor
>= 2) {
85 if (tracerMinor
>= 7) {
86 return LttngUst27EventLayout
.getInstance();
88 return LttngUst20EventLayout
.getInstance();
92 /* Fallback to the UST 2.0 layout and hope for the best */
93 return LttngUst20EventLayout
.getInstance();
99 * This implementation sets the confidence to 100 if the trace is a valid
100 * CTF trace in the "ust" domain.
103 public IStatus
validate(final IProject project
, final String path
) {
104 IStatus status
= super.validate(project
, path
);
105 if (status
instanceof CtfTraceValidationStatus
) {
106 Map
<String
, String
> environment
= ((CtfTraceValidationStatus
) status
).getEnvironment();
107 /* Make sure the domain is "ust" in the trace's env vars */
108 String domain
= environment
.get("domain"); //$NON-NLS-1$
109 if (domain
== null || !domain
.equals("\"ust\"")) { //$NON-NLS-1$
110 return new Status(IStatus
.ERROR
, Activator
.PLUGIN_ID
, Messages
.LttngUstTrace_DomainError
);
112 return new TraceValidationStatus(CONFIDENCE
, Activator
.PLUGIN_ID
);