Are breakpoints inside inline lambdas supposed to ...
# android
p
Are breakpoints inside inline lambdas supposed to work normally? I want to know if I'm doing something wrong, or if that's just the way things are.
t
I think it will be affected by whether lambda expressions are inlined or not
p
I'm getting really weird behavior (debugger stopping and showing the line being an
import
line, but mostly just not stopping at all) when it comes to inline functions.
And yeah, when I remove the inline, everything works fine
t
If the function defined with the inline keyword receives a lambda expression, the content of the lambda expression is also inlined. the breakpoint issue with inline lambda has been mentioned in the book "kotlin in action".
p
Ok, so it's a known problem
I was wondering whether I could do something to fix it, but guess not
t
Breakpoints in lambda functions seems to be troublesome across many languages. It's an issue I've had in Swift and Java.
p
It works perfectly fine in non-inline lambdas though
Or rather, lambdas passed to non-inline functions
t
Most annoying was when I had a breakpoint in Java, trying to fix a NPE - but the breakpoint would only fire after the lambda completed no matter where it was placed. Never figured out why...
I'm sick so my thinking is a bit foggy but I'd guess it's because being inline defines certain aspects of the code to be guaranteed, so optimization will probably remove the lambda and all traces of it.
p
Sure, but there should be some source-map-like information, at least in the debug build, that maps it back to the original code
Maybe it's an Android thing, I'm not sure if the same problem also occurs on the desktop JVM
t
Makes me curious to see the machine code but man, Android debug Kotlin machine code is super hard to read.
I made a script to compare KN, C, and Swift compiling the exact same code both with and without debugging and it's crazy how big the Kotlin's unoptimized debug machine code was. Something like 5mb