Search in sources :

Example 21 with TmfTraceException

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;
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent)

Example 22 with TmfTraceException

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();
            }
        }
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException)

Example 23 with TmfTraceException

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;
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IStatus(org.eclipse.core.runtime.IStatus) TmfXmlKernelTraceStub(org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.TmfXmlKernelTraceStub) IPath(org.eclipse.core.runtime.IPath) TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) KernelMemoryAnalysisModule(org.eclipse.tracecompass.analysis.os.linux.core.kernelmemoryusage.KernelMemoryAnalysisModule) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) Before(org.junit.Before)

Example 24 with TmfTraceException

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);
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException)

Example 25 with TmfTraceException

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));
}
Also used : TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) UIThreadRunnable(org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable) TmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp) Conditions(org.eclipse.swtbot.swt.finder.waits.Conditions) DefaultCondition(org.eclipse.swtbot.swt.finder.waits.DefaultCondition) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) ConditionHelpers(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers) Point(org.eclipse.swt.graphics.Point) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) Logger(org.apache.log4j.Logger) SWTBotUtils(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils) KeyEvent(org.eclipse.swt.events.KeyEvent) After(org.junit.After) IPaletteProvider(org.eclipse.tracecompass.tmf.core.presentation.IPaletteProvider) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) SequentialPaletteProvider(org.eclipse.tracecompass.tmf.core.presentation.SequentialPaletteProvider) RGBAColor(org.eclipse.tracecompass.tmf.core.presentation.RGBAColor) TimeGraphControl(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl) AfterClass(org.junit.AfterClass) Predicate(java.util.function.Predicate) SimpleLayout(org.apache.log4j.SimpleLayout) SWTBotPreferences(org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences) QualitativePaletteProvider(org.eclipse.tracecompass.tmf.core.presentation.QualitativePaletteProvider) TmfContext(org.eclipse.tracecompass.tmf.core.trace.TmfContext) Multisets(com.google.common.collect.Multisets) Display(org.eclipse.swt.widgets.Display) SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) Collectors(java.util.stream.Collectors) TmfFileDialogFactory(org.eclipse.tracecompass.tmf.ui.dialog.TmfFileDialogFactory) Objects(java.util.Objects) MouseEvent(org.eclipse.swt.events.MouseEvent) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) List(java.util.List) AbstractTimeGraphView(org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView) Assert.assertFalse(org.junit.Assert.assertFalse) ConsoleAppender(org.apache.log4j.ConsoleAppender) SWT(org.eclipse.swt.SWT) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) ITmfLocation(org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation) TmfSignalManager(org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager) TmfTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub) NonNull(org.eclipse.jdt.annotation.NonNull) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) KeyStroke(org.eclipse.jface.bindings.keys.KeyStroke) BeforeClass(org.junit.BeforeClass) Multiset(com.google.common.collect.Multiset) RunWith(org.junit.runner.RunWith) Rectangle(org.eclipse.swt.graphics.Rectangle) Keystrokes(org.eclipse.swtbot.swt.finder.keyboard.Keystrokes) Event(org.eclipse.swt.widgets.Event) ArrayList(java.util.ArrayList) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) Lists(com.google.common.collect.Lists) ImageHelper(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ImageHelper) ImmutableMultiset(com.google.common.collect.ImmutableMultiset) RGB(org.eclipse.swt.graphics.RGB) SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) Before(org.junit.Before) ITimeDataProvider(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.ITimeDataProvider) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) File(java.io.File) SWTBotButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotButton) SWTBotTimeGraphEntry(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraphEntry) SWTBotJunit4ClassRunner(org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner) ListResult(org.eclipse.swtbot.swt.finder.results.ListResult) Ignore(org.junit.Ignore) Result(org.eclipse.swtbot.swt.finder.results.Result) SWTBotTimeGraph(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph) ICondition(org.eclipse.swtbot.swt.finder.waits.ICondition) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) Assert.assertEquals(org.junit.Assert.assertEquals) Control(org.eclipse.swt.widgets.Control) RGBAUtil(org.eclipse.tracecompass.tmf.ui.colors.RGBAUtil) SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) TmfContext(org.eclipse.tracecompass.tmf.core.trace.TmfContext) SWTBotTimeGraph(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph) TmfTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub) NonNull(org.eclipse.jdt.annotation.NonNull) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) ITmfLocation(org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation) Before(org.junit.Before)

Aggregations

TmfTraceException (org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException)50 File (java.io.File)17 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)14 IStatus (org.eclipse.core.runtime.IStatus)12 TmfTraceOpenedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal)12 TmfTraceStub (org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub)11 IOException (java.io.IOException)10 IPath (org.eclipse.core.runtime.IPath)8 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)8 TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)8 TmfXmlKernelTraceStub (org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.TmfXmlKernelTraceStub)7 Performance (org.eclipse.test.performance.Performance)6 PerformanceMeter (org.eclipse.test.performance.PerformanceMeter)6 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)6 TmfTrace (org.eclipse.tracecompass.tmf.core.trace.TmfTrace)6 Before (org.junit.Before)6 LttngKernelTrace (org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace)5 CtfTmfTrace (org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4