Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kotlin][debugger] Remove bytecode inspection for coroutine method switch check #2842

Conversation

nikita-nazarov
Copy link
Contributor

When checking if a suspend method has a state machine, the debugger inspected bytecode trying to find an instruction like getfield com/example/MainKt$foo$1.label:I. This approach didn't work in Android Studio, which resulted in a stepping difference between IDEs. This commit introduces a simpler way of detecting if a state machine is generated for a suspend function.

@zuevmaxim

When checking if a suspend method has a state machine, the debugger inspected bytecode trying to find an instruction like `getfield com/example/MainKt$foo$1.label:I`. This approach didn't work in Android Studio, which resulted in a stepping difference between IDEs. This commit introduces a simpler way of detecting if a state machine is generated for a suspend function.
@nikita-nazarov nikita-nazarov force-pushed the nazarov/coroutine-switch-refactoring branch from 75b2987 to 7a2f6e1 Compare September 2, 2024 20:13
@mvicsokolova
Copy link
Contributor

Probably this approach will not work for the cases with tail call optimization, when no state machine is generated for a suspend lambda. I'll check the cases like this.

@nikita-nazarov maybe you could share an example of code, where the behavior was different?

@nikita-nazarov
Copy link
Contributor Author

Tests that fail on Android without this inspection:
testSiSuspendFun
testStepIntoSuspendFunctionSimple

@nikita-nazarov
Copy link
Contributor Author

Hi @mvicsokolova! Can you please take a look at this pr?

@mvicsokolova
Copy link
Contributor

Hi! @nikita-nazarov, I've very sorry for the endless review of this PR, I've merged the fix for this issue into the master branch of ultimate.
I've added your implementation for the case of Android in doesMethodHaveSwitcher method, and left the bytecode traversal looking for the label field in case of JVM.

intellij-monorepo-bot pushed a commit that referenced this pull request Dec 6, 2024
See #2842

GitOrigin-RevId: 065b5262136ba3293653642a25c1f5a28573e372
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants