@@ -76,24 +76,32 @@ internal object DebugProbesImpl {
76
76
77
77
private fun Job.build (map : Map <Job , CoroutineState >, builder : StringBuilder , indent : String ) {
78
78
val state = map[this ]
79
- builder.append(indent)
80
- @Suppress(" DEPRECATION_ERROR" )
81
- val str = if (this !is JobSupport ) toString() else toDebugString()
82
- if (state == null ) {
79
+ val newIndent: String
80
+ if (state == null ) { // Append coroutine without stacktrace
81
+ // Do not print scoped coroutines and do not increase indentation level
83
82
@Suppress(" INVISIBLE_REFERENCE" )
84
- if (this !is kotlinx.coroutines.internal.ScopeCoroutine <* >) { // Do not print scoped coroutines
85
- builder.append(" $str \n " )
83
+ if (this !is kotlinx.coroutines.internal.ScopeCoroutine <* >) {
84
+ builder.append(" $indent$debugString \n " )
85
+ newIndent = indent + " \t "
86
+ } else {
87
+ newIndent = indent
86
88
}
87
89
} else {
90
+ // Append coroutine with its last stacktrace element
88
91
val element = state.lastObservedStackTrace().firstOrNull()
89
92
val contState = state.state
90
- builder.append(" $str , continuation is $contState at line $element \n " )
93
+ builder.append(" $indent$debugString , continuation is $contState at line $element \n " )
94
+ newIndent = indent + " \t "
91
95
}
96
+ // Append children with new indent
92
97
for (child in children) {
93
- child.build(map, builder, indent + " \t " )
98
+ child.build(map, builder, newIndent )
94
99
}
95
100
}
96
101
102
+ @Suppress(" DEPRECATION_ERROR" ) // JobSupport
103
+ private val Job .debugString: String get() = if (this is JobSupport ) toDebugString() else toString()
104
+
97
105
@Synchronized
98
106
public fun dumpCoroutinesState (): List <CoroutineState > {
99
107
check(isInstalled) { " Debug probes are not installed" }
0 commit comments