/**********************************************************************
- * Copyright (c) 2013 Ericsson
+ * Copyright (c) 2013, 2014 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* Contributors:
* Matthew Khouzam - Initial API and implementation
* Alexandre Montplaisir - Add UST callstack state system
+ * Marc-Andre Laperle - Handle BufferOverflowException (Bug 420203)
**********************************************************************/
package org.eclipse.linuxtools.lttng2.ust.core.trace;
-import java.io.File;
+import java.nio.BufferOverflowException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
import org.eclipse.linuxtools.internal.lttng2.ust.core.Activator;
-import org.eclipse.linuxtools.internal.lttng2.ust.core.trace.callstack.LttngUstCallStackProvider;
-import org.eclipse.linuxtools.tmf.core.callstack.CallStackStateProvider;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
-import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
-import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory;
-import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
+import org.eclipse.linuxtools.tmf.core.trace.TraceValidationStatus;
/**
* Class to contain LTTng-UST traces
*/
public class LttngUstTrace extends CtfTmfTrace {
- /** Name of the history file for the callstack state system */
- private static final String CALLSTACK_FILENAME = "ust-callstack.ht"; //$NON-NLS-1$
+ private static final int CONFIDENCE = 100;
/**
* Default constructor
super();
}
+ /**
+ * {@inheritDoc}
+ * <p>
+ * This implementation sets the confidence to 100 if the trace is a valid
+ * CTF trace in the "ust" domain.
+ */
@Override
public IStatus validate(final IProject project, final String path) {
CTFTrace temp;
try {
temp = new CTFTrace(path);
} catch (CTFReaderException e) {
- status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
+ status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
+ return status;
+ } catch (NullPointerException e) {
+ status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
return status;
- } catch (NullPointerException e){
- status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
+ } catch (final BufferOverflowException e) {
+ status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngUstTrace_TraceReadError + ": " + Messages.LttngUstTrace_MalformedTrace); //$NON-NLS-1$
return status;
}
String dom = temp.getEnvironment().get("domain"); //$NON-NLS-1$
temp.dispose();
if (dom != null && dom.equals("\"ust\"")) { //$NON-NLS-1$
- return Status.OK_STATUS;
+ return new TraceValidationStatus(CONFIDENCE, Activator.PLUGIN_ID);
}
status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngUstTrace_DomainError);
return status;
}
-
- @Override
- public IStatus buildStateSystem() {
- super.buildStateSystem();
-
- /*
- * Build the state system for the UST Callstack (will be empty if the
- * required events are not present).
- */
- String directory = TmfTraceManager.getSupplementaryFileDir(this);
- final File htFile = new File(directory + CALLSTACK_FILENAME);
- ITmfStateProvider csInput = new LttngUstCallStackProvider(this);
-
- try {
- ITmfStateSystem ss = TmfStateSystemFactory.newFullHistory(htFile, csInput, false);
- registerStateSystem(CallStackStateProvider.ID, ss);
- } catch (TmfTraceException e) {
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
- }
-
- return Status.OK_STATUS;
- }
}