1 /*******************************************************************************
2 * Copyright (c) 2012, 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 * Alexandre Montplaisir - Initial API and implementation
11 * Matthew Khouzam - Improved validation
12 ******************************************************************************/
14 package org
.eclipse
.linuxtools
.lttng2
.kernel
.core
.trace
;
18 import org
.eclipse
.core
.resources
.IProject
;
19 import org
.eclipse
.core
.resources
.IResource
;
20 import org
.eclipse
.core
.runtime
.CoreException
;
21 import org
.eclipse
.core
.runtime
.IStatus
;
22 import org
.eclipse
.core
.runtime
.Status
;
23 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFReaderException
;
24 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTrace
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.kernel
.core
.Activator
;
26 import org
.eclipse
.linuxtools
.internal
.lttng2
.kernel
.core
.stateprovider
.CtfKernelStateProvider
;
27 import org
.eclipse
.linuxtools
.tmf
.core
.TmfCommonConstants
;
28 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfTrace
;
29 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfTraceException
;
30 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.ITmfStateProvider
;
31 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.ITmfStateSystem
;
32 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.StateSystemManager
;
35 * This is the specification of CtfTmfTrace for use with LTTng 2.x kernel
36 * traces. It uses the CtfKernelStateInput to generate the state history.
39 * @author Alexandre Montplaisir
41 public class CtfKernelTrace
extends CtfTmfTrace
{
44 * The file name of the History Tree
46 public final static String HISTORY_TREE_FILE_NAME
= "stateHistory.ht"; //$NON-NLS-1$
49 * ID of the state system we will build
52 public static final String STATE_ID
= "org.eclipse.linuxtools.lttng2.kernel"; //$NON-NLS-1$
57 public CtfKernelTrace() {
65 public IStatus
validate(final IProject project
, final String path
) {
69 * Make sure the trace is openable as a CTF trace. We do this here
70 * instead of calling super.validate() to keep the reference to "temp".
73 temp
= new CTFTrace(path
);
74 } catch (CTFReaderException e
) {
75 validStatus
= new Status(IStatus
.ERROR
, Activator
.PLUGIN_ID
, e
.toString(), e
);
77 } catch (NullPointerException e
){
78 validStatus
= new Status(IStatus
.ERROR
, Activator
.PLUGIN_ID
, e
.toString(), e
);
82 /* Make sure the domain is "kernel" in the trace's env vars */
83 String dom
= temp
.getEnvironment().get("domain"); //$NON-NLS-1$
85 if (dom
!= null && dom
.equals("\"kernel\"")) { //$NON-NLS-1$
86 return Status
.OK_STATUS
;
88 validStatus
= new Status(IStatus
.ERROR
, Activator
.PLUGIN_ID
, Messages
.CtfKernelTrace_DomainError
);
93 protected void buildStateSystem() throws TmfTraceException
{
94 super.buildStateSystem();
96 /* Set up the path to the history tree file we'll use */
97 IResource resource
= this.getResource();
98 String supplDirectory
= null;
101 // get the directory where the history file will be stored.
102 supplDirectory
= resource
.getPersistentProperty(TmfCommonConstants
.TRACE_SUPPLEMENTARY_FOLDER
);
103 } catch (CoreException e
) {
104 throw new TmfTraceException(e
.toString(), e
);
107 final File htFile
= new File(supplDirectory
+ File
.separator
+ HISTORY_TREE_FILE_NAME
);
108 final ITmfStateProvider htInput
= new CtfKernelStateProvider(this);
110 ITmfStateSystem ss
= StateSystemManager
.loadStateHistory(htFile
, htInput
, false);
111 fStateSystems
.put(STATE_ID
, ss
);