Tons of problems with the debugger and Kotlin

I am having a ton of problems with IntelliJ debugger and Kotlin. I am running on 2019.1.3 built on May 28th.

Basically what happens is breakpoints are not detected, often IDE doesn’t stop and keeps running. Have to try a few times (rerun the app) to make it detect the breakpoints. Also, inserting new breakpoints while app is running doesn’t works. I normally run my projects delegating everything to gradle, but this happens as well when using the IDE to run the app from main class. I wonder if this is because Kotlin is relatively young or some sort of setting which I need to adjust. What do you reckon?
image

2 Likes

This usually happens when you are using wrong version of plugin in IDEA or in build. Try to install latest plugin and then invalidate/restart.

That’s true, for some reason plugin was stuck at 1.3.21, and not updating to 1.3.31 automatically.
Now I have 1.3.31, which is aligned with my gradle settings as well.
Bad news, problem is still happening. Really weird…

Invalidate IDEA cache, rebuild project if you do not delegate build to gradle. In some cases erase .gradle manually.

Unfortunately none of that helped… Same problem happens on different machines, also on different projects. I remember debugging was much better on version 1.2

Strange. I haven’t had any problems with debugging kotlin on any machine. Are you using any uncommon plugins, which could interfere with debugging? Maybe try to update or disable those.

I disabled every plugin I could, definitely not that.
As soon as my breakpoint is hit, this is what I see… all the rest are disabled and cannot place any new one because it’d not stop there. I am inside a suspend function and have enabled -ea like instructured here:

image

Any breaktpoint I set after I click run, it will never hit.

But but but… something interesting happens if I inline that functon or change it from private to public… then it works:
image

1 Like

I updated to Kotlin 1.3.40, problem is still there.
I can confirm the problem happens within suspendable and private methods at the same time.
It’s easy to reproduce:

suspend private fun trythis() {
        val a = 1
        val b = 2
        val c = a + b
    }

So this is how it behaves:

  • public = works
  • private = works
  • suspend public = works
  • suspend private = doesn’t work
  • inline suspend private = works
  • any combination with inline = works.

You have to change breakpoints after it started to reproduce, then it will happen.
Maybe worth opening an issue?
Happens both delegating to gradle and using internal launcher with main class.

3 Likes

Definitely

Ok tracked here.
https://youtrack.jetbrains.com/issue/KT-32102