(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 ->
|
gradle.taskGraph.beforeTask { Task task ->
|
||||||
if (task instanceof Test) {
|
if (task instanceof Test) {
|
||||||
def kotlinxCoroutinesDebugJar = task.classpath.find { it.name.startsWith("kotlinx-coroutines-debug") }
|
def kotlinxCoroutinesDebugJar = task.classpath.find { it.name.startsWith("kotlinx-coroutines-debug") }
|
||||||
if (kotlinxCoroutinesDebugJar)
|
def kotlinxCoroutinesCoreJar = task.classpath.find { it.name.startsWith("kotlinx-coroutines-core") }
|
||||||
task.jvmArgs ("-javaagent:${'$'}{kotlinxCoroutinesDebugJar?.absolutePath}", "-ea")
|
if (kotlinxCoroutinesCoreJar) {
|
||||||
else {
|
def results = (kotlinxCoroutinesCoreJar.getName() =~ /kotlinx-coroutines-core\-([\d\.]+)\.jar${'$'}/).findAll()
|
||||||
for (lib in task.getClasspath()) {
|
if (results) {
|
||||||
def results = (lib.getName() =~ /kotlinx-coroutines-core\-([\d\.]+)\.jar${'$'}/).findAll()
|
def version = results.first()[1]
|
||||||
if (results) {
|
if (org.gradle.util.VersionNumber.parse( version ) >= org.gradle.util.VersionNumber.parse('1.3.6')) {
|
||||||
def version = results.first()[1]
|
task.jvmArgs ("-javaagent:${'$'}{kotlinxCoroutinesCoreJar?.absolutePath}", "-ea")
|
||||||
if (org.gradle.util.VersionNumber.parse( version ) >= org.gradle.util.VersionNumber.parse( '1.3.6' )) {
|
return
|
||||||
task.jvmArgs ("-javaagent:${'$'}{lib?.absolutePath}", "-ea")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (kotlinxCoroutinesDebugJar) {
|
||||||
|
task.jvmArgs ("-javaagent:${'$'}{kotlinxCoroutinesDebugJar?.absolutePath}", "-ea")
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|||||||
+9
-7
@@ -47,12 +47,14 @@ class DebuggerConnection(
|
|||||||
val kotlinxCoroutinesDebug = params.classPath?.pathList?.firstOrNull { it.contains("kotlinx-coroutines-debug") }
|
val kotlinxCoroutinesDebug = params.classPath?.pathList?.firstOrNull { it.contains("kotlinx-coroutines-debug") }
|
||||||
|
|
||||||
val mode = when {
|
val mode = when {
|
||||||
kotlinxCoroutinesDebug != null -> {
|
|
||||||
CoroutineDebuggerMode.VERSION_UP_TO_1_3_5
|
|
||||||
}
|
|
||||||
kotlinxCoroutinesCore != null -> {
|
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
|
else -> CoroutineDebuggerMode.DISABLED
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,10 +70,10 @@ class DebuggerConnection(
|
|||||||
private fun determineCoreVersionMode(kotlinxCoroutinesCore: String): CoroutineDebuggerMode {
|
private fun determineCoreVersionMode(kotlinxCoroutinesCore: String): CoroutineDebuggerMode {
|
||||||
val regex = Regex(""".+\Wkotlinx-coroutines-core-(.+)?\.jar""")
|
val regex = Regex(""".+\Wkotlinx-coroutines-core-(.+)?\.jar""")
|
||||||
val matchResult = regex.matchEntire(kotlinxCoroutinesCore) ?: return CoroutineDebuggerMode.DISABLED
|
val matchResult = regex.matchEntire(kotlinxCoroutinesCore) ?: return CoroutineDebuggerMode.DISABLED
|
||||||
|
val versionToCompareTo = DefaultArtifactVersion("1.3.5-255")
|
||||||
|
|
||||||
val coroutinesCoreVersion = DefaultArtifactVersion(matchResult.groupValues[1])
|
val artifactVersion = DefaultArtifactVersion(matchResult.groupValues[1])
|
||||||
val versionToCompareTo = DefaultArtifactVersion("1.3.5")
|
return if (artifactVersion >= versionToCompareTo)
|
||||||
return if (versionToCompareTo < coroutinesCoreVersion)
|
|
||||||
CoroutineDebuggerMode.VERSION_1_3_6_AND_UP
|
CoroutineDebuggerMode.VERSION_1_3_6_AND_UP
|
||||||
else
|
else
|
||||||
CoroutineDebuggerMode.DISABLED
|
CoroutineDebuggerMode.DISABLED
|
||||||
|
|||||||
-1
@@ -55,7 +55,6 @@ class ContinuationHolder private constructor(val context: DefaultExecutionContex
|
|||||||
}
|
}
|
||||||
CoroutineNameIdState.instance(ci)
|
CoroutineNameIdState.instance(ci)
|
||||||
} else {
|
} else {
|
||||||
CoroutineInfoData.log.warn("Coroutine agent information not found.")
|
|
||||||
CoroutineNameIdState(CoroutineInfoData.DEFAULT_COROUTINE_NAME, "-1", State.UNKNOWN, null)
|
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.Location
|
||||||
import com.sun.jdi.ReferenceType
|
import com.sun.jdi.ReferenceType
|
||||||
import org.jetbrains.kotlin.idea.debugger.evaluate.DefaultExecutionContext
|
import org.jetbrains.kotlin.idea.debugger.evaluate.DefaultExecutionContext
|
||||||
|
import org.jetbrains.kotlin.utils.checkWithAttachment
|
||||||
|
|
||||||
class LocationCache(val context: DefaultExecutionContext) {
|
class LocationCache(val context: DefaultExecutionContext) {
|
||||||
private val classesByName = ClassesByNameProvider.createCache(context.vm.allClasses())
|
private val classesByName = ClassesByNameProvider.createCache(context.vm.allClasses())
|
||||||
@@ -39,8 +40,13 @@ class LocationCache(val context: DefaultExecutionContext) {
|
|||||||
} catch (ignored: AbsentInformationException) {
|
} 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)
|
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"
|
private const val AGENT_135_AND_UP_CLASS_NAME = "kotlinx.coroutines.debug.internal.DebugCoroutineInfo"
|
||||||
|
|
||||||
fun instance(debugProbesImplMirror: DebugProbesImpl, context: DefaultExecutionContext): CoroutineInfo? {
|
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 {
|
return try {
|
||||||
CoroutineInfo(debugProbesImplMirror, context, classType.name())
|
CoroutineInfo(debugProbesImplMirror, context, classType.name())
|
||||||
} catch (e: IllegalStateException) {
|
} catch (e: IllegalStateException) {
|
||||||
|
|||||||
Reference in New Issue
Block a user