os.linux: use Current_cpu_rq for control flow view tool tip
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Fri, 25 Nov 2016 21:11:06 +0000 (16:11 -0500)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Fri, 25 Nov 2016 23:33:02 +0000 (18:33 -0500)
Enable the displaying on hovering of the CPU run queue information for
thread in the WAIT_FOR_CPU state.

Using Current_cpu_rq is also valid for currently running thread.

Move the addition of the CPU tool tip attribute to
getEventHoverToolTipInfo so the presented information reflect the
reality at the hovering time.

Change-Id: Ib01cfd883e5ebc4b3f24143bebaf0ad5da74ff69
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/controlflow/ControlFlowPresentationProvider.java

index 14b087ab762f5eb87f8875652c45a3339a2616cc..917f1c0af2669fdaaeaf0d2e7e42768c29ca5e50 100644 (file)
@@ -14,7 +14,6 @@
 package org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.controlflow;
 
 import java.util.LinkedHashMap;
-import java.util.List;
 import java.util.Map;
 
 import org.eclipse.swt.SWT;
@@ -35,6 +34,7 @@ import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeExcept
 import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
 import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
+import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue.Type;
 import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.StateItem;
@@ -148,30 +148,7 @@ public class ControlFlowPresentationProvider extends TimeGraphPresentationProvid
         if (ssq == null) {
             return retMap;
         }
-        int tid = entry.getThreadId();
 
-        try {
-            // Find every CPU first, then get the current thread
-            int cpusQuark = ssq.getQuarkAbsolute(Attributes.CPUS);
-            List<Integer> cpuQuarks = ssq.getSubAttributes(cpusQuark, false);
-            for (Integer cpuQuark : cpuQuarks) {
-                int currentThreadQuark = ssq.getQuarkRelative(cpuQuark, Attributes.CURRENT_THREAD);
-                ITmfStateInterval interval = ssq.querySingleState(event.getTime(), currentThreadQuark);
-                if (!interval.getStateValue().isNull()) {
-                    ITmfStateValue state = interval.getStateValue();
-                    int currentThreadId = state.unboxInt();
-                    if (tid == currentThreadId) {
-                        retMap.put(Messages.ControlFlowView_attributeCpuName, ssq.getAttributeName(cpuQuark));
-                        break;
-                    }
-                }
-            }
-
-        } catch (AttributeNotFoundException | TimeRangeException | StateValueTypeException e) {
-            Activator.getDefault().logError("Error in ControlFlowPresentationProvider", e); //$NON-NLS-1$
-        } catch (StateSystemDisposedException e) {
-            /* Ignored */
-        }
         int status = ((TimeEvent) event).getValue();
         if (status == StateValues.PROCESS_STATUS_RUN_SYSCALL) {
             int syscallQuark = ssq.optQuarkRelative(entry.getThreadQuark(), Attributes.SYSTEM_CALL);
@@ -195,6 +172,41 @@ public class ControlFlowPresentationProvider extends TimeGraphPresentationProvid
         return retMap;
     }
 
+    @Override
+    public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event, long hoverTime) {
+        Map<String, String> retMap = super.getEventHoverToolTipInfo(event, hoverTime);
+        if (retMap == null) {
+            retMap = new LinkedHashMap<>();
+        }
+
+        if (!(event instanceof TimeEvent) || !((TimeEvent) event).hasValue() ||
+                !(event.getEntry() instanceof ControlFlowEntry)) {
+            return retMap;
+        }
+
+        ControlFlowEntry entry = (ControlFlowEntry) event.getEntry();
+        ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(entry.getTrace(), KernelAnalysisModule.ID);
+        if (ssq == null) {
+            return retMap;
+        }
+
+        try {
+            int currentCpuRqQuark = ssq.getQuarkRelative(entry.getThreadQuark(), Attributes.CURRENT_CPU_RQ);
+            ITmfStateInterval interval = ssq.querySingleState(hoverTime, currentCpuRqQuark);
+            ITmfStateValue value = interval.getStateValue();
+            if (value.getType() == Type.INTEGER) {
+                retMap.put(Messages.ControlFlowView_attributeCpuName, String.valueOf(value.unboxInt()));
+            }
+        } catch (AttributeNotFoundException | TimeRangeException | StateValueTypeException e) {
+            Activator.getDefault().logError("Error in ControlFlowPresentationProvider", e); //$NON-NLS-1$
+        } catch (StateSystemDisposedException e) {
+            /* Ignored */
+        }
+
+        return retMap;
+    }
+
+
     @Override
     public void postDrawEvent(ITimeEvent event, Rectangle bounds, GC gc) {
         if (fAverageCharacterWidth == null) {
This page took 0.027133 seconds and 5 git commands to generate.