lttng: Bug 416062: Control Flow arrows don't follow through idle state
authorPatrick Tasse <patrick.tasse@gmail.com>
Wed, 28 Aug 2013 15:19:57 +0000 (11:19 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Sat, 31 Aug 2013 04:16:30 +0000 (00:16 -0400)
Change-Id: Ib42709cf5ad4aafff96091690d9f2c7477772cde
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/15939
Tested-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
IP-Clean: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
org.eclipse.linuxtools.lttng.help/doc/User-Guide.mediawiki
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/Messages.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/messages.properties
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java

index 91c7a06cf5edad5204037f091ac03937ee47a2cc..ccc5d485b1c4486c2cd0e286473c63b40496bf48 100644 (file)
@@ -1387,9 +1387,9 @@ This dark yellow is what you'll see most of the time since scheduling puts proce
 
 The vertical blue line with T1 above it is the '''current selection indicator'''. When a time range is selected, the region between the begin and end time of the selection will be shaded and two lines with T1 and T2 above will be displayed. The time stamps corresponding to T1, T2 and their delta are shown in the status line when the mouse is hovering over the control flow.
 
-Arrows can be displayed that follow the execution of each CPU across processes. The arrows indicate when the scheduler switches from one process to another for a given CPU. The CPU being followed is indicated on the state tooltip. When the scheduler switches to or from the idle process, no arrow is displayed.
+Arrows can be displayed that follow the execution of each CPU across processes. The arrows indicate when the scheduler switches from one process to another for a given CPU. The CPU being followed is indicated on the state tooltip. When the scheduler switches to and from the idle process, the arrow skips to the next process which executes on the CPU after the idle process. Note that an appropriate zoom level is required for all arrows to be displayed.
 
-The display of arrows is optional and can be toggled using the '''Hide Arrows''' toolbar button. It is also possible to follow a CPU's execution across state changes and scheduler switching using the '''Follow Arrow Forward/Backward''' toolbar buttons.
+The display of arrows is optional and can be toggled using the '''Hide Arrows''' toolbar button. It is also possible to follow a CPU's execution across state changes and the scheduler's process switching using the '''Follow CPU Forward/Backward''' toolbar buttons.
 
 ==== Using the mouse ====
 
@@ -1490,11 +1490,11 @@ The Control Flow View '''toolbar''', located at the top right of the view, has s
 | Toggles the display of arrows on or off
 |-
 | [[Image:images/follow_arrow_bwd.gif]]
-| Follow Arrow Backward
+| Follow CPU Backward
 | Selects the previous state following CPU execution across processes
 |-
 | [[Image:images/follow_arrow_fwd.gif]]
-| Follow Arrow Forward
+| Follow CPU Forward
 | Selects the next state following CPU execution across processes
 |}
 
index 8a1cd19bcf9140385bf23d7a7609df7be1f856cf..7200352850e6b9b6f37570416d091d0920cd3514 100644 (file)
@@ -29,6 +29,8 @@ public class Messages extends NLS {
     public static String ControlFlowView_nextProcessActionToolTipText;
     public static String ControlFlowView_previousProcessActionNameText;
     public static String ControlFlowView_previousProcessActionToolTipText;
+    public static String ControlFlowView_followCPUBwdText;
+    public static String ControlFlowView_followCPUFwdText;
 
     public static String ControlFlowView_attributeSyscallName;
     public static String ControlFlowView_attributeCpuName;
index e4f58b4e848f557e5a50c9edc65675c2e78404b1..29e75b8991ee09f2551cee556c1b7837484b8694 100644 (file)
@@ -22,6 +22,8 @@ ControlFlowView_nextProcessActionNameText=Next Process
 ControlFlowView_nextProcessActionToolTipText=Select Next Process
 ControlFlowView_previousProcessActionNameText=Previous Process
 ControlFlowView_previousProcessActionToolTipText=Select Previous Process
+ControlFlowView_followCPUBwdText=Follow CPU Backward
+ControlFlowView_followCPUFwdText=Follow CPU Forward
 
 ControlFlowView_attributeSyscallName=System Call
 ControlFlowView_attributeCpuName=CPU
index b6ed8dc3cdeb3fb5f3b43f71080a633539bae86f..12ef3d2e1f264c3b883b0e792722f96201a1d6e7 100644 (file)
@@ -19,6 +19,7 @@ import java.util.Comparator;
 import java.util.List;
 
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
@@ -102,9 +103,19 @@ public class ControlFlowView extends AbstractTimeGraphView {
         if (section == null) {
             section = settings.addNewSection(getClass().getName());
         }
-        manager.add(getTimeGraphCombo().getTimeGraphViewer().getHideArrowsAction(section));
-        manager.add(getTimeGraphCombo().getTimeGraphViewer().getFollowArrowBwdAction());
-        manager.add(getTimeGraphCombo().getTimeGraphViewer().getFollowArrowFwdAction());
+
+        IAction hideArrowsAction = getTimeGraphCombo().getTimeGraphViewer().getHideArrowsAction(section);
+        manager.add(hideArrowsAction);
+
+        IAction followArrowBwdAction = getTimeGraphCombo().getTimeGraphViewer().getFollowArrowBwdAction();
+        followArrowBwdAction.setText(Messages.ControlFlowView_followCPUBwdText);
+        followArrowBwdAction.setToolTipText(Messages.ControlFlowView_followCPUBwdText);
+        manager.add(followArrowBwdAction);
+
+        IAction followArrowFwdAction = getTimeGraphCombo().getTimeGraphViewer().getFollowArrowFwdAction();
+        followArrowFwdAction.setText(Messages.ControlFlowView_followCPUFwdText);
+        followArrowFwdAction.setToolTipText(Messages.ControlFlowView_followCPUFwdText);
+        manager.add(followArrowFwdAction);
     }
 
     @Override
@@ -463,22 +474,34 @@ public class ControlFlowView extends AbstractTimeGraphView {
                     }
                     List<Integer> currentThreadQuarks = ssq.getQuarks(Attributes.CPUS, "*", Attributes.CURRENT_THREAD); //$NON-NLS-1$
                     for (int currentThreadQuark : currentThreadQuarks) {
-                        List<ITmfStateInterval> currentThreadIntervals = ssq.queryHistoryRange(currentThreadQuark, start, end, resolution, monitor);
+                        // adjust the query range to include the previous and following intervals
+                        long qstart = Math.max(ssq.querySingleState(start, currentThreadQuark).getStartTime() - 1, ssq.getStartTime());
+                        long qend = Math.min(ssq.querySingleState(end, currentThreadQuark).getEndTime() + 1, ssq.getCurrentEndTime());
+                        List<ITmfStateInterval> currentThreadIntervals = ssq.queryHistoryRange(currentThreadQuark, qstart, qend, resolution, monitor);
                         int prevThread = 0;
                         long prevEnd = 0;
+                        long lastEnd = 0;
                         for (ITmfStateInterval currentThreadInterval : currentThreadIntervals) {
                             if (monitor.isCanceled()) {
                                 return null;
                             }
                             long time = currentThreadInterval.getStartTime();
+                            if (time != lastEnd) {
+                                // don't create links where there are gaps in intervals due to the resolution
+                                prevThread = 0;
+                                prevEnd = 0;
+                            }
                             int thread = currentThreadInterval.getStateValue().unboxInt();
-                            if (thread > 0 && prevThread > 0 && thread != prevThread && time == prevEnd) {
+                            if (thread > 0 && prevThread > 0) {
                                 ITimeGraphEntry prevEntry = findEntry(entryList, trace, prevThread);
                                 ITimeGraphEntry nextEntry = findEntry(entryList, trace, thread);
-                                list.add(new TimeLinkEvent(prevEntry, nextEntry, time, 0, 0));
+                                list.add(new TimeLinkEvent(prevEntry, nextEntry, prevEnd, time - prevEnd, 0));
+                            }
+                            lastEnd = currentThreadInterval.getEndTime() + 1;
+                            if (thread != 0) {
+                                prevThread = thread;
+                                prevEnd = lastEnd;
                             }
-                            prevThread = thread;
-                            prevEnd = currentThreadInterval.getEndTime() + 1;
                         }
                     }
                 } catch (TimeRangeException e) {
index fa1b758e677091f11cf931b14bf8c985760a94c6..d4969cff96424bb0db4dd45e1a180d5ad2a4f94a 100644 (file)
@@ -1479,6 +1479,13 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
 
         int x0 = getXForTime(event.getTime());
         int x1 = getXForTime(event.getTime() + event.getDuration());
+
+        // limit the x-coordinates to prevent integer overflow in calculations
+        // and also GC.drawLine doesn't draw properly with large coordinates
+        final int limit = Integer.MAX_VALUE / 1024;
+        x0 = Math.max(-limit, Math.min(x0, limit));
+        x1 = Math.max(-limit, Math.min(x1, limit));
+
         int y0 = src.y + src.height / 2;
         int y1 = dst.y + dst.height / 2;
         drawArrow(getColorScheme(), event, new Rectangle(x0, y0, x1 - x0, y1 - y0), gc);
@@ -1540,8 +1547,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
         int factor = 10;
         double cos = 0.9510;
         double sin = 0.3090;
-        int lenx = x1 - x0;
-        int leny = y1 - y0;
+        long lenx = x1 - x0;
+        long leny = y1 - y0;
         double len = Math.sqrt(lenx * lenx + leny * leny);
 
         double dx = factor * lenx / len;
This page took 0.033509 seconds and 5 git commands to generate.