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
;
36 * Class to contain LTTng-UST traces
38 * @author Matthew Khouzam
40 public class LttngUstTrace
extends CtfTmfTrace
{
42 private static final int CONFIDENCE
= 100;
44 private @Nullable ILttngUstEventLayout fLayout
= null;
49 public LttngUstTrace() {
54 * Get the event layout to use with this trace. This normally depends on the
57 * @return The event layout
60 public @NonNull ILttngUstEventLayout
getEventLayout() {
61 ILttngUstEventLayout layout
= fLayout
;
63 throw new IllegalStateException("Cannot get the layout of a non-initialized trace!"); //$NON-NLS-1$
69 public void initTrace(IResource resource
, String path
,
70 Class
<?
extends ITmfEvent
> eventType
) throws TmfTraceException
{
71 super.initTrace(resource
, path
, eventType
);
73 /* Determine the event layout to use from the tracer's version */
74 fLayout
= getLayoutFromEnv(this.getEnvironment());
77 private static @NonNull ILttngUstEventLayout
getLayoutFromEnv(Map
<String
, String
> traceEnv
) {
78 String tracerName
= traceEnv
.get("tracer_name"); //$NON-NLS-1$
79 String tracerMajor
= traceEnv
.get("tracer_major"); //$NON-NLS-1$
80 String tracerMinor
= traceEnv
.get("tracer_minor"); //$NON-NLS-1$
82 if ("\"lttng-ust\"".equals(tracerName
) && tracerMajor
!= null && tracerMinor
!= null) { //$NON-NLS-1$
83 if (Integer
.valueOf(tracerMajor
) >= 2) {
84 if (Integer
.valueOf(tracerMinor
) >= 7) {
85 return LttngUst27EventLayout
.getInstance();
87 return LttngUst20EventLayout
.getInstance();
91 /* Fallback to the UST 2.0 layout and hope for the best */
92 return LttngUst20EventLayout
.getInstance();
98 * This implementation sets the confidence to 100 if the trace is a valid
99 * CTF trace in the "ust" domain.
102 public IStatus
validate(final IProject project
, final String path
) {
103 IStatus status
= super.validate(project
, path
);
104 if (status
instanceof CtfTraceValidationStatus
) {
105 Map
<String
, String
> environment
= ((CtfTraceValidationStatus
) status
).getEnvironment();
106 /* Make sure the domain is "ust" in the trace's env vars */
107 String domain
= environment
.get("domain"); //$NON-NLS-1$
108 if (domain
== null || !domain
.equals("\"ust\"")) { //$NON-NLS-1$
109 return new Status(IStatus
.ERROR
, Activator
.PLUGIN_ID
, Messages
.LttngUstTrace_DomainError
);
111 return new TraceValidationStatus(CONFIDENCE
, Activator
.PLUGIN_ID
);