(CoroutineDebugger) -core jar has precedence over -debug
#KT-39412 fixed #KT-39648 fixed
This commit is contained in:
+12
-10
@@ -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()
|
||||
|
||||
+9
-7
@@ -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
|
||||
|
||||
-1
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
+8
-2
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+1
-1
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user