(CoroutineDebugger) Restored frame variables isn't shown for 2020.1.

#KT-40172 fixed
This commit is contained in:
Vladimir Ilmov
2020-07-09 20:23:55 +02:00
parent fbbf4e06ba
commit 3e69250f72
3 changed files with 24 additions and 8 deletions
@@ -51,7 +51,16 @@ class SuspendCoroutineStackFrameItem(
val stackTraceElement: StackTraceElement,
location: Location,
spilledVariables: List<XNamedValue> = emptyList()
) : CoroutineStackFrameItem(location, spilledVariables)
) : CoroutineStackFrameItem(location, spilledVariables) {
override fun createFrame(debugProcess: DebugProcessImpl): XStackFrame? {
return debugProcess.invokeInManagerThread {
val frame = debugProcess.findFirstFrame() ?: return@invokeInManagerThread null
val locationFrame = LocationStackFrameProxyImpl(location, frame)
val position = location.findPosition(debugProcess.project)
CoroutineStackFrame(locationFrame, position, spilledVariables, includeFrameVariables = false)
}
}
}
/**
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.idea.debugger.coroutine.proxy
import com.intellij.xdebugger.frame.XNamedValue
import com.sun.jdi.ObjectReference
import org.jetbrains.kotlin.idea.debugger.coroutine.data.CoroutineInfoData
import org.jetbrains.kotlin.idea.debugger.coroutine.data.CoroutineNameIdState
import org.jetbrains.kotlin.idea.debugger.coroutine.data.CreationCoroutineStackFrameItem
@@ -32,11 +33,7 @@ class CoroutineLibraryAgent2Proxy(private val executionContext: DefaultExecution
private fun mapToCoroutineInfoData(mirror: MirrorOfCoroutineInfo): CoroutineInfoData? {
val coroutineNameIdState = CoroutineNameIdState.instance(mirror)
val stackTrace = mirror.enhancedStackTrace?.mapNotNull { it.stackTraceElement() } ?: emptyList()
val variables: List<XNamedValue> = mirror.lastObservedFrame?.let {
val spilledVariables = debugMetadata?.baseContinuationImpl?.mirror(it, executionContext)
spilledVariables?.spilledValues(executionContext)
} ?: emptyList()
val stackFrames = findStackFrames(stackTrace, variables)
val stackFrames = findStackFrames(stackTrace, mirror.lastObservedFrame)
return CoroutineInfoData(
coroutineNameIdState,
stackFrames.restoredStackFrames,
@@ -57,14 +54,24 @@ class CoroutineLibraryAgent2Proxy(private val executionContext: DefaultExecution
private fun findStackFrames(
frames: List<StackTraceElement>,
variables: List<XNamedValue>
lastObservedFrame: ObjectReference?
): CoroutineStackFrames {
val index = frames.indexOfFirst { it.isCreationSeparatorFrame() }
val restoredStackTraceElements = if (index >= 0)
frames.take(index)
else
frames
var observedFrame = lastObservedFrame
val restoredStackFrames = restoredStackTraceElements.map {
val variables: List<XNamedValue> = observedFrame?.let {
val spilledVariables = debugMetadata?.baseContinuationImpl?.mirror(it, executionContext)
if (spilledVariables != null) {
observedFrame = spilledVariables.nextContinuation
spilledVariables.spilledValues(executionContext)
} else
null
} ?: emptyList()
SuspendCoroutineStackFrameItem(it, locationCache.createLocation(it), variables)
}
val creationStackFrames = frames.subList(index + 1, frames.size).mapIndexed { ix, it ->
@@ -141,7 +141,7 @@ class CoroutineInfo private constructor(
debugProbesImplMirror.enhanceStackTraceWithThreadDump(context, value, lastObservedStackTrace)
else emptyList()
val lastObservedThread = threadValue(value, lastObservedThreadField)
val lastObservedFrame = threadValue(value, lastObservedFrameField)
val lastObservedFrame = objectValue(value, lastObservedFrameField)
return MirrorOfCoroutineInfo(
value,
coroutineContext,