Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimeon Andreev2018-11-23 08:00:27 -0500
committerSimeon Andreev2018-12-12 11:56:20 -0500
commit0555524f178d8d99996d2b5c5d362ef47dcc1306 (patch)
tree893e9326b183db759d3a9fc7a30560258db22d1d /org.eclipse.debug.ui/ui
parentedeebcfcedfbd001e65c989f24512a419a823a38 (diff)
downloadeclipse.platform.debug-0555524f178d8d99996d2b5c5d362ef47dcc1306.tar.gz
eclipse.platform.debug-0555524f178d8d99996d2b5c5d362ef47dcc1306.tar.xz
eclipse.platform.debug-0555524f178d8d99996d2b5c5d362ef47dcc1306.zip
Bug 540243 - Bad selection when opening Debug View on breakpointY20181212-2200I20181212-1800
When the Debug View is not open and a breakpoint is hit, a preference dictates whether the Debug View is opened. If this preference is used, it is possible to observe a bad selection in the Debug View. E.g. a thread is selected and not a stack frame, or a stack frame and a thread are selected. The problem is seen for Java debug targets, when owned monitors are displayed in the Debug View. When the Debug View debug target element is created, DebugTargetProxy.doInstalled() is called. This will retrieve the first suspended thread and expand it, if such a thread is available. The expand delta contains also the top stack frame at which the thread is suspended. This stack frame is added to the delta with index 0. Unfortunately, owned monitors are displayed before stack frames in the list of thread children. So as soon as the children of the thread are updated for the tree view, a thread owned monitor will replace the selected stack frame. This results in an invalid selection handling, which in turn breaks the selection. This change allows classes which extend DebugTargetProxy to override computation of indices for the launch, debug target and suspended stack frame. A follow-up change in JDT debug will ensure the correct index is computed for the suspended stack frame, one which takes the thread owned monitors into account. Change-Id: Ic8ca2f06a7ea9e47c0322e5d3a62775a0c816652 Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
Diffstat (limited to 'org.eclipse.debug.ui/ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugTargetProxy.java52
1 files changed, 45 insertions, 7 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugTargetProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugTargetProxy.java
index cb71acf5a..e97ef177f 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugTargetProxy.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DebugTargetProxy.java
@@ -88,8 +88,8 @@ public class DebugTargetProxy extends EventHandlerModelProxy {
try {
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunch launch = target.getLaunch();
- int launchIndex = indexOf(manager.getLaunches(), target.getLaunch());
- int targetIndex = indexOf(target.getLaunch().getChildren(), target);
+ int launchIndex = getLaunchIndex(launch);
+ int targetIndex = getTargetIndex(target);
delta = new ModelDelta(manager, IModelDelta.NO_CHANGE);
ModelDelta node = delta.addNode(launch, launchIndex, IModelDelta.NO_CHANGE, target.getLaunch().getChildren().length);
node = node.addNode(target, targetIndex, IModelDelta.EXPAND | IModelDelta.SELECT, target.getThreads().length);
@@ -108,10 +108,6 @@ public class DebugTargetProxy extends EventHandlerModelProxy {
if (target != null) {
try {
IThread[] threads = target.getThreads();
- ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
- ILaunch launch = target.getLaunch();
- int launchIndex = indexOf(manager.getLaunches(), target.getLaunch());
- int targetIndex = indexOf(target.getLaunch().getChildren(), target);
IThread chosen = null;
int threadIndex = -1;
// select the first thread with a breakpoint, or the first suspended thread
@@ -140,11 +136,16 @@ public class DebugTargetProxy extends EventHandlerModelProxy {
if (chosen != null) {
IStackFrame frame = chosen.getTopStackFrame();
if (frame != null) {
+ ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunch launch = target.getLaunch();
+ int launchIndex = getLaunchIndex(launch);
+ int targetIndex = getTargetIndex(target);
+ int stackFrameIndex = getStackFrameIndex(frame);
ModelDelta delta = new ModelDelta(manager, IModelDelta.NO_CHANGE);
ModelDelta node = delta.addNode(launch, launchIndex, IModelDelta.NO_CHANGE, target.getLaunch().getChildren().length);
node = node.addNode(target, targetIndex, IModelDelta.NO_CHANGE, threads.length);
node = node.addNode(chosen, threadIndex, IModelDelta.NO_CHANGE | IModelDelta.EXPAND, chosen.getStackFrames().length);
- node = node.addNode(frame, 0, IModelDelta.NO_CHANGE | IModelDelta.SELECT, 0);
+ node = node.addNode(frame, stackFrameIndex, IModelDelta.NO_CHANGE | IModelDelta.SELECT, 0);
return delta;
}
}
@@ -154,4 +155,41 @@ public class DebugTargetProxy extends EventHandlerModelProxy {
return null;
}
+ /**
+ * Computes the index of a launch at top level in the {@code Debug View} tree.
+ *
+ * @param launch The launch for which to compute the index.
+ *
+ * @return The index of the specified launch at top level in the
+ * {@code Debug View}.
+ */
+ protected int getLaunchIndex(ILaunch launch) {
+ ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+ return indexOf(manager.getLaunches(), launch);
+ }
+
+ /**
+ * Computes the index of a debug target in its parent launch. The debug target
+ * index corresponds to the index in {@code Debug View} tree.
+ *
+ * @param target The debug target for which to compute the index.
+ *
+ * @return The index of the specified debug target in its launch.
+ */
+ protected int getTargetIndex(IDebugTarget target) {
+ return indexOf(target.getLaunch().getChildren(), target);
+ }
+
+ /**
+ * Computes the index of a stack frame in the thread suspended at that stack
+ * frame. The stack frame index corresponds to the index in {@code Debug View}
+ * tree.
+ *
+ * @param stackFrame The stack frame for which to compute the index.
+ *
+ * @return The index of the specified stack frame in its parent thread.
+ */
+ protected int getStackFrameIndex(IStackFrame stackFrame) {
+ return 0;
+ }
}

Back to the top