(CoroutineDebugger) Stack printing logic extracted to the single place
for DebugMetadata and CoroutinePanel, some corner cases fixed, test cases added. Added: - external maven dependencies in test scenarios - comparing stack traces + variables on breakpoint
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package coroutine1
|
||||
|
||||
import kotlin.coroutines.Continuation
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
import kotlin.coroutines.startCoroutine
|
||||
|
||||
fun main() {
|
||||
val cnt = Continuation<Int>(EmptyCoroutineContext) { }
|
||||
val result = ::test1.startCoroutine(1, cnt)
|
||||
println(result)
|
||||
}
|
||||
|
||||
suspend fun test1(i: Int): Int {
|
||||
val test1 = "a"
|
||||
a(test1)
|
||||
println(test1)
|
||||
return i
|
||||
}
|
||||
|
||||
suspend fun a(aParam: String) {
|
||||
val a = "a"
|
||||
b(a)
|
||||
println(a)
|
||||
}
|
||||
|
||||
suspend fun b(bParam: String) {
|
||||
val b = "b"
|
||||
// Breakpoint!
|
||||
println(b)
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package continuation
|
||||
|
||||
fun main() {
|
||||
val a = "a"
|
||||
fibonacci().take(10).toList()
|
||||
}
|
||||
|
||||
fun nextSequence(terms: Pair<Int, Int>): Pair<Int, Int> {
|
||||
val terms1 = Pair(terms.second, terms.first + terms.second)
|
||||
if (terms1.first == 8) {
|
||||
//Breakpoint!
|
||||
return terms1
|
||||
} else
|
||||
return terms1
|
||||
}
|
||||
|
||||
fun fibonacci() = sequence {
|
||||
var terms = Pair(0, 1)
|
||||
var step = 0
|
||||
|
||||
while (true) {
|
||||
yield(terms.first)
|
||||
terms = nextSequence(terms)
|
||||
step++
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
LineBreakpoint created at sequence.kt:14
|
||||
Run Java
|
||||
Connected to the target VM
|
||||
sequence.kt:12
|
||||
Thread stack trace:
|
||||
nextSequence:12, SequenceKt (continuation)
|
||||
(terms, terms1)
|
||||
invokeSuspend:23, SequenceKt$fibonacci$1 (continuation)
|
||||
($result, $this$sequence, step, terms, this)
|
||||
resumeWith:33, kotlin.coroutines.jvm.internal.BaseContinuationImpl
|
||||
($i$a$-with-BaseContinuationImpl$resumeWith$1, $this$with, completion, current, param, result, this)
|
||||
hasNext:140, kotlin.sequences.SequenceBuilderIterator
|
||||
(step, this)
|
||||
hasNext:374, kotlin.sequences.TakeSequence$iterator$1
|
||||
(this)
|
||||
toCollection:722, kotlin.sequences.SequencesKt___SequencesKt
|
||||
($this$toCollection, destination)
|
||||
toMutableList:752, kotlin.sequences.SequencesKt___SequencesKt
|
||||
($this$toMutableList)
|
||||
toList:743, kotlin.sequences.SequencesKt___SequencesKt
|
||||
($this$toList)
|
||||
main:5, continuation.SequenceKt
|
||||
(a)
|
||||
main:-1, continuation.SequenceKt
|
||||
()
|
||||
Disconnected from the target VM
|
||||
|
||||
Process finished with exit code 0
|
||||
Reference in New Issue
Block a user