Skip to content

Commit fada750

Browse files
committed
Tweak DebuggerInfo
1 parent fddaee8 commit fada750

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbesImpl.kt

+4
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ internal object DebugProbesImpl {
107107
.toList()
108108
}
109109

110+
/*
111+
* Internal (JVM-public) method used by IDEA debugger.
112+
* It is equivalent to dumpCoroutines, but returns serializable (and thus less typed) objects.
113+
*/
110114
public fun dumpDebuggerInfo() = dumpCoroutinesInfo().map { DebuggerInfo(it) }
111115

112116
public fun dumpCoroutines(out: PrintStream): Unit = synchronized(out) {

kotlinx-coroutines-core/jvm/src/debug/internal/DebuggerInfo.kt

+12-6
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@
22
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
@file:Suppress("PropertyName", "NO_EXPLICIT_VISIBILITY_IN_API_MODE")
5+
@file:Suppress("UNUSED")
66

77
package kotlinx.coroutines.debug.internal
88

99
import java.io.Serializable
1010
import kotlin.coroutines.*
11-
import kotlin.coroutines.jvm.internal.*
11+
import kotlinx.coroutines.*
1212

13+
/*
14+
* This class represents all the data required by IDEA debugger.
15+
* It is serializable in order to speedup JDWP interactions
16+
*/
1317
internal class DebuggerInfo(source: DebugCoroutineInfo) : Serializable {
14-
public val name: String? = source.context[kotlinx.coroutines.CoroutineName]?.name
18+
public val coroutineId: Long? = source.context[CoroutineId]?.id
19+
public val dispatcher: String? = source.context[ContinuationInterceptor].toString()
20+
public val name: String? = source.context[CoroutineName]?.name
1521
public val state: String = source.state
16-
public val lastObservedThreadState = source.lastObservedThread?.state
22+
public val lastObservedThreadState: String? = source.lastObservedThread?.state?.toString()
1723
public val lastObservedThreadName = source.lastObservedThread?.name
18-
public val lastObservedStackTrace = source.lastObservedStackTrace()
19-
public val sequenceNumber = source.sequenceNumber
24+
public val lastObservedStackTrace: List<StackTraceElement> = source.lastObservedStackTrace()
25+
public val sequenceNumber: Long = source.sequenceNumber
2026
}

kotlinx-coroutines-debug/test/RunningThreadStackMergeTest.kt

-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ class RunningThreadStackMergeTest : DebugTestBase() {
179179
awaitCoroutineStarted()
180180
val info = DebugProbesImpl.dumpDebuggerInfo().find { it.state == "RUNNING" }
181181
assertNotNull(info)
182-
@Suppress("INVISIBLE_MEMBER") // IDEA bug
183182
assertNotNull(info.lastObservedThreadName)
184183
coroutineBlocker.await()
185184
}

0 commit comments

Comments
 (0)