(CoroutineDebugger) kotlinx-coroutines-core:1.3.5 support
This commit is contained in:
@@ -5,6 +5,7 @@ plugins {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":idea:jvm-debugger:jvm-debugger-core"))
|
implementation(project(":idea:jvm-debugger:jvm-debugger-core"))
|
||||||
|
implementation("org.apache.maven:maven-artifact:3.6.3")
|
||||||
|
|
||||||
compileOnly(toolsJarApi())
|
compileOnly(toolsJarApi())
|
||||||
compileOnly(intellijDep())
|
compileOnly(intellijDep())
|
||||||
|
|||||||
+34
-7
@@ -26,6 +26,7 @@ import com.intellij.xdebugger.XDebugSession
|
|||||||
import com.intellij.xdebugger.XDebuggerManager
|
import com.intellij.xdebugger.XDebuggerManager
|
||||||
import com.intellij.xdebugger.XDebuggerManagerListener
|
import com.intellij.xdebugger.XDebuggerManagerListener
|
||||||
import com.intellij.xdebugger.impl.XDebugSessionImpl
|
import com.intellij.xdebugger.impl.XDebugSessionImpl
|
||||||
|
import org.apache.maven.artifact.versioning.DefaultArtifactVersion
|
||||||
import org.jetbrains.kotlin.idea.debugger.coroutine.proxy.ManagerThreadExecutor
|
import org.jetbrains.kotlin.idea.debugger.coroutine.proxy.ManagerThreadExecutor
|
||||||
import org.jetbrains.kotlin.idea.debugger.coroutine.util.CreateContentParamsProvider
|
import org.jetbrains.kotlin.idea.debugger.coroutine.util.CreateContentParamsProvider
|
||||||
import org.jetbrains.kotlin.idea.debugger.coroutine.util.logger
|
import org.jetbrains.kotlin.idea.debugger.coroutine.util.logger
|
||||||
@@ -44,19 +45,39 @@ class DebuggerConnection(
|
|||||||
init {
|
init {
|
||||||
if (params is JavaParameters) {
|
if (params is JavaParameters) {
|
||||||
// gradle related logic in KotlinGradleCoroutineDebugProjectResolver
|
// gradle related logic in KotlinGradleCoroutineDebugProjectResolver
|
||||||
val kotlinxCoroutinesClassPathLib =
|
val kotlinxCoroutinesCore = params.classPath?.pathList?.firstOrNull { it.contains("kotlinx-coroutines-core") }
|
||||||
params.classPath?.pathList?.firstOrNull { it.contains("kotlinx-coroutines-debug") }
|
val kotlinxCoroutinesDebug = params.classPath?.pathList?.firstOrNull { it.contains("kotlinx-coroutines-debug") }
|
||||||
if (kotlinxCoroutinesClassPathLib is String)
|
|
||||||
initializeCoroutineAgent(params, kotlinxCoroutinesClassPathLib)
|
val mode = if (kotlinxCoroutinesDebug != null) {
|
||||||
else
|
CoroutineDebuggerMode.VERSION_UP_TO_1_3_4
|
||||||
log.warn("'kotlinx-coroutines-debug' not found in classpath.")
|
} else if (kotlinxCoroutinesCore != null) {
|
||||||
|
determineCoreVersionMode(kotlinxCoroutinesCore)
|
||||||
|
} else
|
||||||
|
CoroutineDebuggerMode.DISABLED
|
||||||
|
|
||||||
|
when (mode) {
|
||||||
|
CoroutineDebuggerMode.VERSION_1_3_5_AND_UP -> initializeCoroutineAgent(params, kotlinxCoroutinesCore)
|
||||||
|
CoroutineDebuggerMode.VERSION_UP_TO_1_3_4 -> initializeCoroutineAgent(params, kotlinxCoroutinesDebug)
|
||||||
|
else -> log.debug("CoroutineDebugger disabled.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
connect()
|
connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun determineCoreVersionMode(kotlinxCoroutinesCore: String): CoroutineDebuggerMode {
|
||||||
|
val regex = Regex(""".+\Wkotlinx\-coroutines\-core\-(.+)?\.jar""")
|
||||||
|
val matchResult = regex.matchEntire(kotlinxCoroutinesCore)
|
||||||
|
|
||||||
|
val coroutinesCoreVersion = DefaultArtifactVersion(matchResult?.groupValues?.get(1)) ?: return CoroutineDebuggerMode.DISABLED
|
||||||
|
val versionToCompareTo = DefaultArtifactVersion("1.3.5")
|
||||||
|
return if (versionToCompareTo.compareTo(coroutinesCoreVersion) < 0)
|
||||||
|
CoroutineDebuggerMode.VERSION_1_3_5_AND_UP
|
||||||
|
else
|
||||||
|
CoroutineDebuggerMode.DISABLED
|
||||||
|
}
|
||||||
|
|
||||||
private fun initializeCoroutineAgent(params: JavaParameters, it: String?) {
|
private fun initializeCoroutineAgent(params: JavaParameters, it: String?) {
|
||||||
params.vmParametersList?.add("-javaagent:$it")
|
params.vmParametersList?.add("-javaagent:$it")
|
||||||
params.vmParametersList?.add("-ea")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun connect() {
|
private fun connect() {
|
||||||
@@ -100,3 +121,9 @@ class DebuggerConnection(
|
|||||||
return ui.createContent(param.id, param.component, param.displayName, param.icon, param.parentComponent)
|
return ui.createContent(param.id, param.component, param.displayName, param.icon, param.parentComponent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class CoroutineDebuggerMode {
|
||||||
|
DISABLED,
|
||||||
|
VERSION_UP_TO_1_3_4,
|
||||||
|
VERSION_1_3_5_AND_UP
|
||||||
|
}
|
||||||
+5
@@ -32,4 +32,9 @@ public class XCoroutinesStackTraceTestGenerated extends AbstractXCoroutinesStack
|
|||||||
public void testCoroutineSuspendFun() throws Exception {
|
public void testCoroutineSuspendFun() throws Exception {
|
||||||
runTest("idea/jvm-debugger/jvm-debugger-test/testData/xcoroutines/coroutineSuspendFun.kt");
|
runTest("idea/jvm-debugger/jvm-debugger-test/testData/xcoroutines/coroutineSuspendFun.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("coroutineSuspendFun135.kt")
|
||||||
|
public void testCoroutineSuspendFun135() throws Exception {
|
||||||
|
runTest("idea/jvm-debugger/jvm-debugger-test/testData/xcoroutines/coroutineSuspendFun135.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
package continuation
|
||||||
|
// ATTACH_LIBRARY: maven(org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5-SNAPSHOT)-javaagent
|
||||||
|
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import kotlinx.coroutines.yield
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val main = "main"
|
||||||
|
runBlocking {
|
||||||
|
a()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun a() {
|
||||||
|
val a = "a"
|
||||||
|
b(a)
|
||||||
|
val aLate = "a" // to prevent stackFrame to collapse
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun b(paramA: String) {
|
||||||
|
yield()
|
||||||
|
val b = "b"
|
||||||
|
c(b)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun c(paramB: String) {
|
||||||
|
val c = "c"
|
||||||
|
//Breakpoint!
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user