~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to lttng/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/CtfKernelTrace.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2012-06-29 12:07:30 UTC
  • Revision ID: package-import@ubuntu.com-20120629120730-bfri1xys1i71dpn6
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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;
 
16
 
 
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.internal.lttng2.kernel.core.stateprovider.CtfKernelStateInput;
 
21
import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
 
22
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
 
23
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
 
24
import org.eclipse.linuxtools.tmf.core.statesystem.IStateChangeInput;
 
25
import org.eclipse.linuxtools.tmf.core.statesystem.StateSystemManager;
 
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.
 
30
 *
 
31
 * @version 1.0
 
32
 * @author Alexandre Montplaisir
 
33
 */
 
34
public class CtfKernelTrace extends CtfTmfTrace {
 
35
 
 
36
    /**
 
37
     * The file name of the History Tree
 
38
     */
 
39
    public final static String HISTORY_TREE_FILE_NAME = "stateHistory.ht"; //$NON-NLS-1$
 
40
 
 
41
    /**
 
42
     * Default constructor
 
43
     */
 
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
        }
 
53
        /* Add extra checks specific to kernel traces here */
 
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 */
 
60
        IResource resource = this.getResource();
 
61
        String supplDirectory = null;
 
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) {
 
67
            throw new TmfTraceException(e.toString(), e);
 
68
        }
 
69
 
 
70
        final File htFile = new File(supplDirectory + File.separator + HISTORY_TREE_FILE_NAME);
 
71
        final IStateChangeInput htInput = new CtfKernelStateInput(this);
 
72
 
 
73
        this.ss = StateSystemManager.loadStateHistory(htFile, htInput, false);
 
74
    }
 
75
}