Fix for the fix: Fix an error if a user forcefully reads after the
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.core / src / org / eclipse / linuxtools / lttng2 / kernel / core / trace / CtfKernelTrace.java
CommitLineData
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
13package org.eclipse.linuxtools.lttng2.kernel.core.trace;
14
15import java.io.File;
11d6f468
AM
16
17import org.eclipse.core.resources.IProject;
5e4bf87d 18import org.eclipse.core.resources.IResource;
e12ecd30 19import org.eclipse.core.runtime.CoreException;
dc0f7bfe 20import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.CtfKernelStateInput;
e12ecd30 21import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
11d6f468
AM
22import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
23import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
18ab1d18 24import org.eclipse.linuxtools.tmf.core.statesystem.IStateChangeInput;
6e71ce46 25import org.eclipse.linuxtools.tmf.core.statesystem.StateSystemManager;
11d6f468
AM
26
27/**
28 * This is the specification of CtfTmfTrace for use with LTTng 2.x kernel
29 * traces. It uses the CtfKernelStateInput to generate the state history.
d85d2a6d 30 *
11d6f468 31 * @author alexmont
d85d2a6d 32 *
11d6f468
AM
33 */
34public class CtfKernelTrace extends CtfTmfTrace {
35
e12ecd30
BH
36 /**
37 * The file name of the History Tree
38 */
39 public final static String HISTORY_TREE_FILE_NAME = "stateHistory.ht"; //$NON-NLS-1$
6752f420 40
d85d2a6d
AM
41 /**
42 * Default constructor
43 */
11d6f468
AM
44 public CtfKernelTrace() {
45 super();
46 }
47
48 @Override
49 public boolean validate(final IProject project, final String path) {
50 if (!super.validate(project, path)) {
51 return false;
52 }
f483ae24 53 /* Add extra checks specific to kernel traces here */
11d6f468
AM
54 return true;
55 }
56
57 @Override
58 protected void buildStateSystem() throws TmfTraceException {
59 /* Set up the path to the history tree file we'll use */
6e71ce46 60 IResource resource = this.getResource();
d85d2a6d 61 String supplDirectory = null;
e12ecd30
BH
62
63 try {
64 // get the directory where the history file will be stored.
65 supplDirectory = resource.getPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER);
66 } catch (CoreException e) {
9fa32496 67 throw new TmfTraceException(e.toString(), e);
e12ecd30
BH
68 }
69
70 final File htFile = new File(supplDirectory + File.separator + HISTORY_TREE_FILE_NAME);
6e71ce46 71 final IStateChangeInput htInput = new CtfKernelStateInput(this);
11d6f468 72
51e216bd 73 this.ss = StateSystemManager.loadStateHistory(htFile, htInput, false);
11d6f468
AM
74 }
75}
This page took 0.029407 seconds and 5 git commands to generate.