Debugger: Fix step over in functions with default parameters (KT-14828)

Adds a synthetic line number just before the original function call.
The new line number is recognized by the debugger which replaces the
  'step over' action with 'step into' and stops.
This commit is contained in:
Yan Zhulanow
2020-02-05 19:05:42 +09:00
parent d0f34624bd
commit 4244f05307
21 changed files with 357 additions and 19 deletions
@@ -0,0 +1,21 @@
package test
fun main(args: Array<String>) {
//Breakpoint!
call()
foo()
}
fun call(a: Int = def()) {
foo()
}
fun def(): Int {
return libFun() // 'Step over' causes debugger skipping call()
}
fun foo() {}
fun libFun() = 12
// STEP_INTO: 1
// STEP_OVER: 2
@@ -0,0 +1,10 @@
LineBreakpoint created at afterDefaultParameterValues.kt:5
Run Java
Connected to the target VM
afterDefaultParameterValues.kt:5
afterDefaultParameterValues.kt:9
afterDefaultParameterValues.kt:10
afterDefaultParameterValues.kt:11
Disconnected from the target VM
Process finished with exit code 0
@@ -0,0 +1,21 @@
package test
fun main(args: Array<String>) {
//Breakpoint!
call()
foo()
}
fun call(a: Int = def()) {
foo()
}
fun def(): Int {
return libFun() // 'Step over' causes debugger skipping call()
}
fun foo() {}
fun libFun() = 12
// STEP_INTO: 2
// STEP_OVER: 5
@@ -0,0 +1,14 @@
LineBreakpoint created at afterDefaultParameterValues2.kt:5
Run Java
Connected to the target VM
afterDefaultParameterValues2.kt:5
afterDefaultParameterValues2.kt:9
afterDefaultParameterValues2.kt:14
afterDefaultParameterValues2.kt:9
afterDefaultParameterValues2.kt:10
afterDefaultParameterValues2.kt:11
afterDefaultParameterValues2.kt:6
afterDefaultParameterValues2.kt:7
Disconnected from the target VM
Process finished with exit code 0
@@ -0,0 +1,26 @@
package test
fun main() {
val foo = FooImpl()
//Breakpoint!
foo.call()
foo.foo()
}
interface Foo {
fun call(a: Int = def()) {
foo()
}
fun def(): Int {
return libFun() // 'Step over' causes debugger skipping call()
}
fun foo() {}
fun libFun() = 12
}
class FooImpl : Foo
// STEP_INTO: 2
// STEP_OVER: 7
@@ -0,0 +1,16 @@
LineBreakpoint created at afterDefaultParameterValues2Intf.kt:6
Run Java
Connected to the target VM
afterDefaultParameterValues2Intf.kt:6
afterDefaultParameterValues2Intf.kt:11
afterDefaultParameterValues2Intf.kt:16
afterDefaultParameterValues2Intf.kt:23
afterDefaultParameterValues2Intf.kt:11
afterDefaultParameterValues2Intf.kt:12
afterDefaultParameterValues2Intf.kt:13
afterDefaultParameterValues2Intf.kt:23
afterDefaultParameterValues2Intf.kt:11
afterDefaultParameterValues2Intf.kt:7
Disconnected from the target VM
Process finished with exit code 0
@@ -0,0 +1,26 @@
package test
fun main() {
val foo = FooImpl()
//Breakpoint!
foo.call()
foo.foo()
}
interface Foo {
fun call(a: Int = def()) {
foo()
}
fun def(): Int {
return libFun() // 'Step over' causes debugger skipping call()
}
fun foo() {}
fun libFun() = 12
}
class FooImpl : Foo
// STEP_INTO: 1
// STEP_OVER: 2
@@ -0,0 +1,10 @@
LineBreakpoint created at afterDefaultParameterValuesIntf.kt:6
Run Java
Connected to the target VM
afterDefaultParameterValuesIntf.kt:6
afterDefaultParameterValuesIntf.kt:11
afterDefaultParameterValuesIntf.kt:12
afterDefaultParameterValuesIntf.kt:13
Disconnected from the target VM
Process finished with exit code 0
@@ -7,11 +7,11 @@ Connected to the target VM
smartStepIntoFunWithDefaultArgs.kt:17
smartStepIntoFunWithDefaultArgs.kt:4
smartStepIntoFunWithDefaultArgs.kt:22
smartStepIntoFunWithDefaultArgs.kt:4
smartStepIntoFunWithDefaultArgs.kt:3
smartStepIntoFunWithDefaultArgs.kt:27
smartStepIntoFunWithDefaultArgs.kt:8
smartStepIntoFunWithDefaultArgs.kt:32
smartStepIntoFunWithDefaultArgs.kt:8
smartStepIntoFunWithDefaultArgs.kt:7
Disconnected from the target VM
Process finished with exit code 0
@@ -16,7 +16,7 @@ smartStepIntoInterfaceImpl.kt:91
smartStepIntoInterfaceImpl.kt:96
smartStepIntoInterfaceImpl.kt:9
smartStepIntoInterfaceImpl.kt:101
smartStepIntoInterfaceImpl.kt:14
smartStepIntoInterfaceImpl.kt:13
smartStepIntoInterfaceImpl.kt:106
smartStepIntoInterfaceImpl.kt:14
smartStepIntoInterfaceImpl.kt:111
@@ -39,4 +39,4 @@ suspend fun run() {
}
}
// STEP_OVER: 4
// STEP_OVER: 3
@@ -3,7 +3,6 @@ Run Java
Connected to the target VM
soSuspendableCallInEndOfFun.kt:29
soSuspendableCallInEndOfFun.kt:17
soSuspendableCallInEndOfFun.kt:16
soSuspendableCallInEndOfFun.kt:18
soSuspendableCallInEndOfFun.kt:37
Disconnected from the target VM