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 ******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng2
.kernel
.core
.trace
;
17 import org
.eclipse
.core
.resources
.IProject
;
18 import org
.eclipse
.core
.resources
.IResource
;
19 import org
.eclipse
.core
.runtime
.CoreException
;
20 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFReaderException
;
21 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTrace
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.kernel
.core
.stateprovider
.CtfKernelStateInput
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.TmfCommonConstants
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfTrace
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfTraceException
;
26 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.IStateChangeInput
;
27 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.ITmfStateSystem
;
28 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.StateSystemManager
;
31 * This is the specification of CtfTmfTrace for use with LTTng 2.x kernel
32 * traces. It uses the CtfKernelStateInput to generate the state history.
35 * @author Alexandre Montplaisir
37 public class CtfKernelTrace
extends CtfTmfTrace
{
40 * The file name of the History Tree
42 public final static String HISTORY_TREE_FILE_NAME
= "stateHistory.ht"; //$NON-NLS-1$
45 * ID of the state system we will build
48 public static final String STATE_ID
= "org.eclipse.linuxtools.lttng2.kernel"; //$NON-NLS-1$
53 public CtfKernelTrace() {
58 public boolean validate(final IProject project
, final String path
) {
61 * Make sure the trace is openable as a CTF trace. We do this here
62 * instead of calling super.validate() to keep the reference to "temp".
65 temp
= new CTFTrace(path
);
66 } catch (CTFReaderException e
) {
70 /* Make sure the domain is "kernel" in the trace's env vars */
71 String dom
= temp
.getEnvironment().get("domain"); //$NON-NLS-1$
73 if (dom
!= null && dom
.equals("\"kernel\"")) { //$NON-NLS-1$
80 protected void buildStateSystem() throws TmfTraceException
{
81 super.buildStateSystem();
83 /* Set up the path to the history tree file we'll use */
84 IResource resource
= this.getResource();
85 String supplDirectory
= null;
88 // get the directory where the history file will be stored.
89 supplDirectory
= resource
.getPersistentProperty(TmfCommonConstants
.TRACE_SUPPLEMENTARY_FOLDER
);
90 } catch (CoreException e
) {
91 throw new TmfTraceException(e
.toString(), e
);
94 final File htFile
= new File(supplDirectory
+ File
.separator
+ HISTORY_TREE_FILE_NAME
);
95 final IStateChangeInput htInput
= new CtfKernelStateInput(this);
97 ITmfStateSystem ss
= StateSystemManager
.loadStateHistory(htFile
, htInput
, false);
98 fStateSystems
.put(STATE_ID
, ss
);