From ac31f2fbd9cd5816aa6df5d30d9c12fa7a8bd992 Mon Sep 17 00:00:00 2001 From: Patrick Tasse Date: Fri, 11 Jul 2014 16:30:17 -0400 Subject: [PATCH] tmf: Add thread id to call stack state system This will optionally be used for sorting threads Change-Id: Ie38aba65745f123a5195ac1621a749d24fbffa93 Signed-off-by: Patrick Tasse Reviewed-on: https://git.eclipse.org/r/29836 Reviewed-by: Matthew Khouzam Tested-by: Hudson CI --- .../callstack/LttngUstCallStackProvider.java | 7 ++++++ .../callstack/CallStackStateProvider.java | 24 ++++++++++++++++--- .../tmf/core/callstack/Messages.java | 2 +- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/internal/lttng2/ust/core/trace/callstack/LttngUstCallStackProvider.java b/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/internal/lttng2/ust/core/trace/callstack/LttngUstCallStackProvider.java index 068b787b83..b01a6de58e 100644 --- a/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/internal/lttng2/ust/core/trace/callstack/LttngUstCallStackProvider.java +++ b/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/internal/lttng2/ust/core/trace/callstack/LttngUstCallStackProvider.java @@ -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(); + } } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/callstack/CallStackStateProvider.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/callstack/CallStackStateProvider.java index cb9a2d419b..54f02e3eac 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/callstack/CallStackStateProvider.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/callstack/CallStackStateProvider.java @@ -53,7 +53,8 @@ import org.eclipse.osgi.util.NLS; * * where: *
- * (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. *
* 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; + } } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/callstack/Messages.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/callstack/Messages.java index 32d5f5855d..eaf0f7c394 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/callstack/Messages.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/callstack/Messages.java @@ -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 -- 2.34.1