diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleCoroutineDebugProjectResolver.kt b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleCoroutineDebugProjectResolver.kt index 039ecd86cd2..f7159de4903 100644 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleCoroutineDebugProjectResolver.kt +++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleCoroutineDebugProjectResolver.kt @@ -30,19 +30,21 @@ class KotlinGradleCoroutineDebugProjectResolver : AbstractProjectResolverExtensi gradle.taskGraph.beforeTask { Task task -> if (task instanceof Test) { def kotlinxCoroutinesDebugJar = task.classpath.find { it.name.startsWith("kotlinx-coroutines-debug") } - if (kotlinxCoroutinesDebugJar) - task.jvmArgs ("-javaagent:${'$'}{kotlinxCoroutinesDebugJar?.absolutePath}", "-ea") - else { - for (lib in task.getClasspath()) { - def results = (lib.getName() =~ /kotlinx-coroutines-core\-([\d\.]+)\.jar${'$'}/).findAll() - if (results) { - def version = results.first()[1] - if (org.gradle.util.VersionNumber.parse( version ) >= org.gradle.util.VersionNumber.parse( '1.3.6' )) { - task.jvmArgs ("-javaagent:${'$'}{lib?.absolutePath}", "-ea") - } + def kotlinxCoroutinesCoreJar = task.classpath.find { it.name.startsWith("kotlinx-coroutines-core") } + if (kotlinxCoroutinesCoreJar) { + def results = (kotlinxCoroutinesCoreJar.getName() =~ /kotlinx-coroutines-core\-([\d\.]+)\.jar${'$'}/).findAll() + if (results) { + def version = results.first()[1] + if (org.gradle.util.VersionNumber.parse( version ) >= org.gradle.util.VersionNumber.parse('1.3.6')) { + task.jvmArgs ("-javaagent:${'$'}{kotlinxCoroutinesCoreJar?.absolutePath}", "-ea") + return } } } + if (kotlinxCoroutinesDebugJar) { + task.jvmArgs ("-javaagent:${'$'}{kotlinxCoroutinesDebugJar?.absolutePath}", "-ea") + return + } } } """.trimIndent() diff --git a/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/DebuggerConnection.kt b/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/DebuggerConnection.kt index 7766e1117cb..7371dc23776 100644 --- a/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/DebuggerConnection.kt +++ b/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/DebuggerConnection.kt @@ -47,12 +47,14 @@ class DebuggerConnection( val kotlinxCoroutinesDebug = params.classPath?.pathList?.firstOrNull { it.contains("kotlinx-coroutines-debug") } val mode = when { - kotlinxCoroutinesDebug != null -> { - CoroutineDebuggerMode.VERSION_UP_TO_1_3_5 - } kotlinxCoroutinesCore != null -> { - determineCoreVersionMode(kotlinxCoroutinesCore) + val coreVersion = determineCoreVersionMode(kotlinxCoroutinesCore) + if (coreVersion == CoroutineDebuggerMode.DISABLED && kotlinxCoroutinesDebug != null) + CoroutineDebuggerMode.VERSION_UP_TO_1_3_5 + else + CoroutineDebuggerMode.DISABLED } + kotlinxCoroutinesDebug != null -> CoroutineDebuggerMode.VERSION_UP_TO_1_3_5 else -> CoroutineDebuggerMode.DISABLED } @@ -68,10 +70,10 @@ class DebuggerConnection( private fun determineCoreVersionMode(kotlinxCoroutinesCore: String): CoroutineDebuggerMode { val regex = Regex(""".+\Wkotlinx-coroutines-core-(.+)?\.jar""") val matchResult = regex.matchEntire(kotlinxCoroutinesCore) ?: return CoroutineDebuggerMode.DISABLED + val versionToCompareTo = DefaultArtifactVersion("1.3.5-255") - val coroutinesCoreVersion = DefaultArtifactVersion(matchResult.groupValues[1]) - val versionToCompareTo = DefaultArtifactVersion("1.3.5") - return if (versionToCompareTo < coroutinesCoreVersion) + val artifactVersion = DefaultArtifactVersion(matchResult.groupValues[1]) + return if (artifactVersion >= versionToCompareTo) CoroutineDebuggerMode.VERSION_1_3_6_AND_UP else CoroutineDebuggerMode.DISABLED diff --git a/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/proxy/ContinuationHolder.kt b/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/proxy/ContinuationHolder.kt index 3d76a7561ef..95f5bd61ebe 100644 --- a/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/proxy/ContinuationHolder.kt +++ b/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/proxy/ContinuationHolder.kt @@ -55,7 +55,6 @@ class ContinuationHolder private constructor(val context: DefaultExecutionContex } CoroutineNameIdState.instance(ci) } else { - CoroutineInfoData.log.warn("Coroutine agent information not found.") CoroutineNameIdState(CoroutineInfoData.DEFAULT_COROUTINE_NAME, "-1", State.UNKNOWN, null) } } diff --git a/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/proxy/LocationCache.kt b/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/proxy/LocationCache.kt index 9ec1df0bfef..b2dcfb17a52 100644 --- a/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/proxy/LocationCache.kt +++ b/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/proxy/LocationCache.kt @@ -13,6 +13,7 @@ import com.sun.jdi.AbsentInformationException import com.sun.jdi.Location import com.sun.jdi.ReferenceType import org.jetbrains.kotlin.idea.debugger.evaluate.DefaultExecutionContext +import org.jetbrains.kotlin.utils.checkWithAttachment class LocationCache(val context: DefaultExecutionContext) { private val classesByName = ClassesByNameProvider.createCache(context.vm.allClasses()) @@ -39,8 +40,13 @@ class LocationCache(val context: DefaultExecutionContext) { } catch (ignored: AbsentInformationException) { } } + checkWithAttachment(type != null, { + "Bad type: $type" + }) { + it.withAttachment("type", type) + it.withAttachment("methodName", methodName) + it.withAttachment("line", line) + } return GeneratedLocation(context.debugProcess, type, methodName, line) } - - } \ No newline at end of file diff --git a/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/proxy/mirror/coroutinesDebugMirror.kt b/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/proxy/mirror/coroutinesDebugMirror.kt index 87cf1afaea7..b2176ec315e 100644 --- a/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/proxy/mirror/coroutinesDebugMirror.kt +++ b/idea/jvm-debugger/jvm-debugger-coroutine/src/org/jetbrains/kotlin/idea/debugger/coroutine/proxy/mirror/coroutinesDebugMirror.kt @@ -112,7 +112,7 @@ class CoroutineInfo private constructor( private const val AGENT_135_AND_UP_CLASS_NAME = "kotlinx.coroutines.debug.internal.DebugCoroutineInfo" fun instance(debugProbesImplMirror: DebugProbesImpl, context: DefaultExecutionContext): CoroutineInfo? { - val classType = context.findClassSafe(AGENT_134_CLASS_NAME) ?: context.findClassSafe(AGENT_135_AND_UP_CLASS_NAME) ?: return null + val classType = context.findClassSafe(AGENT_135_AND_UP_CLASS_NAME) ?: context.findClassSafe(AGENT_134_CLASS_NAME) ?: return null return try { CoroutineInfo(debugProbesImplMirror, context, classType.name()) } catch (e: IllegalStateException) {