Remove isAtBreakpoint checks as it's not valid in all cases

For example, when we stopped at a breakpoint and then did a 'step over' action, we aren't at that breakpoint any more.
However, we still can evaluate things.
This commit is contained in:
Yan Zhulanow
2019-03-13 22:03:09 +03:00
parent bbdeb3efac
commit 90e84aa15d
4 changed files with 13 additions and 4 deletions
@@ -43,9 +43,11 @@ class KotlinCoroutinesAsyncStackTraceProvider : KotlinCoroutinesAsyncStackTraceP
if (!location.isInKotlinSources()) {
return null
}
val method = location.safeMethod() ?: return null
val currentThread = frameProxy.threadProxy().threadReference
if (currentThread == null || !currentThread.isSuspended || !currentThread.isAtBreakpoint) {
val threadReference = frameProxy.threadProxy().threadReference
if (threadReference == null || !threadReference.isSuspended || !suspendContext.debugProcess.canRunEvaluation) {
return null
}
@@ -276,3 +276,9 @@ fun Type.isSubtype(type: AsmType): Boolean {
return false
}
val DebuggerContextImpl.canRunEvaluation: Boolean
get() = debugProcess?.canRunEvaluation ?: false
val DebugProcessImpl.canRunEvaluation: Boolean
get() = suspendManager.pausedContext != null
@@ -315,7 +315,7 @@ class KotlinEvaluator(val codeFragment: KtCodeFragment, val sourcePosition: Sour
return runEvaluation(context, compiledData, classLoader ?: context.evaluationContext.classLoader) { args ->
val vm = context.vm.virtualMachine
val thread = context.suspendContext.thread?.threadReference?.takeIf { it.isAtBreakpoint }
val thread = context.suspendContext.thread?.threadReference?.takeIf { it.isSuspended }
?: error("Can not find a thread to run evaluation on")
val eval = JDIEval(vm, classLoader, thread, context.invokePolicy)
@@ -33,6 +33,7 @@ import com.sun.jdi.*
import com.sun.jdi.Type
import org.jetbrains.kotlin.idea.debugger.KotlinDebuggerSettings
import org.jetbrains.kotlin.idea.debugger.ToggleKotlinVariablesState
import org.jetbrains.kotlin.idea.debugger.canRunEvaluation
import org.jetbrains.kotlin.load.java.JvmAbi
import java.util.*
import com.sun.jdi.Type as JdiType
@@ -80,7 +81,7 @@ class KotlinClassWithDelegatedPropertyRenderer(private val rendererSettings: Nod
listener: DescriptorLabelListener
): String? {
val toStringRenderer = rendererSettings.toStringRenderer
if (toStringRenderer.isEnabled && DebuggerManagerEx.getInstanceEx(evaluationContext.project).context.isEvaluationPossible) {
if (toStringRenderer.isEnabled && DebuggerManagerEx.getInstanceEx(evaluationContext.project).context.canRunEvaluation) {
if (toStringRenderer.isApplicable(descriptor.type)) {
return toStringRenderer.calcLabel(descriptor, evaluationContext, listener)
}