lttng: Add a LttngUstEvent class for LttngUstTraces
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Fri, 4 Sep 2015 22:34:08 +0000 (18:34 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Fri, 23 Oct 2015 20:09:49 +0000 (16:09 -0400)
This class will support ITmfSourceLookup, now done through the
UST debug info analysis.

Change-Id: I904f7e8eb1811ab1f74ba95165d3d9167548ca3d
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/56192
Reviewed-by: Hudson CI
lttng/org.eclipse.tracecompass.lttng2.ust.core/META-INF/MANIFEST.MF
lttng/org.eclipse.tracecompass.lttng2.ust.core/plugin.xml
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEvent.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEventFactory.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstTrace.java

index 96aa139799f41a02aab4ff8969d2fa2447cc4954..a5a65bf968a7653aee414f47b5d48cf13363895e 100644 (file)
@@ -22,7 +22,8 @@ Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.tracecompass.common.core,
  org.eclipse.tracecompass.tmf.core,
  org.eclipse.tracecompass.tmf.ctf.core,
- org.eclipse.tracecompass.lttng2.control.core
+ org.eclipse.tracecompass.lttng2.control.core,
+ org.eclipse.tracecompass.ctf.core
 Import-Package: com.google.common.base,
  com.google.common.collect,
  com.google.common.io
index 4db528ef00c48eb5868aecaac36728bb9aeea7ed..f11891a8f8b423a9bdb162a347a5267dc9850bce 100644 (file)
@@ -5,7 +5,7 @@
          point="org.eclipse.linuxtools.tmf.core.tracetype">
       <type
             category="org.eclipse.linuxtools.tmf.ctf.core.category.ctf"
-            event_type="org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent"
+            event_type="org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstEvent"
             id="org.eclipse.linuxtools.lttng2.ust.tracetype"
             isDirectory="true"
             name="%tracetype.type.ust"
diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEvent.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEvent.java
new file mode 100644 (file)
index 0000000..3494ff4
--- /dev/null
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.lttng2.ust.core.trace;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
+import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
+import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoAspect;
+import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfCallsite;
+import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfSourceLookup;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
+import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
+
+/**
+ * Event type for use in LTTng-UST traces.
+ *
+ * @author Alexandre Montplaisir
+ * @since 2.0
+ */
+@NonNullByDefault
+public class LttngUstEvent extends CtfTmfEvent implements ITmfSourceLookup {
+
+    /**
+     * Default constructor. Only for use by extension points, should not be
+     * called directly.
+     */
+    @Deprecated
+    public LttngUstEvent() {
+        super();
+    }
+
+    /**
+     * Constructor
+     *
+     * @param trace
+     *            The trace to which this event belongs
+     * @param rank
+     *            The rank of the event
+     * @param timestamp
+     *            The timestamp
+     * @param channel
+     *            The CTF channel of this event
+     * @param cpu
+     *            The event's CPU
+     * @param declaration
+     *            The event declaration
+     * @param eventDefinition
+     *            The event definition
+     */
+    protected LttngUstEvent(CtfTmfTrace trace, long rank, TmfNanoTimestamp timestamp,
+            String channel, int cpu, IEventDeclaration declaration, EventDefinition eventDefinition) {
+        super(trace, rank, timestamp, channel, cpu, declaration, eventDefinition);
+    }
+
+    @Override
+    public @Nullable ITmfCallsite getCallsite() {
+        return UstDebugInfoAspect.INSTANCE.resolve(this);
+    }
+}
diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEventFactory.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEventFactory.java
new file mode 100644 (file)
index 0000000..9b6dca6
--- /dev/null
@@ -0,0 +1,69 @@
+/**********************************************************************
+ * Copyright (c) 2015 Ericsson and others
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ **********************************************************************/
+
+package org.eclipse.tracecompass.lttng2.ust.core.trace;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.ctf.core.CTFStrings;
+import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
+import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
+import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
+import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEventFactory;
+import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
+
+/**
+ * Factory for {@link LttngUstEvent}.
+ *
+ * @author Matthew Khouzam
+ * @author Alexandre Montplaisir
+ * @since 2.0
+ */
+public class LttngUstEventFactory extends CtfTmfEventFactory {
+
+    private static final @NonNull LttngUstEventFactory INSTANCE = new LttngUstEventFactory();
+
+    /**
+     * Private constructor.
+     */
+    private LttngUstEventFactory() {
+        super();
+    }
+
+    public static @NonNull LttngUstEventFactory instance() {
+        return INSTANCE;
+    }
+
+    @Override
+    public CtfTmfEvent createEvent(CtfTmfTrace trace, EventDefinition eventDef, String fileName) {
+        /* Prepare what to pass to CtfTmfEvent's constructor */
+        final IEventDeclaration eventDecl = eventDef.getDeclaration();
+        final long ts = eventDef.getTimestamp();
+        final TmfNanoTimestamp timestamp = trace.createTimestamp(trace.timestampCyclesToNanos(ts));
+
+        int sourceCPU = eventDef.getCPU();
+
+        String reference = (fileName == null ? NO_STREAM : fileName);
+
+        /* Handle the special case of lost events */
+        if (eventDecl.getName().equals(CTFStrings.LOST_EVENT_NAME)) {
+            return createLostEvent(trace, eventDef, eventDecl, ts, timestamp, sourceCPU, reference);
+        }
+
+        /* Handle standard event types */
+        return new LttngUstEvent(trace,
+                ITmfContext.UNKNOWN_RANK,
+                timestamp,
+                reference, // filename
+                sourceCPU,
+                eventDecl,
+                eventDef);
+    }
+}
\ No newline at end of file
index 64b8c2ecafba695f9b70a8005351f023be94942e..2d4d86e5d61be33b1ea14940935a60d9a55600f2 100644 (file)
@@ -72,7 +72,7 @@ public class LttngUstTrace extends CtfTmfTrace {
      * Default constructor
      */
     public LttngUstTrace() {
-        super();
+        super(LttngUstEventFactory.instance());
     }
 
     /**
This page took 0.043102 seconds and 5 git commands to generate.