[IR] Align debugging of suspend lambdas with old BE

The existing backend restores LVs and parameters from the suspend lambda
fields used for spilling between suspension points, hence they are
visible in the debugger as local variables, plain and simple.

This PR introduces the same pattern to the IR backend, to bring the
debugging experience in line with the existing backend.

Both backends are still at the mercy of the liveness analysis
performed in the coroutine transformer where a liveness analysis
minimizes live ranges of entries in the LVT. E.g. an unused parameter
will be dropped entirely.

Adjusted existing test expectations accounting for the differences in
LV behavior.
This commit is contained in:
Kristoffer Andersen
2020-11-24 12:53:16 +01:00
committed by Alexander Udalov
parent 2be62c13b0
commit 8a5f260d04
12 changed files with 112 additions and 78 deletions
@@ -606,6 +606,11 @@ public class IrKotlinEvaluateExpressionTestGenerated extends AbstractIrKotlinEva
runTest("idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/coroutines/anyUpdateVariable.kt");
}
@TestMetadata("capturedReceiverName.kt")
public void testCapturedReceiverName() throws Exception {
runTest("idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/coroutines/capturedReceiverName.kt");
}
@TestMetadata("primitivesCoertion.kt")
public void testPrimitivesCoertion() throws Exception {
runTest("idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/coroutines/primitivesCoertion.kt");
@@ -605,6 +605,11 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
runTest("idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/coroutines/anyUpdateVariable.kt");
}
@TestMetadata("capturedReceiverName.kt")
public void testCapturedReceiverName() throws Exception {
runTest("idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/coroutines/capturedReceiverName.kt");
}
@TestMetadata("primitivesCoertion.kt")
public void testPrimitivesCoertion() throws Exception {
runTest("idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/coroutines/primitivesCoertion.kt");
@@ -0,0 +1,40 @@
package capturedReceiverName
import kotlin.sequences.*
import kotlin.coroutines.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(object : Continuation<Unit>{
override val context: CoroutineContext
get() = EmptyCoroutineContext
override fun resumeWith(result: Result<Unit>) {
result.getOrThrow()
}
})
}
fun main(args: Array<String>) {
builder {
var s = "OK"
s = strChanger(s) { character ->
//Breakpoint!
character != 'a' // (2)
}
println(s)
}
}
suspend fun strChanger(str: String, pred: suspend (Char) -> Boolean): String {
var result = ""
str.forEach {
if (pred(it)) {
result += it
}
}
return result
}
// EXPRESSION: character
// RESULT: 79: C
// 79.toChar() == 'O'
@@ -0,0 +1,10 @@
LineBreakpoint created at capturedReceiverName.kt:22
Run Java
Connected to the target VM
capturedReceiverName.kt:22
Compile bytecode for character
capturedReceiverName.kt:22
Disconnected from the target VM
Process finished with exit code 0
OK