1 /*******************************************************************************
2 * Copyright (c) 2012, 2014 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 * Matthew Khouzam - Improved validation
12 ******************************************************************************/
14 package org
.eclipse
.linuxtools
.lttng2
.kernel
.core
.trace
;
16 import java
.nio
.BufferOverflowException
;
18 import org
.eclipse
.core
.resources
.IProject
;
19 import org
.eclipse
.core
.runtime
.IStatus
;
20 import org
.eclipse
.core
.runtime
.Status
;
21 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFReaderException
;
22 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTrace
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.kernel
.core
.Activator
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TraceValidationStatus
;
25 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.CtfTmfTrace
;
28 * This is the specification of CtfTmfTrace for use with LTTng 2.x kernel
31 * @author Alexandre Montplaisir
34 public class LttngKernelTrace
extends CtfTmfTrace
{
36 private static final int CONFIDENCE
= 100;
41 public LttngKernelTrace() {
48 * This implementation sets the confidence to 100 if the trace is a valid
49 * CTF trace in the "kernel" domain.
52 public IStatus
validate(final IProject project
, final String path
) {
54 * Make sure the trace is openable as a CTF trace. We do this here
55 * instead of calling super.validate() to keep the reference to "temp".
57 try (CTFTrace temp
= new CTFTrace(path
);) {
58 /* Make sure the domain is "kernel" in the trace's env vars */
59 String dom
= temp
.getEnvironment().get("domain"); //$NON-NLS-1$
60 if (dom
!= null && dom
.equals("\"kernel\"")) { //$NON-NLS-1$
61 return new TraceValidationStatus(CONFIDENCE
, Activator
.PLUGIN_ID
);
63 return new Status(IStatus
.ERROR
, Activator
.PLUGIN_ID
, Messages
.LttngKernelTrace_DomainError
);
65 } catch (CTFReaderException e
) {
66 return new Status(IStatus
.ERROR
, Activator
.PLUGIN_ID
, e
.toString(), e
);
67 } catch (NullPointerException e
) {
68 return new Status(IStatus
.ERROR
, Activator
.PLUGIN_ID
, e
.toString(), e
);
69 } catch (final BufferOverflowException e
) {
70 return new Status(IStatus
.ERROR
, Activator
.PLUGIN_ID
, Messages
.LttngKernelTrace_TraceReadError
+ ": " + Messages
.LttngKernelTrace_MalformedTrace
); //$NON-NLS-1$