Merge branch 'master' into lttng-luna
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ust.core / src / org / eclipse / linuxtools / lttng2 / ust / core / trace / LttngUstTrace.java
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
11 * Alexandre Montplaisir - Add UST callstack state system
12 **********************************************************************/
13
14 package org.eclipse.linuxtools.lttng2.ust.core.trace;
15
16 import java.io.File;
17
18 import org.eclipse.core.resources.IProject;
19 import org.eclipse.core.runtime.IStatus;
20 import org.eclipse.core.runtime.Status;
21 import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
22 import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
23 import org.eclipse.linuxtools.internal.lttng2.ust.core.Activator;
24 import org.eclipse.linuxtools.internal.lttng2.ust.core.trace.callstack.LttngUstCallStackProvider;
25 import org.eclipse.linuxtools.tmf.core.callstack.CallStackStateProvider;
26 import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
27 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
28 import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
29 import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
30 import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory;
31 import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
32
33 /**
34 * Class to contain LTTng-UST traces
35 *
36 * @author Matthew Khouzam
37 * @since 2.1
38 */
39 public class LttngUstTrace extends CtfTmfTrace {
40
41 /** Name of the history file for the callstack state system */
42 private static final String CALLSTACK_FILENAME = "ust-callstack.ht"; //$NON-NLS-1$
43
44 /**
45 * Default constructor
46 */
47 public LttngUstTrace() {
48 super();
49 }
50
51 @Override
52 public IStatus validate(final IProject project, final String path) {
53 CTFTrace temp;
54 IStatus status;
55 /* Make sure the trace is openable as a CTF trace. */
56 try {
57 temp = new CTFTrace(path);
58 } catch (CTFReaderException e) {
59 status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
60 return status;
61 } catch (NullPointerException e){
62 status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
63 return status;
64 }
65
66 /* Make sure the domain is "ust" in the trace's env vars */
67 String dom = temp.getEnvironment().get("domain"); //$NON-NLS-1$
68 temp.dispose();
69 if (dom != null && dom.equals("\"ust\"")) { //$NON-NLS-1$
70 return Status.OK_STATUS;
71 }
72 status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngUstTrace_DomainError);
73 return status;
74 }
75
76 @Override
77 public IStatus buildStateSystem() {
78 super.buildStateSystem();
79
80 /*
81 * Build the state system for the UST Callstack (will be empty if the
82 * required events are not present).
83 */
84 String directory = TmfTraceManager.getSupplementaryFileDir(this);
85 final File htFile = new File(directory + CALLSTACK_FILENAME);
86 ITmfStateProvider csInput = new LttngUstCallStackProvider(this);
87
88 try {
89 ITmfStateSystem ss = TmfStateSystemFactory.newFullHistory(htFile, csInput, false);
90 registerStateSystem(CallStackStateProvider.ID, ss);
91 } catch (TmfTraceException e) {
92 return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
93 }
94
95 return Status.OK_STATUS;
96 }
97 }
This page took 0.036122 seconds and 6 git commands to generate.