in kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbesImpl.kt [180:211]
fun dumpCoroutinesInfoAsJsonAndReferences(): Array<Any> {
val coroutinesInfo = dumpCoroutinesInfo()
val size = coroutinesInfo.size
val lastObservedThreads = ArrayList<Thread?>(size)
val lastObservedFrames = ArrayList<CoroutineStackFrame?>(size)
val coroutinesInfoAsJson = ArrayList<String>(size)
for (info in coroutinesInfo) {
val context = info.context
val name = context[CoroutineName.Key]?.name?.toStringRepr()
val dispatcher = context[CoroutineDispatcher.Key]?.toStringRepr()
coroutinesInfoAsJson.add(
"""
{
"name": $name,
"id": ${context[CoroutineId.Key]?.id},
"dispatcher": $dispatcher,
"sequenceNumber": ${info.sequenceNumber},
"state": "${info.state}"
}
""".trimIndent()
)
lastObservedFrames.add(info.lastObservedFrame)
lastObservedThreads.add(info.lastObservedThread)
}
return arrayOf(
"[${coroutinesInfoAsJson.joinToString()}]",
lastObservedThreads.toTypedArray(),
lastObservedFrames.toTypedArray(),
coroutinesInfo.toTypedArray()
)
}