Bug 540243 - Bad selection when opening Debug View on breakpoint

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 ensures JavaDebugTargetProxy.getNextSuspendedThreadDelta()
also handles existing monitors for the thread. The top suspended stack
frame now has index that is greater than 0, if the thread owns monitors.

Change-Id: I27be0857844e8faa98f21714512534cc963d5e0b
Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
5 files changed