tmf: Split "CTF adaptor" into separate plugins/feature
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ust.core / src / org / eclipse / linuxtools / internal / lttng2 / ust / core / trace / callstack / LttngUstCallStackProvider.java
index 3be120963f78d92e76dcfa8d40273a28c501fdb6..068b787b83396d37998a973a55ff8501879bba2f 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
@@ -15,11 +15,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 +50,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! */
@@ -64,6 +64,12 @@ public class LttngUstCallStackProvider extends CallStackStateProvider {
         FUNC_EXIT_EVENTS.add("lttng_ust_cyg_profile_fast:func_exit"); //$NON-NLS-1$
     }
 
+    /**
+     * 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;
+
     // ------------------------------------------------------------------------
     // Constructor
     // ------------------------------------------------------------------------
@@ -74,7 +80,7 @@ public class LttngUstCallStackProvider extends CallStackStateProvider {
      * @param trace
      *            The UST trace
      */
-    public LttngUstCallStackProvider(LttngUstTrace trace) {
+    public LttngUstCallStackProvider(ITmfTrace trace) {
         super(trace);
     }
 
@@ -83,14 +89,13 @@ public class LttngUstCallStackProvider extends CallStackStateProvider {
     // ------------------------------------------------------------------------
 
     @Override
-    public LttngUstTrace getTrace() {
-        /* Type is enforced by the constructor */
-        return (LttngUstTrace) super.getTrace();
+    public LttngUstCallStackProvider getNewInstance() {
+        return new LttngUstCallStackProvider(getTrace());
     }
 
     @Override
-    public LttngUstCallStackProvider getNewInstance() {
-        return new LttngUstCallStackProvider(getTrace());
+    public int getVersion() {
+        return VERSION;
     }
 
     // ------------------------------------------------------------------------
@@ -117,17 +122,17 @@ 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;
         }
         Long address = (Long) event.getContent().getField(FIELD_ADDR).getValue();
-        return getFunctionNameFromAddress(address.longValue());
+        return Long.toHexString(address);
     }
 
     @Override
     public String functionExit(ITmfEvent event) {
-        String eventName = ((CtfTmfEvent) event).getEventName();
+        String eventName = event.getType().getName();
         if (!FUNC_EXIT_EVENTS.contains(eventName)) {
             return null;
         }
@@ -140,7 +145,7 @@ public class LttngUstCallStackProvider extends CallStackStateProvider {
             return CallStackStateProvider.UNDEFINED;
         }
         Long address = (Long) field.getValue();
-        return getFunctionNameFromAddress(address.longValue());
+        return Long.toHexString(address);
     }
 
     @Override
@@ -156,16 +161,4 @@ public class LttngUstCallStackProvider extends CallStackStateProvider {
 
         return new String(procName + '-' + vtid.toString());
     }
-
-    // ------------------------------------------------------------------------
-    // Internal helper methods
-    // ------------------------------------------------------------------------
-
-    private static String getFunctionNameFromAddress(long address) {
-        /*
-         * We do not support getting the real function name yet, just print the
-         * hex string.
-         */
-        return new String("0x" + Long.toHexString(address)); //$NON-NLS-1$
-    }
 }
This page took 0.02624 seconds and 5 git commands to generate.