use of org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException in project tracecompass by tracecompass.
the class TmfOpenTraceHelper method openTraceElement.
private static ITmfTrace openTraceElement(final TmfTraceElement traceElement) {
final ITmfTrace trace = traceElement.instantiateTrace();
final ITmfEvent traceEvent = traceElement.instantiateEvent();
if ((trace == null) || (traceEvent == null)) {
TraceUtils.displayErrorMsg(NLS.bind(Messages.TmfOpenTraceHelper_OpenElement, traceElement.getTypeName()), Messages.TmfOpenTraceHelper_NoTraceType);
if (trace != null) {
trace.dispose();
}
return null;
}
try {
trace.initTrace(traceElement.getResource(), traceElement.getResource().getLocation().toOSString(), traceEvent.getClass(), traceElement.getElementPath(), traceElement.getTraceType());
} catch (final TmfTraceException e) {
TraceUtils.displayErrorMsg(NLS.bind(Messages.TmfOpenTraceHelper_OpenElement, traceElement.getTypeName()), Messages.TmfOpenTraceHelper_InitError + ENDL + ENDL + e, e.getCause());
trace.dispose();
return null;
}
return trace;
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException in project tracecompass by tracecompass.
the class UpdateTraceBoundsJob method extractBoundsFromTrace.
/**
* Extract the bounds from a trace and refresh its trace elements
*
* @param traceElement
* the trace element to refresh
*/
private static void extractBoundsFromTrace(TmfTraceElement traceElement) {
ITmfTimestamp start;
ITmfTimestamp end;
ITmfTrace trace = traceElement.getTrace();
boolean wasInitBefore = (trace != null);
if (!wasInitBefore) {
trace = traceElement.instantiateTrace();
}
if (trace == null) {
/*
* We could not instantiate the trace because its type is unknown,
* abandon.
*/
traceElement.setStartTime(TmfTimestamp.BIG_BANG);
traceElement.setEndTime(TmfTimestamp.BIG_BANG);
} else {
try {
if (!wasInitBefore) {
trace.initTrace(traceElement.getResource(), traceElement.getResource().getLocation().toOSString(), traceElement.instantiateEvent().getClass(), traceElement.getElementPath(), traceElement.getTraceType());
}
start = trace.readStart();
if (start != null) {
traceElement.setStartTime(start);
/*
* Intermediate refresh when we get the start time, will not
* re-trigger a job.
*/
traceElement.refreshViewer();
end = trace.readEnd();
traceElement.setEndTime((end != null) ? end : TmfTimestamp.BIG_BANG);
} else {
traceElement.setStartTime(TmfTimestamp.BIG_BANG);
traceElement.setEndTime(TmfTimestamp.BIG_BANG);
}
} catch (TmfTraceException e1) {
/*
* Set the bounds to BIG_BANG to avoid trying to reread the
* trace.
*/
traceElement.setStartTime(TmfTimestamp.BIG_BANG);
traceElement.setEndTime(TmfTimestamp.BIG_BANG);
// $NON-NLS-1$ //$NON-NLS-2$
TraceCompassLogUtils.traceInstant(LOGGER, Level.CONFIG, "Failed to read time bounds", "trace", traceElement.getName());
} finally {
/*
* Leave the trace at the same initialization status as
* previously.
*/
if (!wasInitBefore) {
trace.dispose();
}
}
}
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException in project tracecompass by tracecompass.
the class KernelMemoryStateProviderTest method setUp.
/**
* Setup the trace for the tests
*/
@Before
public void setUp() {
ITmfTrace trace = new TmfXmlKernelTraceStub();
IPath filePath = Activator.getAbsoluteFilePath(KERNEL_MEMORY_USAGE_FILE);
IStatus status = trace.validate(null, filePath.toOSString());
if (!status.isOK()) {
fail(status.getException().getMessage());
}
try {
trace.initTrace(null, filePath.toOSString(), TmfEvent.class);
} catch (TmfTraceException e) {
fail(e.getMessage());
}
deleteSuppFiles(trace);
((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
fModule = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelMemoryAnalysisModule.class, KernelMemoryAnalysisModule.ID);
assertNotNull(fModule);
fTrace = trace;
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException in project tracecompass by tracecompass.
the class GdbTrace method initTrace.
@Override
public void initTrace(IResource resource, String path, Class<? extends ITmfEvent> type) throws TmfTraceException {
try {
String tracedExecutable = resource.getPersistentProperty(EXEC_KEY);
if (tracedExecutable == null) {
throw new TmfTraceException(Messages.GdbTrace_ExecutableNotSet);
}
String defaultGdbCommand = Platform.getPreferencesService().getString(GdbPlugin.PLUGIN_ID, IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND, IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT, null);
fGdbTpRef = new DsfGdbAdaptor(this, defaultGdbCommand, path, tracedExecutable);
fNbFrames = getNbFrames();
} catch (CoreException e) {
throw new TmfTraceException(Messages.GdbTrace_FailedToInitializeTrace, e);
}
super.initTrace(resource, path, type);
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException in project tracecompass by tracecompass.
the class TimeGraphViewTest method before.
/**
* Before the test is run, make the view see the items.
*
* Reset the perspective and close all the views.
*
* @throws TmfTraceException
* could not load a trace
*/
@Before
public void before() throws TmfTraceException {
fBot = new SWTWorkbenchBot();
fBot.closeAllEditors();
for (SWTBotView viewBot : fBot.views()) {
viewBot.close();
}
SWTBotUtils.openView(TimeGraphViewStub.ID);
fViewBot = fBot.viewById(TimeGraphViewStub.ID);
fViewBot.show();
fTrace = new TmfTraceStub() {
@Override
@NonNull
public String getName() {
return "Stub";
}
@Override
public TmfContext seekEvent(ITmfLocation location) {
return new TmfContext();
}
@Override
public ITmfTimestamp getInitialRangeOffset() {
return TmfTimestamp.fromNanos(80);
}
};
fTrace.setStartTime(TmfTimestamp.fromNanos(0));
fTrace.setEndTime(TmfTimestamp.fromNanos(180));
TmfTraceStub trace = fTrace;
trace.initialize(null, "", ITmfEvent.class);
assertNotNull(trace);
fTimeGraph = new SWTBotTimeGraph(fViewBot.bot());
// Wait for trace to be loaded
fViewBot.bot().waitUntil(new TgConditionHelper(t -> fTimeGraph.getEntries().length == 0));
fBounds = getBounds();
UIThreadRunnable.syncExec(() -> TmfSignalManager.dispatchSignal(new TmfTraceOpenedSignal(this, trace, null)));
// Wait for trace to be loaded
fViewBot.bot().waitUntil(new TgConditionHelper(t -> fTimeGraph.getEntries().length >= 2));
resetTimeRange();
// Make sure the thumb is over 1 in size
fBot.waitUntil(new TgConditionHelper(t -> fViewBot.bot().slider().getThumb() > 1));
}
Aggregations