Bug 537903 - Wrong Debug View due to evaluation on debug context change

Whenever an evaluation runs during thread suspend handling, its possible
to create a delta which selects the suspended thread but not its first
stack frame. This results due to very specific interleaving of thread
running state and code in
ThreadEventHandler.fireDeltaUpdatingSelectedFrame().

An evaluation can e.g. be triggered by a job in client code, either with
IJavaThread.runEvaluation() or with IJavaObject.sendMessage() methods.
No synchronization is possible between those methods and the suspend
handling, since such synchronization can block debug event processing
and so potentially lead to deadlocks.

This change attempts to salvage the situation, after the bad case is
encountered. If no top stack frame could be retrieved by
ThreadEventHandler.fireDeltaUpdatingSelectedFrame(), but the thread is
in suspended state, we query the top stack frame again. In case one
evaluation ran in parallel with the suspend handling, at this point we
know for sure that the evaluation is done and so the top stack frame is
accessible.

This change does not help in case client code bombards the thread with
evaluations. It also does not help in case an evaluation ran throughout
the entire thread suspend handling.

Change-Id: I34252c0dac3d031bbbefc3a1328175cab0793ae5
Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
1 file changed