Commit | Line | Data |
---|---|---|
11d6f468 AM |
1 | /******************************************************************************* |
2 | * Copyright (c) 2012 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 | * Alexandre Montplaisir - Initial API and implementation | |
11 | ******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.lttng2.kernel.core.trace; | |
14 | ||
15 | import java.io.File; | |
11d6f468 AM |
16 | |
17 | import org.eclipse.core.resources.IProject; | |
5e4bf87d | 18 | import org.eclipse.core.resources.IResource; |
e12ecd30 | 19 | import org.eclipse.core.runtime.CoreException; |
7c60c8b4 AM |
20 | import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; |
21 | import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; | |
dc0f7bfe | 22 | import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.CtfKernelStateInput; |
e12ecd30 | 23 | import org.eclipse.linuxtools.tmf.core.TmfCommonConstants; |
11d6f468 AM |
24 | import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; |
25 | import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; | |
18ab1d18 | 26 | import org.eclipse.linuxtools.tmf.core.statesystem.IStateChangeInput; |
6e71ce46 | 27 | import org.eclipse.linuxtools.tmf.core.statesystem.StateSystemManager; |
11d6f468 AM |
28 | |
29 | /** | |
30 | * This is the specification of CtfTmfTrace for use with LTTng 2.x kernel | |
31 | * traces. It uses the CtfKernelStateInput to generate the state history. | |
d85d2a6d | 32 | * |
2cb26548 AM |
33 | * @version 1.0 |
34 | * @author Alexandre Montplaisir | |
11d6f468 AM |
35 | */ |
36 | public class CtfKernelTrace extends CtfTmfTrace { | |
37 | ||
e12ecd30 BH |
38 | /** |
39 | * The file name of the History Tree | |
40 | */ | |
41 | public final static String HISTORY_TREE_FILE_NAME = "stateHistory.ht"; //$NON-NLS-1$ | |
6752f420 | 42 | |
a76f1067 AM |
43 | /** |
44 | * ID of the state system we will build | |
45 | * @since 2.0 | |
46 | * */ | |
47 | public static final String STATE_ID = "org.eclipse.linuxtools.lttng2.kernel"; //$NON-NLS-1$ | |
48 | ||
d85d2a6d AM |
49 | /** |
50 | * Default constructor | |
51 | */ | |
11d6f468 AM |
52 | public CtfKernelTrace() { |
53 | super(); | |
54 | } | |
55 | ||
56 | @Override | |
57 | public boolean validate(final IProject project, final String path) { | |
7c60c8b4 AM |
58 | CTFTrace temp; |
59 | /* | |
60 | * Make sure the trace is openable as a CTF trace. We do this here | |
61 | * instead of calling super.validate() to keep the reference to "temp". | |
62 | */ | |
63 | try { | |
64 | temp = new CTFTrace(path); | |
65 | } catch (CTFReaderException e) { | |
11d6f468 AM |
66 | return false; |
67 | } | |
7c60c8b4 AM |
68 | |
69 | /* Make sure the domain is "kernel" in the trace's env vars */ | |
70 | String dom = temp.getEnvironment().get("domain"); //$NON-NLS-1$ | |
71 | if (dom != null && dom.equals("\"kernel\"")) { //$NON-NLS-1$ | |
72 | return true; | |
73 | } | |
74 | return false; | |
11d6f468 AM |
75 | } |
76 | ||
77 | @Override | |
78 | protected void buildStateSystem() throws TmfTraceException { | |
79 | /* Set up the path to the history tree file we'll use */ | |
6e71ce46 | 80 | IResource resource = this.getResource(); |
d85d2a6d | 81 | String supplDirectory = null; |
e12ecd30 BH |
82 | |
83 | try { | |
84 | // get the directory where the history file will be stored. | |
85 | supplDirectory = resource.getPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER); | |
86 | } catch (CoreException e) { | |
9fa32496 | 87 | throw new TmfTraceException(e.toString(), e); |
e12ecd30 BH |
88 | } |
89 | ||
90 | final File htFile = new File(supplDirectory + File.separator + HISTORY_TREE_FILE_NAME); | |
6e71ce46 | 91 | final IStateChangeInput htInput = new CtfKernelStateInput(this); |
11d6f468 | 92 | |
a76f1067 | 93 | this.ss = StateSystemManager.loadStateHistory(htFile, htInput, STATE_ID, false); |
11d6f468 AM |
94 | } |
95 | } |