Search in sources :

Example 1 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class UstKernelSyncTest method testOneEvent.

/**
 * Test that the TID given by the kernel analysis matches the one from the
 * UST event's context for a given UST event that was known to fail.
 *
 * Reproduces the specific example that was pointed out in bug 484620.
 */
@Test
public void testOneEvent() {
    TmfExperiment experiment = fExperiment;
    ITmfTrace ustTrace = fUstTrace;
    KernelAnalysisModule module = fKernelModule;
    assertNotNull(experiment);
    assertNotNull(ustTrace);
    assertNotNull(module);
    Predicate<@NonNull ITmfEvent> eventFinder = event -> {
        Long addr = event.getContent().getFieldValue(Long.class, "addr");
        Long cs = event.getContent().getFieldValue(Long.class, "call_site");
        Long ctxVtid = event.getContent().getFieldValue(Long.class, "context._vtid");
        if (addr == null || cs == null || ctxVtid == null) {
            return false;
        }
        return Objects.equals(event.getType().getName(), "lttng_ust_cyg_profile:func_entry") && Objects.equals(Long.toHexString(addr), "804af97") && Objects.equals(Long.toHexString(cs), "804ab03") && Objects.equals(ctxVtid.longValue(), 594L);
    };
    /* The event we're looking for is the second event matching the predicate */
    CtfTmfEvent ustEvent = (CtfTmfEvent) TmfTraceUtils.getNextEventMatching(experiment, 0, eventFinder, null);
    assertNotNull(ustEvent);
    long rank = experiment.seekEvent(ustEvent.getTimestamp()).getRank() + 1;
    ustEvent = (CtfTmfEvent) TmfTraceUtils.getNextEventMatching(experiment, rank, eventFinder, null);
    assertNotNull(ustEvent);
    /* Make sure the correct event was retrieved */
    assertEquals(ustTrace, ustEvent.getTrace());
    assertEquals(1450193715128075054L, ustEvent.getTimestamp().toNanos());
    Integer tidFromKernel = KernelThreadInformationProvider.getThreadOnCpu(module, ustEvent.getCPU(), ustEvent.getTimestamp().toNanos());
    assertNotNull(tidFromKernel);
    assertEquals(594, tidFromKernel.intValue());
}
Also used : CtfTestTrace(org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) TestRule(org.junit.rules.TestRule) CtfTmfTestTraceUtils(org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) KernelAnalysisModule(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule) After(org.junit.After) Timeout(org.junit.rules.Timeout) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) LttngKernelTestTraceUtils(org.eclipse.tracecompass.lttng2.lttng.kernel.core.tests.shared.LttngKernelTestTraceUtils) Before(org.junit.Before) TmfTraceSelectedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal) KernelThreadInformationProvider(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelThreadInformationProvider) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) Assert.assertNotNull(org.junit.Assert.assertNotNull) Predicate(java.util.function.Predicate) Test(org.junit.Test) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) Rule(org.junit.Rule) TmfTraceUtils(org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils) TmfSignalManager(org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager) NonNull(org.eclipse.jdt.annotation.NonNull) Assert.assertEquals(org.junit.Assert.assertEquals) CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) KernelAnalysisModule(org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule) Test(org.junit.Test)

Example 2 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class UstDebugInfoAnalysisModuleTest method testBinaryCallsites.

/**
 * Test that the binary callsite aspect resolves correctly for some
 * user-defined tracepoints in the trace.
 *
 * These should be available even without the binaries with debug symbols
 * being present on the system.
 */
@Test
public void testBinaryCallsites() {
    LttngUstTrace trace = LttngUstTestTraceUtils.getTrace(REAL_TEST_TRACE);
    /*
         * Fake a "trace opened" signal, so that the relevant analyses are
         * started.
         */
    TmfTraceOpenedSignal signal = new TmfTraceOpenedSignal(this, trace, null);
    TmfSignalManager.dispatchSignal(signal);
    UstDebugInfoAnalysisModule module = TmfTraceUtils.getAnalysisModuleOfClass(trace, UstDebugInfoAnalysisModule.class, UstDebugInfoAnalysisModule.ID);
    assertNotNull(module);
    module.waitForCompletion();
    /* Send a request to get the 3 events we are interested in */
    List<@NonNull LttngUstEvent> events = new ArrayList<>();
    TmfEventRequest request = new TmfEventRequest(LttngUstEvent.class, 31, 1, ExecutionType.FOREGROUND) {

        @Override
        public void handleData(ITmfEvent event) {
            super.handleData(event);
            events.add((LttngUstEvent) event);
        }
    };
    trace.sendRequest(request);
    try {
        request.waitForCompletion();
    } catch (InterruptedException e) {
        fail(e.getMessage());
    }
    /* Tests that the aspects are resolved correctly */
    final UstDebugInfoBinaryAspect aspect = UstDebugInfoBinaryAspect.INSTANCE;
    String actual = checkNotNull(aspect.resolve(events.get(0))).toString();
    String expected = "/home/simark/src/babeltrace/tests/debug-info-data/libhello_so+0x14d4";
    assertEquals(expected, actual);
    LttngUstTestTraceUtils.dispose(REAL_TEST_TRACE);
}
Also used : LttngUstTrace(org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace) ArrayList(java.util.ArrayList) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) LttngUstEvent(org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstEvent) UstDebugInfoBinaryAspect(org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoBinaryAspect) UstDebugInfoAnalysisModule(org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoAnalysisModule) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 3 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfEventTest method testHashCode.

// ------------------------------------------------------------------------
// hashCode
// ------------------------------------------------------------------------
@Test
public void testHashCode() {
    ITmfEvent event1 = new TmfEvent(fTrace, ITmfContext.UNKNOWN_RANK, null, null, null);
    ITmfEvent event2 = new TmfEvent(fTrace, ITmfContext.UNKNOWN_RANK, null, null, null);
    assertTrue("hashCode", event1.hashCode() == event2.hashCode());
    final ITmfTrace trace = fTrace;
    event1 = new TmfEvent(trace, 0, fTimestamp1, fType, fContent1);
    event2 = new TmfEvent(trace, 1, fTimestamp2, fType, fContent2);
    final ITmfEvent event1b = new TmfEvent(event1);
    final ITmfEvent event2b = new TmfEvent(event2);
    assertTrue("hashCode", event1.hashCode() == event1b.hashCode());
    assertTrue("hashCode", event2.hashCode() == event2b.hashCode());
    assertTrue("hashCode", event1.hashCode() != event2.hashCode());
    assertTrue("hashCode", event2.hashCode() != event1.hashCode());
    trace.dispose();
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfEvent(org.eclipse.tracecompass.tmf.core.event.TmfEvent) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Test(org.junit.Test)

Example 4 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfCoalescedEventRequestTest method trigger.

/**
 * @param signal
 *            the trigger signal
 */
@TmfSignalHandler
public void trigger(final TmfTestTriggerSignal2 signal) {
    TmfTimeRange range = new TmfTimeRange(TmfTimestamp.create(100, -3), TmfTimestamp.BIG_CRUNCH);
    requestedEvents1 = new Vector<>();
    request1 = new TmfEventRequest(ITmfEvent.class, range, 0, 1, ExecutionType.FOREGROUND) {

        @Override
        public void handleData(ITmfEvent event) {
            super.handleData(event);
            if (!isCompleted()) {
                requestedEvents1.add(event);
            }
        }
    };
    providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
    providers[0].sendRequest(request1);
}
Also used : ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 5 with ITmfEvent

use of org.eclipse.tracecompass.tmf.core.event.ITmfEvent in project tracecompass by tracecompass.

the class TmfCoalescedEventRequestTest method trigger.

@TmfSignalHandler
public void trigger(final TmfTestTriggerSignal signal) {
    TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
    final long REQUEST_OFFSET = 1000;
    requestedEvents1 = new Vector<>();
    request1 = new TmfEventRequest(ITmfEvent.class, range, signal.fIndex, NB_EVENTS, ExecutionType.FOREGROUND) {

        @Override
        public void handleData(ITmfEvent event) {
            super.handleData(event);
            if (!isCompleted()) {
                requestedEvents1.add(event);
                if (signal.forceCancel) {
                    cancel();
                }
            }
        }
    };
    requestedEvents2 = new Vector<>();
    request2 = new TmfEventRequest(ITmfEvent.class, range, signal.fIndex + REQUEST_OFFSET, NB_EVENTS, ExecutionType.FOREGROUND) {

        @Override
        public void handleData(ITmfEvent event) {
            super.handleData(event);
            if (!isCompleted()) {
                requestedEvents2.add(event);
            }
        }
    };
    requestedEvents3 = new Vector<>();
    request3 = new TmfEventRequest(ITmfEvent.class, range, signal.fIndex + 2 * REQUEST_OFFSET, NB_EVENTS, ExecutionType.FOREGROUND) {

        @Override
        public void handleData(ITmfEvent event) {
            super.handleData(event);
            if (!isCompleted()) {
                requestedEvents3.add(event);
            }
        }
    };
    providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
    providers[0].sendRequest(request1);
    providers[0].sendRequest(request2);
    providers[0].sendRequest(request3);
}
Also used : ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Aggregations

ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)182 Test (org.junit.Test)127 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)112 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)40 TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)30 AnalysisManagerTest (org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest)27 ITmfLocation (org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation)25 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)24 NonNull (org.eclipse.jdt.annotation.NonNull)20 TmfEvent (org.eclipse.tracecompass.tmf.core.event.TmfEvent)17 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)16 Vector (java.util.Vector)15 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)15 Predicate (java.util.function.Predicate)14 TmfTraceUtils (org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils)14 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)13 CtfTestTrace (org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace)13 CtfTmfTestTraceUtils (org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils)13 Assert.assertEquals (org.junit.Assert.assertEquals)13 Assert.assertNotNull (org.junit.Assert.assertNotNull)13