Commit | Line | Data |
---|---|---|
91fc3690 AM |
1 | /********************************************************************** |
2 | * Copyright (c) 2013 Ericsson | |
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 | ||
15 | package org.eclipse.linuxtools.lttng2.ust.core.trace; | |
16 | ||
af015d44 | 17 | import java.nio.BufferOverflowException; |
1c6660ca | 18 | |
91fc3690 AM |
19 | import org.eclipse.core.resources.IProject; |
20 | import org.eclipse.core.runtime.IStatus; | |
21 | import org.eclipse.core.runtime.Status; | |
22 | import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; | |
23 | import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; | |
24 | import org.eclipse.linuxtools.internal.lttng2.ust.core.Activator; | |
25 | import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; | |
26 | ||
27 | /** | |
28 | * Class to contain LTTng-UST traces | |
29 | * | |
30 | * @author Matthew Khouzam | |
31 | * @since 2.1 | |
32 | */ | |
33 | public class LttngUstTrace extends CtfTmfTrace { | |
34 | ||
35 | /** | |
36 | * Default constructor | |
37 | */ | |
38 | public LttngUstTrace() { | |
39 | super(); | |
40 | } | |
41 | ||
42 | @Override | |
43 | public IStatus validate(final IProject project, final String path) { | |
44 | CTFTrace temp; | |
45 | IStatus status; | |
46 | /* Make sure the trace is openable as a CTF trace. */ | |
47 | try { | |
48 | temp = new CTFTrace(path); | |
49 | } catch (CTFReaderException e) { | |
af015d44 | 50 | status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e); |
91fc3690 | 51 | return status; |
af015d44 MAL |
52 | } catch (NullPointerException e) { |
53 | status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e); | |
91fc3690 | 54 | return status; |
af015d44 MAL |
55 | } catch (final BufferOverflowException e) { |
56 | status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngUstTrace_TraceReadError + ": " + Messages.LttngUstTrace_MalformedTrace); //$NON-NLS-1$ | |
91fc3690 AM |
57 | return status; |
58 | } | |
59 | ||
60 | /* Make sure the domain is "ust" in the trace's env vars */ | |
61 | String dom = temp.getEnvironment().get("domain"); //$NON-NLS-1$ | |
62 | temp.dispose(); | |
63 | if (dom != null && dom.equals("\"ust\"")) { //$NON-NLS-1$ | |
64 | return Status.OK_STATUS; | |
65 | } | |
66 | status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngUstTrace_DomainError); | |
67 | return status; | |
68 | } | |
69 | } |