Commit | Line | Data |
---|---|---|
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 | 15 | package org.eclipse.tracecompass.lttng2.ust.core.trace; |
91fc3690 | 16 | |
af015d44 | 17 | import java.nio.BufferOverflowException; |
1c6660ca | 18 | |
91fc3690 | 19 | import org.eclipse.core.resources.IProject; |
fe71057b | 20 | import org.eclipse.core.resources.IResource; |
91fc3690 AM |
21 | import org.eclipse.core.runtime.IStatus; |
22 | import org.eclipse.core.runtime.Status; | |
9bc60be7 | 23 | import org.eclipse.tracecompass.internal.lttng2.ust.core.Activator; |
fe71057b | 24 | import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; |
2bdf0193 | 25 | import org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus; |
fe71057b | 26 | import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent; |
9722e5d7 | 27 | import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace; |
91fc3690 AM |
28 | |
29 | /** | |
30 | * Class to contain LTTng-UST traces | |
31 | * | |
32 | * @author Matthew Khouzam | |
91fc3690 AM |
33 | */ |
34 | public class LttngUstTrace extends CtfTmfTrace { | |
35 | ||
cd43d683 PT |
36 | private static final int CONFIDENCE = 100; |
37 | ||
91fc3690 AM |
38 | /** |
39 | * Default constructor | |
40 | */ | |
41 | public LttngUstTrace() { | |
42 | super(); | |
43 | } | |
44 | ||
cd43d683 PT |
45 | /** |
46 | * {@inheritDoc} | |
47 | * <p> | |
48 | * This implementation sets the confidence to 100 if the trace is a valid | |
49 | * CTF trace in the "ust" domain. | |
50 | */ | |
91fc3690 | 51 | @Override |
b562a24f | 52 | public IStatus validate(final IProject project, final String path) { |
fe71057b AM |
53 | try (CtfTmfTrace temp = new CtfTmfTrace();) { |
54 | temp.initTrace((IResource) null, path, CtfTmfEvent.class); | |
55 | ||
dd9752d5 AM |
56 | /* Make sure the domain is "ust" in the trace's env vars */ |
57 | String dom = temp.getEnvironment().get("domain"); //$NON-NLS-1$ | |
58 | if (dom != null && dom.equals("\"ust\"")) { //$NON-NLS-1$ | |
59 | return new TraceValidationStatus(CONFIDENCE, Activator.PLUGIN_ID); | |
60 | } | |
61 | return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngUstTrace_DomainError); | |
62 | ||
fe71057b | 63 | } catch (TmfTraceException e) { |
dd9752d5 | 64 | return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e); |
af015d44 | 65 | } catch (NullPointerException e) { |
dd9752d5 | 66 | return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e); |
af015d44 | 67 | } catch (final BufferOverflowException e) { |
dd9752d5 | 68 | return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngUstTrace_TraceReadError + ": " + Messages.LttngUstTrace_MalformedTrace); //$NON-NLS-1$ |
91fc3690 | 69 | } |
91fc3690 AM |
70 | } |
71 | } |