(CoroutineDebugger) Restored frame variables isn't shown for 2020.1.
#KT-40172 fixed
This commit is contained in:
+10
-1
@@ -51,7 +51,16 @@ class SuspendCoroutineStackFrameItem(
|
|||||||
val stackTraceElement: StackTraceElement,
|
val stackTraceElement: StackTraceElement,
|
||||||
location: Location,
|
location: Location,
|
||||||
spilledVariables: List<XNamedValue> = emptyList()
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+13
-6
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.idea.debugger.coroutine.proxy
|
package org.jetbrains.kotlin.idea.debugger.coroutine.proxy
|
||||||
|
|
||||||
import com.intellij.xdebugger.frame.XNamedValue
|
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.CoroutineInfoData
|
||||||
import org.jetbrains.kotlin.idea.debugger.coroutine.data.CoroutineNameIdState
|
import org.jetbrains.kotlin.idea.debugger.coroutine.data.CoroutineNameIdState
|
||||||
import org.jetbrains.kotlin.idea.debugger.coroutine.data.CreationCoroutineStackFrameItem
|
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? {
|
private fun mapToCoroutineInfoData(mirror: MirrorOfCoroutineInfo): CoroutineInfoData? {
|
||||||
val coroutineNameIdState = CoroutineNameIdState.instance(mirror)
|
val coroutineNameIdState = CoroutineNameIdState.instance(mirror)
|
||||||
val stackTrace = mirror.enhancedStackTrace?.mapNotNull { it.stackTraceElement() } ?: emptyList()
|
val stackTrace = mirror.enhancedStackTrace?.mapNotNull { it.stackTraceElement() } ?: emptyList()
|
||||||
val variables: List<XNamedValue> = mirror.lastObservedFrame?.let {
|
val stackFrames = findStackFrames(stackTrace, mirror.lastObservedFrame)
|
||||||
val spilledVariables = debugMetadata?.baseContinuationImpl?.mirror(it, executionContext)
|
|
||||||
spilledVariables?.spilledValues(executionContext)
|
|
||||||
} ?: emptyList()
|
|
||||||
val stackFrames = findStackFrames(stackTrace, variables)
|
|
||||||
return CoroutineInfoData(
|
return CoroutineInfoData(
|
||||||
coroutineNameIdState,
|
coroutineNameIdState,
|
||||||
stackFrames.restoredStackFrames,
|
stackFrames.restoredStackFrames,
|
||||||
@@ -57,14 +54,24 @@ class CoroutineLibraryAgent2Proxy(private val executionContext: DefaultExecution
|
|||||||
|
|
||||||
private fun findStackFrames(
|
private fun findStackFrames(
|
||||||
frames: List<StackTraceElement>,
|
frames: List<StackTraceElement>,
|
||||||
variables: List<XNamedValue>
|
lastObservedFrame: ObjectReference?
|
||||||
): CoroutineStackFrames {
|
): CoroutineStackFrames {
|
||||||
val index = frames.indexOfFirst { it.isCreationSeparatorFrame() }
|
val index = frames.indexOfFirst { it.isCreationSeparatorFrame() }
|
||||||
val restoredStackTraceElements = if (index >= 0)
|
val restoredStackTraceElements = if (index >= 0)
|
||||||
frames.take(index)
|
frames.take(index)
|
||||||
else
|
else
|
||||||
frames
|
frames
|
||||||
|
|
||||||
|
var observedFrame = lastObservedFrame
|
||||||
val restoredStackFrames = restoredStackTraceElements.map {
|
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)
|
SuspendCoroutineStackFrameItem(it, locationCache.createLocation(it), variables)
|
||||||
}
|
}
|
||||||
val creationStackFrames = frames.subList(index + 1, frames.size).mapIndexed { ix, it ->
|
val creationStackFrames = frames.subList(index + 1, frames.size).mapIndexed { ix, it ->
|
||||||
|
|||||||
+1
-1
@@ -141,7 +141,7 @@ class CoroutineInfo private constructor(
|
|||||||
debugProbesImplMirror.enhanceStackTraceWithThreadDump(context, value, lastObservedStackTrace)
|
debugProbesImplMirror.enhanceStackTraceWithThreadDump(context, value, lastObservedStackTrace)
|
||||||
else emptyList()
|
else emptyList()
|
||||||
val lastObservedThread = threadValue(value, lastObservedThreadField)
|
val lastObservedThread = threadValue(value, lastObservedThreadField)
|
||||||
val lastObservedFrame = threadValue(value, lastObservedFrameField)
|
val lastObservedFrame = objectValue(value, lastObservedFrameField)
|
||||||
return MirrorOfCoroutineInfo(
|
return MirrorOfCoroutineInfo(
|
||||||
value,
|
value,
|
||||||
coroutineContext,
|
coroutineContext,
|
||||||
|
|||||||
Reference in New Issue
Block a user