tmf: Add thread id to call stack state system
authorPatrick Tasse <patrick.tasse@gmail.com>
Fri, 11 Jul 2014 20:30:17 +0000 (16:30 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Fri, 18 Jul 2014 14:03:30 +0000 (10:03 -0400)
This will optionally be used for sorting threads

Change-Id: Ie38aba65745f123a5195ac1621a749d24fbffa93
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/29836
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Hudson CI
org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/internal/lttng2/ust/core/trace/callstack/LttngUstCallStackProvider.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/callstack/CallStackStateProvider.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/callstack/Messages.java

index 068b787b83396d37998a973a55ff8501879bba2f..b01a6de58ee78aad7d2936b9eda158059a310f0c 100644 (file)
@@ -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;
@@ -161,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();
+    }
 }
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;
+    }
 }
index 32d5f5855d3668bcb8bd984ee1f141ceff65d948..eaf0f7c3942a6011033003596d7eb3944954932d 100644 (file)
@@ -21,7 +21,7 @@ import org.eclipse.osgi.util.NLS;
  */
 public class Messages extends NLS {
 
-    private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.core.callstack"; //$NON-NLS-1$
+    private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.core.callstack.messages"; //$NON-NLS-1$
 
     /**
      * The value popped from a 'func_exit' event doesn't match the current
This page took 0.028794 seconds and 5 git commands to generate.