gdbtrace: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ust.core / src / org / eclipse / linuxtools / internal / lttng2 / ust / core / trace / callstack / LttngUstCallStackProvider.java
index ae77fb4ce86afbaca6d7459762a6458321001509..15bc30a1aaf8431dc43611403a4f49925d90c488 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2013 Ericsson
+ * Copyright (c) 2013, 2014 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *   Alexandre Montplaisir - Initial API and implementation
+ *   Patrick Tasse - Add support for thread id
  *******************************************************************************/
 
 package org.eclipse.linuxtools.internal.lttng2.ust.core.trace.callstack;
@@ -15,11 +16,11 @@ package org.eclipse.linuxtools.internal.lttng2.ust.core.trace.callstack;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.eclipse.linuxtools.lttng2.ust.core.trace.LttngUstTrace;
 import org.eclipse.linuxtools.tmf.core.callstack.CallStackStateProvider;
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.ctf.core.CtfTmfEvent;
 
 /**
  * Callstack provider for LTTng-UST traces.
@@ -50,10 +51,10 @@ public class LttngUstCallStackProvider extends CallStackStateProvider {
     private static final String FIELD_ADDR = "addr"; //$NON-NLS-1$
 
     /** Event names indicating function entry */
-    private static final Set<String> FUNC_ENTRY_EVENTS = new HashSet<String>();
+    private static final Set<String> FUNC_ENTRY_EVENTS = new HashSet<>();
 
     /** Event names indicating function exit */
-    private static final Set<String> FUNC_EXIT_EVENTS = new HashSet<String>();
+    private static final Set<String> FUNC_EXIT_EVENTS = new HashSet<>();
 
     static {
         /* This seems overkill, but it will be checked every event. Gotta go FAST! */
@@ -68,7 +69,7 @@ public class LttngUstCallStackProvider extends CallStackStateProvider {
      * Version number of this state provider. Please bump this if you modify
      * the contents of the generated state history in some way.
      */
-    private static final int VERSION = 1;
+    private static final int VERSION = 2;
 
     // ------------------------------------------------------------------------
     // Constructor
@@ -80,7 +81,7 @@ public class LttngUstCallStackProvider extends CallStackStateProvider {
      * @param trace
      *            The UST trace
      */
-    public LttngUstCallStackProvider(LttngUstTrace trace) {
+    public LttngUstCallStackProvider(ITmfTrace trace) {
         super(trace);
     }
 
@@ -88,12 +89,6 @@ public class LttngUstCallStackProvider extends CallStackStateProvider {
     // Methods from AbstractTmfStateProvider
     // ------------------------------------------------------------------------
 
-    @Override
-    public LttngUstTrace getTrace() {
-        /* Type is enforced by the constructor */
-        return (LttngUstTrace) super.getTrace();
-    }
-
     @Override
     public LttngUstCallStackProvider getNewInstance() {
         return new LttngUstCallStackProvider(getTrace());
@@ -128,7 +123,7 @@ public class LttngUstCallStackProvider extends CallStackStateProvider {
 
     @Override
     public String functionEntry(ITmfEvent event) {
-        String eventName = ((CtfTmfEvent) event).getEventName();
+        String eventName = event.getType().getName();
         if (!FUNC_ENTRY_EVENTS.contains(eventName)) {
             return null;
         }
@@ -138,7 +133,7 @@ public class LttngUstCallStackProvider extends CallStackStateProvider {
 
     @Override
     public String functionExit(ITmfEvent event) {
-        String eventName = ((CtfTmfEvent) event).getEventName();
+        String eventName = event.getType().getName();
         if (!FUNC_EXIT_EVENTS.contains(eventName)) {
             return null;
         }
@@ -167,4 +162,10 @@ public class LttngUstCallStackProvider extends CallStackStateProvider {
 
         return new String(procName + '-' + vtid.toString());
     }
+
+    @Override
+    protected Long getThreadId(ITmfEvent event) {
+        ITmfEventField content = ((CtfTmfEvent) event).getContent();
+        return (Long) content.getField(CONTEXT_VTID).getValue();
+    }
 }
This page took 0.032279 seconds and 5 git commands to generate.