Commit | Line | Data |
---|---|---|
11d6f468 | 1 | /******************************************************************************* |
94cce698 | 2 | * Copyright (c) 2012, 2013 Ericsson |
11d6f468 AM |
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 | |
a94410d9 | 11 | * Matthew Khouzam - Improved validation |
11d6f468 AM |
12 | ******************************************************************************/ |
13 | ||
14 | package org.eclipse.linuxtools.lttng2.kernel.core.trace; | |
15 | ||
16 | import java.io.File; | |
11d6f468 AM |
17 | |
18 | import org.eclipse.core.resources.IProject; | |
a94410d9 MK |
19 | import org.eclipse.core.runtime.IStatus; |
20 | import org.eclipse.core.runtime.Status; | |
7c60c8b4 AM |
21 | import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; |
22 | import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; | |
a94410d9 | 23 | import org.eclipse.linuxtools.internal.lttng2.kernel.core.Activator; |
d3ba47d4 | 24 | import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider; |
11d6f468 AM |
25 | import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; |
26 | import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; | |
0fe46f2a | 27 | import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider; |
a51b2b9f | 28 | import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem; |
3f436e7c | 29 | import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory; |
e1385db9 | 30 | import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager; |
11d6f468 AM |
31 | |
32 | /** | |
33 | * This is the specification of CtfTmfTrace for use with LTTng 2.x kernel | |
34 | * traces. It uses the CtfKernelStateInput to generate the state history. | |
d85d2a6d | 35 | * |
2cb26548 | 36 | * @author Alexandre Montplaisir |
d3ba47d4 | 37 | * @since 2.0 |
11d6f468 | 38 | */ |
d3ba47d4 | 39 | public class LttngKernelTrace extends CtfTmfTrace { |
11d6f468 | 40 | |
e12ecd30 BH |
41 | /** |
42 | * The file name of the History Tree | |
43 | */ | |
44 | public final static String HISTORY_TREE_FILE_NAME = "stateHistory.ht"; //$NON-NLS-1$ | |
6752f420 | 45 | |
a76f1067 AM |
46 | /** |
47 | * ID of the state system we will build | |
48 | * @since 2.0 | |
49 | * */ | |
50 | public static final String STATE_ID = "org.eclipse.linuxtools.lttng2.kernel"; //$NON-NLS-1$ | |
51 | ||
d85d2a6d AM |
52 | /** |
53 | * Default constructor | |
54 | */ | |
d3ba47d4 | 55 | public LttngKernelTrace() { |
11d6f468 AM |
56 | super(); |
57 | } | |
58 | ||
a94410d9 MK |
59 | /** |
60 | * @since 2.0 | |
61 | */ | |
11d6f468 | 62 | @Override |
a94410d9 | 63 | public IStatus validate(final IProject project, final String path) { |
7c60c8b4 | 64 | CTFTrace temp; |
a94410d9 | 65 | IStatus validStatus; |
7c60c8b4 AM |
66 | /* |
67 | * Make sure the trace is openable as a CTF trace. We do this here | |
68 | * instead of calling super.validate() to keep the reference to "temp". | |
69 | */ | |
70 | try { | |
71 | temp = new CTFTrace(path); | |
72 | } catch (CTFReaderException e) { | |
a94410d9 MK |
73 | validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e); |
74 | return validStatus; | |
75 | } catch (NullPointerException e){ | |
76 | validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e); | |
77 | return validStatus; | |
11d6f468 | 78 | } |
7c60c8b4 AM |
79 | |
80 | /* Make sure the domain is "kernel" in the trace's env vars */ | |
81 | String dom = temp.getEnvironment().get("domain"); //$NON-NLS-1$ | |
81fe3479 | 82 | temp.dispose(); |
7c60c8b4 | 83 | if (dom != null && dom.equals("\"kernel\"")) { //$NON-NLS-1$ |
a94410d9 | 84 | return Status.OK_STATUS; |
7c60c8b4 | 85 | } |
d3ba47d4 | 86 | validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngKernelTrace_DomainError); |
a94410d9 | 87 | return validStatus; |
11d6f468 AM |
88 | } |
89 | ||
42459d24 AM |
90 | /** |
91 | * @since 3.0 | |
92 | */ | |
11d6f468 | 93 | @Override |
42459d24 | 94 | protected IStatus buildStateSystem() { |
a51b2b9f AM |
95 | super.buildStateSystem(); |
96 | ||
e1385db9 AM |
97 | /* Build the state system specific to LTTng kernel traces */ |
98 | String directory = TmfTraceManager.getSupplementaryFileDir(this); | |
99 | final File htFile = new File(directory + HISTORY_TREE_FILE_NAME); | |
d3ba47d4 | 100 | final ITmfStateProvider htInput = new LttngKernelStateProvider(this); |
11d6f468 | 101 | |
42459d24 AM |
102 | try { |
103 | ITmfStateSystem ss = TmfStateSystemFactory.newFullHistory(htFile, htInput, false); | |
104 | fStateSystems.put(STATE_ID, ss); | |
105 | } catch (TmfTraceException e) { | |
b22a582a | 106 | return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); |
42459d24 AM |
107 | } |
108 | return Status.OK_STATUS; | |
faa38350 PT |
109 | } |
110 | ||
11d6f468 | 111 | } |