From e96fbf223b9f6ef87c392e004a808daa17a87845 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Sat, 5 Mar 2005 18:54:28 +0300 Subject: [PATCH] fix 44026 --- .../debugger/impl/DebuggerSession.java | 32 ++++++++++--------- .../jdi/ThreadReferenceProxyImpl.java | 19 ++++++++--- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/source/com/intellij/debugger/impl/DebuggerSession.java b/source/com/intellij/debugger/impl/DebuggerSession.java index 2a839763c1c0..27fcad2b7525 100644 --- a/source/com/intellij/debugger/impl/DebuggerSession.java +++ b/source/com/intellij/debugger/impl/DebuggerSession.java @@ -180,23 +180,25 @@ public class DebuggerSession { } } - while (!currentThread.isSuspended()) { - // wait until thread is considered suspended. Querying data from a thread immediately after VM.suspend() - // may result in IncompatibleThreadStateException, most likely some time after suspend() VM erroneously thinks that thread is still running - try { - Thread.sleep(10); + StackFrameProxyImpl proxy = null; + if (currentThread != null) { + while (!currentThread.isSuspended()) { + // wait until thread is considered suspended. Querying data from a thread immediately after VM.suspend() + // may result in IncompatibleThreadStateException, most likely some time after suspend() VM erroneously thinks that thread is still running + try { + Thread.sleep(10); + } + catch (InterruptedException e) { + } } - catch (InterruptedException e) { - } - } - StackFrameProxyImpl proxy; - try { - proxy = (currentThread.frameCount() > 0) ? currentThread.frame(0) : null; - } - catch (EvaluateException e) { - proxy = null; - LOG.error(e); + try { + proxy = (currentThread.frameCount() > 0) ? currentThread.frame(0) : null; + } + catch (EvaluateException e) { + proxy = null; + LOG.error(e); + } } positionContext = new SimpleStackFrameContext(proxy, debugProcess); } diff --git a/source/com/intellij/debugger/jdi/ThreadReferenceProxyImpl.java b/source/com/intellij/debugger/jdi/ThreadReferenceProxyImpl.java index 7107f1b1410f..19d05096bdb0 100644 --- a/source/com/intellij/debugger/jdi/ThreadReferenceProxyImpl.java +++ b/source/com/intellij/debugger/jdi/ThreadReferenceProxyImpl.java @@ -113,11 +113,20 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp DebuggerManagerThreadImpl.assertIsManagerThread(); checkValid(); if (myFrameCount == -1) { - try { - myFrameCount = getThreadReference().frameCount(); - } - catch (IncompatibleThreadStateException e) { - throw EvaluateExceptionUtil.createEvaluateException(e); + while (true) { + // JDI bug: although isSuspended() == true, frameCount() may throw IncompatibleTharedStateException + // so keep trying to get frame count if the thread reports itself as "suspended" + try { + final ThreadReference threadReference = getThreadReference(); + myFrameCount = threadReference.frameCount(); + break; + } + catch (IncompatibleThreadStateException e) { + if (!isSuspended()) { + // give up because it seems to be really resumed + throw EvaluateExceptionUtil.createEvaluateException(e); + } + } } } return myFrameCount;