diff --git a/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/FrameInfo.kt b/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/FrameInfo.kt index b6c4ccbc514..2a9c7cf823c 100644 --- a/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/FrameInfo.kt +++ b/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/FrameInfo.kt @@ -5,6 +5,8 @@ package org.jetbrains.kotlin.idea.debugger.evaluate +import com.intellij.debugger.jdi.LocalVariableProxyImpl +import com.intellij.debugger.jdi.StackFrameProxyImpl import com.intellij.openapi.project.Project import com.intellij.psi.CommonClassNames import com.intellij.psi.PsiElementFactory @@ -12,10 +14,11 @@ import com.intellij.psi.PsiNameHelper import com.intellij.psi.PsiType import com.intellij.psi.search.GlobalSearchScope import com.sun.jdi.* +import org.jetbrains.kotlin.idea.debugger.safeVisibleVariables import org.jetbrains.kotlin.idea.j2k.j2k import org.jetbrains.kotlin.psi.KtProperty -class FrameInfo private constructor(val project: Project, thisObject: Value?, variables: Map) { +class FrameInfo private constructor(val project: Project, thisObject: Value?, variables: Map) { val thisObject = run { if (thisObject == null) { return@run null @@ -29,12 +32,23 @@ class FrameInfo private constructor(val project: Project, thisObject: Value?, va companion object { private const val FAKE_JAVA_THIS_NAME = "\$this\$_java_locals_debug_fun_" - fun from(project: Project, frame: StackFrame?): FrameInfo { - if (frame == null) { + fun from(project: Project, frameProxy: StackFrameProxyImpl?): FrameInfo { + if (frameProxy == null) { return FrameInfo(project, null, emptyMap()) } - return FrameInfo(project, frame.thisObject(), frame.getValues(frame.visibleVariables())) + val variableValues = collectVariableValues(frameProxy) + return FrameInfo(project, frameProxy.thisObject(), variableValues) + } + + private fun collectVariableValues(frameProxy: StackFrameProxyImpl): Map { + val variables = frameProxy.safeVisibleVariables() + val values = HashMap(variables.size) + for (variable in variables) { + val value = frameProxy.getValue(variable) ?: continue + values[variable] = value + } + return values } private fun createKotlinProperty(project: Project, name: String, typeName: String, value: Value?): KtProperty? { diff --git a/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt b/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt index e245d62a797..c3cc9e50c95 100644 --- a/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt +++ b/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt @@ -168,15 +168,15 @@ class KotlinCodeFragmentFactory : CodeFragmentFactory() { val worker = object : DebuggerCommandImpl() { override fun action() { try { - val frame = hopelessAware { + val frameProxy = hopelessAware { if (ApplicationManager.getApplication().isUnitTestMode) { - contextElement?.getCopyableUserData(DEBUG_CONTEXT_FOR_TESTS)?.frameProxy?.stackFrame + contextElement?.getCopyableUserData(DEBUG_CONTEXT_FOR_TESTS)?.frameProxy } else { - debuggerContext.frameProxy?.stackFrame + debuggerContext.frameProxy } } - frameInfo = FrameInfo.from(debuggerContext.project, frame) + frameInfo = FrameInfo.from(debuggerContext.project, frameProxy) } catch (ignored: AbsentInformationException) { // Debug info unavailable } catch (ignored: InvalidStackFrameException) {