Debugger: Support captured values (KT-30740)

This commit is contained in:
Yan Zhulanow
2019-04-30 23:59:23 +03:00
parent f16459df32
commit 5777592024
12 changed files with 437 additions and 191 deletions
@@ -0,0 +1,36 @@
package capturedValues1
fun main(args: Array<String>) {
1000.foo(args)
}
fun Int.foo(args: Array<String>) {
val a = 1
block {
val b = 2
val b2 = 2
block("x") place1@ {
val c = 3
val c2 = 3
block("y") place2@ {
//Breakpoint!
this@place1
this@foo
b
c2
args
}
}
}
}
fun block(block: () -> Unit) {
block()
}
fun <T> block(obj: T, block: T.() -> Unit) {
obj.block()
}
// SHOW_KOTLIN_VARIABLES
// PRINT_FRAME
@@ -0,0 +1,20 @@
LineBreakpoint created at capturedValues1.kt:17
Run Java
Connected to the target VM
capturedValues1.kt:17
frame = invoke:17, CapturedValues1Kt$foo$1$1$1 {capturedValues1}
unknown = this (@foo) = 1000
unknown = args = {java.lang.String[0]@uniqueID}
unknown = b = 2
unknown = this (@place1) = x
field = value: char[] = {char[1]@uniqueID} (sp = String.!EXT!)
element = 0 = 'x' 120
field = hash: int = 0 (sp = String.!EXT!)
unknown = c2 = 3
local = this: java.lang.String = y (sp = null)
field = value: char[] = {char[1]@uniqueID} (sp = String.!EXT!)
element = 0 = 'y' 121
field = hash: int = 0 (sp = String.!EXT!)
Disconnected from the target VM
Process finished with exit code 0
@@ -0,0 +1,27 @@
package capturedValues2
fun main() {
1000.foo()
}
fun Int.foo() {
block {
val b = 1
val b2 = 2
block("x") foo@ {
//Breakpoint!
this@foo + b
}
}
}
fun block(block: () -> Unit) {
block()
}
fun <T> block(obj: T, block: T.() -> Unit) {
obj.block()
}
// SHOW_KOTLIN_VARIABLES
// PRINT_FRAME
@@ -0,0 +1,13 @@
LineBreakpoint created at capturedValues2.kt:13
Run Java
Connected to the target VM
capturedValues2.kt:13
frame = invoke:13, CapturedValues2Kt$foo$1$1 {capturedValues2}
unknown = b = 1
local = this: java.lang.String = x (sp = null)
field = value: char[] = {char[1]@uniqueID} (sp = String.!EXT!)
element = 0 = 'x' 120
field = hash: int = 0 (sp = String.!EXT!)
Disconnected from the target VM
Process finished with exit code 0