https://kotlinlang.org logo
#android
Title
# android
p

peterholak

08/01/2018, 1:32 PM
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

tateisu

08/01/2018, 1:33 PM
I think it will be affected by whether lambda expressions are inlined or not
p

peterholak

08/01/2018, 1:35 PM
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

tateisu

08/01/2018, 1:38 PM
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

peterholak

08/01/2018, 1:38 PM
Ok, so it's a known problem
I was wondering whether I could do something to fix it, but guess not
t

thymecypher

08/01/2018, 2:36 PM
Breakpoints in lambda functions seems to be troublesome across many languages. It's an issue I've had in Swift and Java.
p

peterholak

08/01/2018, 2:37 PM
It works perfectly fine in non-inline lambdas though
Or rather, lambdas passed to non-inline functions
t

thymecypher

08/01/2018, 2:37 PM
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

peterholak

08/01/2018, 2:44 PM
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

thymecypher

08/01/2018, 2:45 PM
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
3 Views