TMF : Bug 385217 - Display 64 unsigned integers correctly
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.core / src / org / eclipse / linuxtools / lttng2 / kernel / core / trace / LttngKernelTrace.java
CommitLineData
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
14package org.eclipse.linuxtools.lttng2.kernel.core.trace;
15
16import java.io.File;
11d6f468
AM
17
18import org.eclipse.core.resources.IProject;
5e4bf87d 19import org.eclipse.core.resources.IResource;
e12ecd30 20import org.eclipse.core.runtime.CoreException;
a94410d9
MK
21import org.eclipse.core.runtime.IStatus;
22import org.eclipse.core.runtime.Status;
7c60c8b4
AM
23import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
24import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
a94410d9 25import org.eclipse.linuxtools.internal.lttng2.kernel.core.Activator;
d3ba47d4 26import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
e12ecd30 27import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
11d6f468
AM
28import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
29import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
0fe46f2a 30import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
a51b2b9f 31import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
3f436e7c 32import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory;
11d6f468
AM
33
34/**
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.
d85d2a6d 37 *
2cb26548 38 * @author Alexandre Montplaisir
d3ba47d4 39 * @since 2.0
11d6f468 40 */
d3ba47d4 41public class LttngKernelTrace extends CtfTmfTrace {
11d6f468 42
e12ecd30
BH
43 /**
44 * The file name of the History Tree
45 */
46 public final static String HISTORY_TREE_FILE_NAME = "stateHistory.ht"; //$NON-NLS-1$
6752f420 47
a76f1067
AM
48 /**
49 * ID of the state system we will build
50 * @since 2.0
51 * */
52 public static final String STATE_ID = "org.eclipse.linuxtools.lttng2.kernel"; //$NON-NLS-1$
53
d85d2a6d
AM
54 /**
55 * Default constructor
56 */
d3ba47d4 57 public LttngKernelTrace() {
11d6f468
AM
58 super();
59 }
60
a94410d9
MK
61 /**
62 * @since 2.0
63 */
11d6f468 64 @Override
a94410d9 65 public IStatus validate(final IProject project, final String path) {
7c60c8b4 66 CTFTrace temp;
a94410d9 67 IStatus validStatus;
7c60c8b4
AM
68 /*
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".
71 */
72 try {
73 temp = new CTFTrace(path);
74 } catch (CTFReaderException e) {
a94410d9
MK
75 validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
76 return validStatus;
77 } catch (NullPointerException e){
78 validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
79 return validStatus;
11d6f468 80 }
7c60c8b4
AM
81
82 /* Make sure the domain is "kernel" in the trace's env vars */
83 String dom = temp.getEnvironment().get("domain"); //$NON-NLS-1$
81fe3479 84 temp.dispose();
7c60c8b4 85 if (dom != null && dom.equals("\"kernel\"")) { //$NON-NLS-1$
a94410d9 86 return Status.OK_STATUS;
7c60c8b4 87 }
d3ba47d4 88 validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngKernelTrace_DomainError);
a94410d9 89 return validStatus;
11d6f468
AM
90 }
91
92 @Override
93 protected void buildStateSystem() throws TmfTraceException {
a51b2b9f
AM
94 super.buildStateSystem();
95
11d6f468 96 /* Set up the path to the history tree file we'll use */
6e71ce46 97 IResource resource = this.getResource();
d85d2a6d 98 String supplDirectory = null;
e12ecd30
BH
99
100 try {
101 // get the directory where the history file will be stored.
102 supplDirectory = resource.getPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER);
103 } catch (CoreException e) {
9fa32496 104 throw new TmfTraceException(e.toString(), e);
e12ecd30
BH
105 }
106
107 final File htFile = new File(supplDirectory + File.separator + HISTORY_TREE_FILE_NAME);
d3ba47d4 108 final ITmfStateProvider htInput = new LttngKernelStateProvider(this);
11d6f468 109
3f436e7c 110 ITmfStateSystem ss = TmfStateSystemFactory.newFullHistory(htFile, htInput, false);
a51b2b9f 111 fStateSystems.put(STATE_ID, ss);
faa38350
PT
112 }
113
11d6f468 114}
This page took 0.04291 seconds and 5 git commands to generate.