From ba686c701e0aefb69faf4021f10f480218c91bb6 Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Tue, 1 Sep 2015 13:27:33 +0300 Subject: [PATCH] Debugger for inline functions: check for available strata (faster than compute source position) --- .../debugger/stepping/KotlinSteppingCommandProvider.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt index 1aac527c32d..1b2766a0180 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt @@ -44,6 +44,8 @@ public class KotlinSteppingCommandProvider: JvmSteppingCommandProvider() { ): DebugProcessImpl.ResumeCommand? { if (suspendContext == null) return null + if (!isKotlinStrataPresent(suspendContext)) return null + val result: Pair>? = computeInManagerThread(suspendContext) { val sp = runReadAction { ContextUtil.getSourcePosition(it) } ?: return@computeInManagerThread null val cl = it.debugProcess.positionManager.getAllClasses(sp) @@ -78,6 +80,11 @@ public class KotlinSteppingCommandProvider: JvmSteppingCommandProvider() { return null } + private fun isKotlinStrataPresent(suspendContext: SuspendContextImpl): Boolean { + val availableStrata = suspendContext.frameProxy?.location()?.declaringType()?.availableStrata() ?: return false + return availableStrata.contains("Kotlin") + } + private fun computeInManagerThread(suspendContext: SuspendContextImpl, action: (SuspendContextImpl) -> T?): T? { val semaphore = Semaphore() semaphore.down()