lttng: Add Callstack View support for UST traces
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ust.core / src / org / eclipse / linuxtools / lttng2 / ust / core / trace / LttngUstTrace.java
CommitLineData
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
91fc3690
AM
12 **********************************************************************/
13
14package org.eclipse.linuxtools.lttng2.ust.core.trace;
15
1c6660ca
AM
16import java.io.File;
17
91fc3690
AM
18import org.eclipse.core.resources.IProject;
19import org.eclipse.core.runtime.IStatus;
20import org.eclipse.core.runtime.Status;
21import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
22import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
23import org.eclipse.linuxtools.internal.lttng2.ust.core.Activator;
1c6660ca
AM
24import org.eclipse.linuxtools.internal.lttng2.ust.core.trace.callstack.LttngUstCallStackProvider;
25import org.eclipse.linuxtools.tmf.core.callstack.CallStackStateProvider;
91fc3690 26import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
1c6660ca
AM
27import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
28import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
29import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
30import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory;
31import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
91fc3690
AM
32
33/**
34 * Class to contain LTTng-UST traces
35 *
36 * @author Matthew Khouzam
37 * @since 2.1
38 */
39public class LttngUstTrace extends CtfTmfTrace {
40
1c6660ca
AM
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
91fc3690
AM
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 }
1c6660ca
AM
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 }
91fc3690 97}
This page took 0.027439 seconds and 5 git commands to generate.