Commit Graph

84 Commits

Author SHA1 Message Date
Ilmir Usmanov e79c9a3618 Extend LVT record of alive variables to end of next suspension point
Otherwise, arguments of suspend call become invisible in async stack
trace
 #KT-44714
2021-03-08 23:56:40 +01:00
Mikhael Bogdanov bea29d0de5 Add test for KT-44074
#KT-44074
2021-01-28 18:01:21 +01:00
Kristoffer Andersen 43b61a618d [IR+Tests] Improve Local Function Debugging Experience
This change improves the debugging experience around local functions
on the IR backend. The changes include moving old
checkLocalVariablesTable (cLVT) tests to the new stepping/local variable
infrastructure in order to refine the tests and further define the
behavior of the two JVM backends, and their differences.

The primary ported test case is cLVT/localFun.kt that documents the
discrepancy in implementation strategy for local functions on the two
backends. The old backend implements local functions as lambdas
assigned to a local variable while the IR backend lifts them out as
static funtions on the surrounding class. The discrepancies and their
consequences are documented in bytecodeListing, idea-stepping,
localVariableTable and debugStepping tests.

The only _code change_ is disabling the captured variable name
mangling for captured variables on the IR backend. Captured variables
are passed as arguments to the static function, so in the debugger,
they really just are local variables. For them to show properly in the
debugger and be detectable by evaluate expression, they simply need no
mangling.

Finally, this change cleans 3 redundant cLVT tests, copyFunction.kt
and destructuringInlineLambda.kt and destructuringInFor.kt, that are
all covered in the new suite. The stepping behavior needs to be made
precise around for loops, but that is an entirely seperate issue.
2021-01-11 18:21:23 +01:00
Kristoffer Andersen 8a5f260d04 [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.
2020-12-12 11:48:47 +01:00
Kristoffer Andersen 5967e8295e [IR] Align captured receiver variable naming with old BE 2020-11-18 15:18:10 +01:00
Mads Ager dca1f4631c [JVM_IR] Use line number 1 for multifile bridge methods.
This is necessary for the intellij debugger filters to hide
these bridges.

Fixes KT-41961.
2020-10-29 13:04:08 +01:00
Mads Ager ad88c60fd8 [JVM_IR] Copy offsets from the original function to invokeSuspend.
Otherwise, implicit returns in void returning suspend functions
will not have the line number of the end brace.

Fixes KT-41962 and KT-40464.
2020-10-21 12:38:45 +02:00
Mads Ager 318d11dcec [JVM_IR] Remove muting of fwBackingField.
It has been rebased and is not using this .out file at all
for JVM_IR. So in terms of testing this is a noop.
2020-10-16 19:21:08 +03:00
Mads Ager 0505bd958a [JVM] Fix the nop removal optimization.
Never remove a nop if that would cause a line number to move
across a local lifetime boundary.

This fixes KT-42725.
2020-10-16 19:21:08 +03:00
Mads Ager 17748b4499 [JVM_IR] Fix off-by-one line number error in CoroutineCodegen.
Fixes KT-41957.
2020-10-14 20:57:42 +02:00
Mads Ager f941733f13 [JVM_IR] Rebase init blocks stepping test that is working as intended. 2020-10-12 08:36:17 +02:00
pyos 05c856f1f7 JVM_IR: move SuspendLambdaLowering next to FunctionReferenceLowering
#KT-42253 Fixed
 #KT-39434 Fixed
2020-10-07 14:30:36 +02:00
Mads Ager a37f16d7a2 [IR] Do not generate line numbers for synthesized data class members.
Fixes KT-41903.
2020-10-06 19:53:47 +02:00
Steven Schäfer 39736868bf JVM IR: Allow debugger to evaluate expressions involving IR dependencies 2020-10-01 14:35:05 +02:00
Steven Schäfer 48b736e551 JVM IR: Enable evaluate expression tests for the JVM IR backend 2020-10-01 14:35:05 +02:00
Mads Ager ac742123fd [JVM_IR] Generate line numbers in synthetic bridges.
The current backend does that for some bridges. We do it consistently
for all bridges.

The line number used differs. For the JVM_IR backend, we use the
line number of the class to which the bridge is added. For the
JVM backend, that does not appear to be the case for bridges
in lambdas. I prefer the line number for a lambda invoke bridge
to be the line for the lambda instead os some surrounding class.
2020-09-24 08:59:48 +02:00
Alexander Udalov 84df996204 JVM IR: fix "step over" for inline function calls in conditions
Reimplement the same hacky approach used in the old backend (see
cc2fe6b0c6).

Previously, the debugger incorrectly stepped into Collections.kt on
"step over" inline function calls from stdlib like 'any'.

Since `if` and `when` expressions are represented the same way in IR,
the behavior is fixed for both of them. It's not the case in the old JVM
backend, where stepping over `when` conditions still suffers from the
same problem, which the newly added test checks.
2020-09-23 15:54:15 +02:00
Mads Ager 78483930bc [JVM_IR] Fix offsets in constant propagation optimization.
Loads of temporary variables that contain constants are replaced
with a copy of the constant. This avoids locals loads and stores.
However, the copy of the constant needs to have the offset of
the load and not of the original constant.

Fixes KT-41963.
2020-09-22 19:12:06 +02:00
Mads Ager 9f3ce099ee [JVM_IR] Fix line numbers for function reference invoke methods. 2020-09-22 16:59:46 +02:00
Mads Ager 05c662ec55 [JVM_IR] Remove line numbers from delegated member functions.
This fixes smart step into for delegated member functions.
Additionally, we align on the string "memberFunctionName(...)"
for expression non-null checks for both JVM_IR and JVM
backends.
2020-09-21 18:49:08 +02:00
Mads Ager a62ffbf992 [JVM_IR] Ignore fwBackingField stepping test.
The test relies on fixes not yet landed, so it currently fails.
2020-09-17 22:14:30 +02:00
Alexander Udalov 86cc5840ed JVM IR: unmute stepping test noParameterExtensionLambdaArgumentCallInInline3.kt
Bytecode generated by JVM IR ensures that on multiline expressions,
every call is stepped over, which seems better than in the old backend.

Also remove kt34905.kt since it duplicates this test case.
2020-09-16 17:52:27 +02:00
Alexander Udalov 0cccc61654 JVM IR: unmute stepping test smartStepIntoInterfaceImpl.kt
The only difference seems to be that step into IImpl.fooOverride is
actually supported in JVM_IR. Also fix slightly incorrect line numbers
in the comments.
2020-09-16 17:52:27 +02:00
Mads Ager e943d76266 [JVM_IR] Rebase fwBackingField stepping test.
The difference is that JVM_IR generates line numbers for the
constructor field initialization.

In this case:

```
29: class B {
30:   // comment
31:   val bPropVal: Int,
32:   // comment
33:   var bProbVar: Int
34: ) {
```

the line numbers for the field initializations are 31 and 33 where
in the current backend the whole constructor has line number 29.
2020-09-16 17:51:22 +02:00
Roman Artemev 685b74769d [JVM IR] Fix lineNumber passing into CoroutineTransformer.
- Get it from `IrFile` & `IrElement.startOffset` instead of descriptor
 - Unmute stepping tests
2020-09-03 11:37:24 +03:00
Roman Artemev c6a338bcdc Mute broken stepping JVM IR tests
They are broken because of c7b57c0fb3.
Current debug info generator in IR uses information from descriptors so
removing that break tests.
2020-09-02 17:52:27 +03:00
Mads Ager a6f301e84a [JVM_IR] Rebase constructor stepping tests that are working as intended.
JVM_IR has consistent stepping behavior for secondary constructors
and init blocks. This change fixes the expectations for tests that
expect the less consistent JVM backend behavior.
2020-08-20 13:12:22 +02:00
Mads Ager 2c6b5c8847 [JVM_IR] Give temporary variable loads meaningful offsets.
Temporary variable loads in when expressions had the offsets
of the variable declaration. That leads to hacks during codegen
for line number generation.

Instead of those hacks, give the variable loads the offsets of
the context in which they occur. That avoids the codegen hacks
and fixes stepping behavior for more when expressions.
2020-08-20 13:12:22 +02:00
Mads Ager 119302b016 [JVM_IR] Run KotlinSteppingTests with the JVM_IR backend.
Implement support for supressing failures by backend.
2020-08-20 05:48:54 +02:00
Ilmir Usmanov 6c475e614a Minor. Update debugger tests 2020-08-05 19:47:55 +02:00
Ilmir Usmanov 4fb5f8603a Keep $continuation in LVT
in case of suspend functions and `this` is case of lambdas, since they
are used in async stack trace generation.
Update tests.
 #KT-40661 Open
2020-07-29 00:01:12 +02:00
Vladimir Ilmov 14766a3e1a (CoroutineDebugger) lv 'task' added to tests in EventLoopImplBase kotlinx-coroutines-core:1.3.7 2020-07-20 11:38:01 +02:00
Vladimir Ilmov e49f3b567b (CoroutineDebugger) minimum supported version kotlinx-coroutines-core.1.3.8
Workaround for starting agent on windows removed, version upgraded in tests
 #KT-40073 fixed
2020-07-20 11:38:00 +02:00
Vladimir Ilmov b100fd526f (CoroutineDebugger)(Test) local variable removed from generated code 2020-06-19 00:32:19 +02:00
Ilmir Usmanov 542f1b8709 Minor. Update tests 2020-06-18 17:53:47 +02:00
Vladimir Ilmov 50165397c7 (CoroutineDebugger) flaky test coroutine-debug library changed to 1.3.4 2020-06-08 22:54:09 +02:00
Ilmir Usmanov f1906bc966 Minor. Update test 2020-06-05 21:55:34 +02:00
Yan Zhulanow 45c97a2c5e Debugger: Add test for KT-14057 2020-05-27 02:38:43 +09:00
Yan Zhulanow bf890a1540 Debugger, tests: Change ADDITIONAL_BREAKPOINT directive format
- Make it extendable and easier to parse
- Allow to create additional function breakpoints
2020-05-27 02:38:43 +09:00
Yan Zhulanow 4244f05307 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.
2020-05-27 02:38:43 +09:00
Yan Zhulanow 69965eaa5c Implement new stepping for suspend functions 2020-05-27 02:38:43 +09:00
Yan Zhulanow 0afd73b95c Debugger: Pass files with inline functions to backend (KT-36404) 2020-05-27 02:38:42 +09:00
Yan Zhulanow 85a5e5241f Debugger: Fix function breakpoints for libraries (KT-36403) 2020-05-27 02:38:42 +09:00
pyos f625444be2 Update debugger test data
Note: neither the new nor the old data is actually correct, as the
debugger needs to stop on line 7 twice (once for the call, once for the
lambda) but ignore the synthetic line number in between.
2020-05-25 20:03:56 +02:00
Vladimir Ilmov 545fdb96d5 (CoroutineDebugger) 201 compatibility fix
#KT-39143 fixed
2020-05-25 14:36:22 +02:00
Vladimir Ilmov acced52384 (CoroutineDebugger) Tests added for no creation stack frame information 2020-04-23 11:36:15 +02:00
Vladimir Ilmov 73f5e48518 (CoroutineDebugger) Minor fixes, kotlinx.coroutines version fix 2020-04-21 09:48:13 +02:00
Vladimir Ilmov 0ce8ca7bcd (CoroutineDebugger) negative frames removed from coroutine stack 2020-04-21 09:48:13 +02:00
Vladimir Ilmov 68c6e9e2d6 (CoroutineDebugger) kotlinx-coroutines-core:1.3.5 support 2020-04-21 09:48:12 +02:00
Vladimir Ilmov 6f42ed7248 (CoroutineDebugger) PreflightFrame support in tests via CoroutineAsync 2020-04-21 09:48:11 +02:00