fix 44026

This commit is contained in:
Eugene Zhuravlev
2005-03-05 18:54:28 +03:00
parent e935b1d985
commit e96fbf223b
2 changed files with 31 additions and 20 deletions
@@ -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);
}
@@ -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;