I often run my program with a debugger attached just in case something doesn’t work. Then I leave it running over night to see how it performs over a longer period.
Randomly, my Flow-based logic stops working almost completely after a few hours. It get’s stuck and I don’t know where.
So I simply want to hit “Pause” in the IDE and debug the program as if it was paused automatically because of a breakpoint. I don’t really care where exactly it pauses as long as I can inspect threads, coroutines, expressions and some local variables of the threads’ current stacks to get closer to the source of the issue.
Right now it’s like this:
1. Hit “Pause” in Debug view.
2. It lists all threads with “main” selected and “Object.wait” highlighted in the code as that’s what the thread is currently executing (or rather waiting for).
3. It shows me the current stack of all threads.
4. “Variables” view, “Coroutines” view and the “Evaluate Expression…” view cannot be used because I manually paused the program instead of using a breakpoint. All show errors.
So the information the IDE currently provides in that situation (basically just threads list & stack traces) is completely useless to me. My issue is with coroutines and I can’t get access to that list (“No coroutine information found”).
So as a workaround I sneak in something like this upfront (if I don’t forget it):
GlobalScope.launch {
while (true) { delay(10000) }
}
I can set a breakpoint in the loop while the program is running. When the debugger breaks there instead of me pausing it manually, then suddenly all of those information become available.
Unfortunately I often cannot debug coroutines even if I pause with a breakpoint because of
https://youtrack.jetbrains.com/issue/KT-42594