do not postpone commands for dead threads

This commit is contained in:
Egor Ushakov
2018-04-03 19:54:36 +03:00
parent d47649085d
commit ac39226cff
3 changed files with 15 additions and 7 deletions
@@ -8,6 +8,7 @@ import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.sun.jdi.ObjectCollectedException;
import com.sun.jdi.ThreadReference;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -53,9 +54,10 @@ public abstract class DebuggerContextCommandImpl extends SuspendContextCommandIm
@Override
public final void contextAction(@NotNull SuspendContextImpl suspendContext) {
SuspendManager suspendManager = myDebuggerContext.getDebugProcess().getSuspendManager();
ThreadReferenceProxyImpl thread = getThread();
boolean isSuspendedByContext;
try {
isSuspendedByContext = suspendManager.isSuspended(getThread());
isSuspendedByContext = suspendManager.isSuspended(thread);
}
catch (ObjectCollectedException ignored) {
notifyCancelled();
@@ -64,15 +66,15 @@ public abstract class DebuggerContextCommandImpl extends SuspendContextCommandIm
if (isSuspendedByContext) {
if (LOG.isDebugEnabled()) {
LOG.debug("Context thread " + suspendContext.getThread());
LOG.debug("Debug thread" + getThread());
LOG.debug("Debug thread" + thread);
}
threadAction(suspendContext);
}
else {
// no suspend context currently available
SuspendContextImpl suspendContextForThread = myCustomThread != null ? suspendContext :
SuspendManagerUtil.findContextByThread(suspendManager, getThread());
if (suspendContextForThread != null) {
SuspendManagerUtil.findContextByThread(suspendManager, thread);
if (suspendContextForThread != null && thread.status() != ThreadReference.THREAD_STATUS_ZOMBIE) {
suspendContextForThread.postponeCommand(this);
}
else {
@@ -1,6 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
/*
* @author Eugene Zhuravlev
@@ -18,6 +16,7 @@ import com.intellij.openapi.util.Comparing;
import com.intellij.util.ThreeState;
import com.intellij.util.containers.ContainerUtil;
import com.sun.jdi.*;
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -133,6 +132,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
super.clearCaches();
}
@MagicConstant(valuesFromClass = ThreadReference.class)
public int status() {
try {
return getThreadReference().status();
@@ -18,4 +18,10 @@
name='com.sun.jdi.StackFrame java.util.Map<com.sun.jdi.LocalVariable,com.sun.jdi.Value> getValues(java.util.List<? extends com.sun.jdi.LocalVariable>)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.sun.jdi.ThreadReference int status()'>
<annotation name="org.intellij.lang.annotations.MagicConstant">
<val name="valuesFromClass" val="com.sun.jdi.ThreadReference.class" />
</annotation>
</item>
</root>