ss: Move plugins to Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / callstack / CallStackStateProvider.java
index cb9a2d419ba5f7aadf028a922da0cf0c93d5bd46..54f02e3eac2c112fcf6b2cd80a6f95c9e79ba6be 100644 (file)
@@ -53,7 +53,8 @@ import org.eclipse.osgi.util.NLS;
  *</pre>
  * where:
  * <br>
- * (Thread n) is an attribute whose name is the name of the thread
+ * (Thread n) is an attribute whose name is the display name of the thread.
+ * Optionally, its value is a long representing the thread id, used for sorting.
  * <br>
  * CallStack is a stack-attribute whose pushed values are either a string,
  * int or long representing the function name or address in the call stack.
@@ -97,9 +98,14 @@ public abstract class CallStackStateProvider extends AbstractTmfStateProvider {
             if (functionEntryName != null) {
                 long timestamp = event.getTimestamp().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
                 String thread = getThreadName(event);
-                int quark = ss.getQuarkAbsoluteAndAdd(THREADS, thread, CALL_STACK);
+                int threadQuark = ss.getQuarkAbsoluteAndAdd(THREADS, thread);
+                Long threadId = getThreadId(event);
+                if (threadId != null) {
+                    ss.updateOngoingState(TmfStateValue.newValueLong(threadId), threadQuark);
+                }
+                int callStackQuark = ss.getQuarkRelativeAndAdd(threadQuark, CALL_STACK);
                 ITmfStateValue value = TmfStateValue.newValueString(functionEntryName);
-                ss.pushAttribute(timestamp, value, quark);
+                ss.pushAttribute(timestamp, value, callStackQuark);
                 return;
             }
 
@@ -177,4 +183,16 @@ public abstract class CallStackStateProvider extends AbstractTmfStateProvider {
      * @since 3.0
      */
     protected abstract String getThreadName(ITmfEvent event);
+
+    /**
+     * Return the thread id of a function entry event.
+     *
+     * @param event
+     *            The event
+     * @return The thread id, or null if undefined
+     * @since 3.1
+     */
+    protected Long getThreadId(ITmfEvent event) {
+        return null;
+    }
 }
This page took 0.025319 seconds and 5 git commands to generate.