From c8c0f3383d7d3161ff3f44cac8cdb95fe949a365 Mon Sep 17 00:00:00 2001 From: Vladimir Ilmov Date: Mon, 13 Jan 2020 17:40:16 +0100 Subject: [PATCH] [debug] coroutine's stack frame locations pre-calculated on initialization --- .../coroutine/command/CoroutineBuilder.kt | 25 +++++-------------- .../debugger/coroutine/view/XCoroutineView.kt | 2 +- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/command/CoroutineBuilder.kt b/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/command/CoroutineBuilder.kt index 215afef3e60..ef33dca4491 100644 --- a/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/command/CoroutineBuilder.kt +++ b/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/command/CoroutineBuilder.kt @@ -200,10 +200,8 @@ class CreationCoroutineStackFrameItem( frame: StackFrameProxyImpl, val stackTraceElement: StackTraceElement, stackFrame: XStackFrame, - val location: Location -) : CoroutineStackFrameItem(frame, stackFrame) { - override fun location() = location - + location: Location +) : CoroutineStackFrameItem(frame, stackFrame, location) { fun emptyDescriptor() = EmptyStackFrameDescriptor(stackTraceElement, frame) } @@ -213,9 +211,7 @@ class SuspendCoroutineStackFrameItem( val stackTraceElement: StackTraceElement, stackFrame: XStackFrame, val lastObservedFrameFieldRef: ObjectReference -) : CoroutineStackFrameItem(frame, stackFrame) { - override fun location() = frame.location() - +) : CoroutineStackFrameItem(frame, stackFrame, frame.location()) { fun emptyDescriptor() = EmptyStackFrameDescriptor(stackTraceElement, frame) } @@ -224,28 +220,19 @@ class AsyncCoroutineStackFrameItem( frame: StackFrameProxyImpl, val frameItem: StackFrameItem, stackFrame: XStackFrame -) : CoroutineStackFrameItem(frame, stackFrame) { - override fun location() : Location = frame.location() -} +) : CoroutineStackFrameItem(frame, stackFrame, frame.location()) class RunningCoroutineStackFrameItem( frame: StackFrameProxyImpl, stackFrame: XStackFrame -) : CoroutineStackFrameItem(frame, stackFrame) { - val location = frame.location() // it should be invoked in manager thread +) : CoroutineStackFrameItem(frame, stackFrame, frame.location()) - override fun location() = location -} - -abstract class CoroutineStackFrameItem(val frame: StackFrameProxyImpl, val stackFrame: XStackFrame) { +abstract class CoroutineStackFrameItem(val frame: StackFrameProxyImpl, val stackFrame: XStackFrame, val location: Location) { val log by logger fun sourcePosition() : XSourcePosition? = stackFrame.sourcePosition - abstract fun location(): Location - fun uniqueId(): String { - val location = location() try { return location.safeSourceName() + ":" + location.safeMethod().toString() + ":" + location.safeLineNumber() + ":" + location.safeSourceLineNumber() diff --git a/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/view/XCoroutineView.kt b/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/view/XCoroutineView.kt index 7f44ba091d4..e3a0061cbbe 100644 --- a/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/view/XCoroutineView.kt +++ b/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/view/XCoroutineView.kt @@ -237,7 +237,7 @@ class XCoroutineView(val project: Project, val session: XDebugSession) : inner class CoroutineFrameValue(val frame: CoroutineStackFrameItem ) : XNamedValue(frame.uniqueId()) { override fun computePresentation(node: XValueNode, place: XValuePlace) = - applyRenderer(node, renderer.render(frame.location())) + applyRenderer(node, renderer.render(frame.location)) } private fun applyRenderer(node: XValueNode, presentation: SimpleColoredTextIcon) =