1 /*******************************************************************************
2 * Copyright (c) 2012 Ericsson
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
10 * Alexandre Montplaisir - Initial API and implementation
11 ******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng2
.kernel
.core
.trace
;
16 import java
.io
.IOException
;
18 import org
.eclipse
.core
.resources
.IProject
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.kernel
.core
.stateprovider
.CTFKernelStateInput
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfTrace
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfTraceException
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.StateHistorySystem
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.backend
.historytree
.HistoryTreeBackend
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.helpers
.HistoryBuilder
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.helpers
.IStateChangeInput
;
26 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.helpers
.IStateHistoryBackend
;
29 * This is the specification of CtfTmfTrace for use with LTTng 2.x kernel
30 * traces. It uses the CtfKernelStateInput to generate the state history.
35 public class CtfKernelTrace
extends CtfTmfTrace
{
37 public CtfKernelTrace() {
42 public boolean validate(final IProject project
, final String path
) {
43 if (!super.validate(project
, path
)) {
46 /* Add extra checks specific to kernel traces here */;
51 protected void buildStateSystem() throws TmfTraceException
{
52 /* Set up the path to the history tree file we'll use */
53 final String htPath
= this.getPath() + ".ht";
54 final File htFile
= new File(htPath
);
56 IStateHistoryBackend htBackend
;
57 IStateChangeInput htInput
;
58 HistoryBuilder builder
;
60 /* If the target file already exists, do not rebuild it uselessly */
61 // TODO for now we assume it's complete. Might be a good idea to check
62 // at least if its range matches the trace's range.
64 if (htFile
.exists()) {
65 /* Load an existing history */
66 htBackend
= new HistoryTreeBackend(htFile
);
67 this.ss
= new StateHistorySystem(htBackend
, false);
69 /* Create a new state history from scratch */
70 htInput
= new CTFKernelStateInput(this);
71 htBackend
= new HistoryTreeBackend(htFile
,
72 htInput
.getStartTime());
73 builder
= new HistoryBuilder(htInput
, htBackend
);
75 // TODO this is blocking for now...
78 } catch (IOException e
) {
79 throw new TmfTraceException(e
.getMessage());