Search in sources :

Example 1 with ITmfEventAspect

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

the class LttngKernelTrace method initTrace.

@Override
public void initTrace(IResource resource, String path, Class<? extends ITmfEvent> eventType) throws TmfTraceException {
    super.initTrace(resource, path, eventType);
    /*
         * Add aspects
         */
    fOriginTracer = getTracerFromEnv();
    ImmutableList.Builder<ITmfEventAspect<?>> builder = new Builder<>();
    builder.addAll(LTTNG_KERNEL_ASPECTS);
    builder.addAll(createCounterAspects(this));
    ContextPidAspect pidAspect = ContextPidAspect.getAspect(this);
    if (pidAspect != null) {
        builder.add(pidAspect);
    }
    ContextTidAspect tidAspect = ContextTidAspect.getAspect(this);
    if (tidAspect != null) {
        builder.add(tidAspect);
    }
    fAspects = builder.build();
}
Also used : ITmfEventAspect(org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect) ImmutableList(com.google.common.collect.ImmutableList) Builder(com.google.common.collect.ImmutableList.Builder) ContextTidAspect(org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.ContextTidAspect) ContextPidAspect(org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.ContextPidAspect)

Example 2 with ITmfEventAspect

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

the class TmfFilterHelperTest method testInputRegexNoField.

/**
 * Test a regex with no parameter
 */
@Test
public void testInputRegexNoField() {
    String regex = "afield";
    ITmfFilter filter = getFilter(regex);
    assertTrue(filter instanceof TmfFilterRootNode);
    TmfFilterRootNode node = (TmfFilterRootNode) filter;
    assertEquals(1, node.getChildrenCount());
    ITmfFilterTreeNode child = node.getChild(0);
    assertTrue(child instanceof TmfFilterOrNode);
    // Verify the orNode
    TmfFilterOrNode orNode = (TmfFilterOrNode) child;
    ITmfTrace trace = STUB_TRACE;
    assertNotNull(trace);
    Iterable<@NonNull ITmfEventAspect<?>> eventAspects = trace.getEventAspects();
    // Verify that each child is a matches node and there's one per aspect
    assertEquals(Iterables.size(eventAspects), orNode.getChildrenCount());
    for (int i = 0; i < orNode.getChildrenCount(); i++) {
        assertTrue(orNode.getChild(i) instanceof TmfFilterMatchesNode);
    }
    for (ITmfEventAspect<?> aspect : eventAspects) {
        // Find a contains condition for each aspect
        ITmfFilterTreeNode[] children = orNode.getChildren();
        TmfFilterMatchesNode found = null;
        for (int i = 0; i < children.length; i++) {
            TmfFilterMatchesNode childFilter = (TmfFilterMatchesNode) children[i];
            if (aspect.equals(childFilter.getEventAspect())) {
                found = childFilter;
                break;
            }
        }
        assertNotNull("found aspect " + aspect.getName(), found);
        assertEquals(regex, found.getRegex());
    }
    // Test expected behavior on events
    assertTrue(filter.matches(fEvent1));
    assertFalse(filter.matches(fEvent2));
    assertTrue(filter.matches(fEvent3));
}
Also used : ITmfFilterTreeNode(org.eclipse.tracecompass.tmf.core.filter.model.ITmfFilterTreeNode) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfEventAspect(org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect) TmfFilterOrNode(org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterOrNode) ITmfFilter(org.eclipse.tracecompass.tmf.core.filter.ITmfFilter) TmfFilterMatchesNode(org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterMatchesNode) TmfFilterRootNode(org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterRootNode) Test(org.junit.Test)

Example 3 with ITmfEventAspect

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

the class TmfEventTableDataProvider method getExperimentAspects.

/**
 * Get the events table for an experiment. If all traces in the experiment are
 * of the same type, use the same behavior as if it was one trace of that type.
 *
 * @param experiment
 *            the experiment
 * @param parent
 *            the parent Composite
 * @param cacheSize
 *            the event table cache size
 * @return An event table of the appropriate type
 */
private static Iterable<ITmfEventAspect<?>> getExperimentAspects(TmfExperiment experiment) {
    List<ITmfTrace> traces = experiment.getTraces();
    ImmutableSet.Builder<ITmfEventAspect<?>> builder = new ImmutableSet.Builder<>();
    /* For experiments, we'll add a "trace name" aspect/column */
    builder.add(TmfBaseAspects.getTraceNameAspect());
    if (hasCommonTraceType(experiment)) {
        /*
             * All the traces in this experiment are of the same type, let's just use the
             * normal table for that type.
             */
        builder.addAll(traces.get(0).getEventAspects());
    } else {
        /*
             * There are different trace types in the experiment, so we are definitely using
             * a TmfEventsTable. Aggregate the columns from all trace types.
             */
        for (ITmfTrace trace : traces) {
            builder.addAll(trace.getEventAspects());
        }
    }
    return builder.build();
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfEventAspect(org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect) ImmutableSet(com.google.common.collect.ImmutableSet)

Example 4 with ITmfEventAspect

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

the class TmfEventsEditor method createEventsTable.

/**
 * Create the event table
 *
 * @param parent
 *            The parent composite
 * @param cacheSize
 *            The cache size
 * @return The event table instance
 */
@NonNull
protected TmfEventsTable createEventsTable(final Composite parent, final int cacheSize) {
    ITmfTrace trace = fTrace;
    /*
         * Check if the trace (or experiment type) defines a specific event
         * table in its extension point.
         */
    TmfEventsTable table = TmfTraceTypeUIUtils.getEventTable(trace, parent, cacheSize);
    if (table != null) {
        return table;
    }
    /*
         * Use the aspects defined by the trace type (or each trace type in an
         * experiment) to build a table consisting of these.
         */
    Iterable<ITmfEventAspect<?>> aspects = getTraceAspects(trace);
    if (Iterables.isEmpty(aspects)) {
        /* Couldn't find any event aspects, use a default table */
        return new TmfEventsTable(parent, cacheSize);
    }
    return new TmfEventsTable(parent, cacheSize, aspects);
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfEventAspect(org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect) TmfEventsTable(org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 5 with ITmfEventAspect

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

the class CustomEventAspects method generateAspects.

/**
 * Build a set of event aspects for a given trace definition
 *
 * @param definition
 *            The {@link CustomTraceDefinition} of the trace for which you
 *            want the aspects
 * @return The set of event aspects for the given trace
 */
@NonNull
public static Iterable<ITmfEventAspect<?>> generateAspects(CustomTraceDefinition definition) {
    List<String> fieldNames = new ArrayList<>();
    ImmutableList.Builder<ITmfEventAspect<?>> builder = new ImmutableList.Builder<>();
    for (OutputColumn output : definition.outputs) {
        if (output.tag.equals(Tag.TIMESTAMP) && (definition.timeStampOutputFormat == null || definition.timeStampOutputFormat.isEmpty())) {
            builder.add(TmfBaseAspects.getTimestampAspect());
            fieldNames.add(output.name);
        } else if (output.tag.equals(Tag.EVENT_TYPE)) {
            builder.add(TmfBaseAspects.getEventTypeAspect());
            fieldNames.add(output.name);
        } else if (output.tag.equals(Tag.EXTRA_FIELD_NAME) || output.tag.equals(Tag.EXTRA_FIELD_VALUE)) {
            // These tags should have been substituted with Tag.EXTRA_FIELDS
            continue;
        } else if (output.tag.equals(Tag.EXTRA_FIELDS)) {
            builder.add(new CustomExtraFieldsAspect());
        } else {
            builder.add(new TmfContentFieldAspect(output.name, output.name));
            fieldNames.add(output.name);
        }
    }
    return builder.build();
}
Also used : ITmfEventAspect(org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect) ImmutableList(com.google.common.collect.ImmutableList) TmfContentFieldAspect(org.eclipse.tracecompass.tmf.core.event.aspect.TmfContentFieldAspect) ArrayList(java.util.ArrayList) OutputColumn(org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition.OutputColumn) NonNull(org.eclipse.jdt.annotation.NonNull)

Aggregations

ITmfEventAspect (org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect)14 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)5 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableSet (com.google.common.collect.ImmutableSet)3 ArrayList (java.util.ArrayList)3 NonNull (org.eclipse.jdt.annotation.NonNull)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Nullable (org.eclipse.jdt.annotation.Nullable)2 Point (org.eclipse.swt.graphics.Point)2 TableColumn (org.eclipse.swt.widgets.TableColumn)2 EventTableLine (org.eclipse.tracecompass.internal.provisional.tmf.core.model.table.EventTableLine)2 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)2 TmfContentFieldAspect (org.eclipse.tracecompass.tmf.core.event.aspect.TmfContentFieldAspect)2 TmfEventTableColumn (org.eclipse.tracecompass.tmf.ui.viewers.events.columns.TmfEventTableColumn)2 Builder (com.google.common.collect.ImmutableList.Builder)1 HashMap (java.util.HashMap)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 Action (org.eclipse.jface.action.Action)1 IAction (org.eclipse.jface.action.IAction)1 TableEditor (org.eclipse.swt.custom.TableEditor)1