1 /**********************************************************************
2 * Copyright (c) 2013 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 **********************************************************************/
14 package org
.eclipse
.linuxtools
.lttng2
.ust
.core
.trace
;
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
;
34 * Class to contain LTTng-UST traces
36 * @author Matthew Khouzam
39 public class LttngUstTrace
extends CtfTmfTrace
{
41 /** Name of the history file for the callstack state system */
42 private static final String CALLSTACK_FILENAME
= "ust-callstack.ht"; //$NON-NLS-1$
47 public LttngUstTrace() {
52 public IStatus
validate(final IProject project
, final String path
) {
55 /* Make sure the trace is openable as a CTF trace. */
57 temp
= new CTFTrace(path
);
58 } catch (CTFReaderException e
) {
59 status
= new Status(IStatus
.ERROR
, Activator
.PLUGIN_ID
, e
.toString(), e
);
61 } catch (NullPointerException e
){
62 status
= new Status(IStatus
.ERROR
, Activator
.PLUGIN_ID
, e
.toString(), e
);
66 /* Make sure the domain is "ust" in the trace's env vars */
67 String dom
= temp
.getEnvironment().get("domain"); //$NON-NLS-1$
69 if (dom
!= null && dom
.equals("\"ust\"")) { //$NON-NLS-1$
70 return Status
.OK_STATUS
;
72 status
= new Status(IStatus
.ERROR
, Activator
.PLUGIN_ID
, Messages
.LttngUstTrace_DomainError
);
77 public IStatus
buildStateSystem() {
78 super.buildStateSystem();
81 * Build the state system for the UST Callstack (will be empty if the
82 * required events are not present).
84 String directory
= TmfTraceManager
.getSupplementaryFileDir(this);
85 final File htFile
= new File(directory
+ CALLSTACK_FILENAME
);
86 ITmfStateProvider csInput
= new LttngUstCallStackProvider(this);
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
);
95 return Status
.OK_STATUS
;