Inline functions and line numbers

Currently the call of an inline function produces stack traces with line numbers at the end of the given kotlin file. I understand the reason for the generated code, but wouldn’t it be possible to supply the actual line where the code fragment was inserted/introduced? Current stack trace makes it near impossible to identify the actual source of an exception.

1 Like

If you are using intellij there is a feature called “analyze stacktrace”. It should be able to resolve it for you. I think it’s under “Analyze > Analyze Stacktrace”

1 Like

Nope. It doesn’t. Still gives me a line outside the actual file. No mapping taking place. I’m left to guessing. Having the insertion line would be a great help

1 Like

Mmm. Your right. I could have sworn that it worked that way. I also found this:

So I guess it should work.

Also found that. For me it doesn’t work. Never have seen it work. Right now I feel forced to ignore inline functions but I need reification at some points and am lost in case of a stack trace.

Maybe create an issue: https://youtrack.jetbrains.com/issues/KT. I mean there must be a way to resolve this.

I can do that. But I’d still like to know if adding the insertion line of an line function is still an option. This way it would be easier to read the stack trace without any additional tooling.

I think I will first need to check if the problem is due to different commit states. Sadly in this case it is hard to say if it is at the right not existing line :slight_smile:

By the insertion line you mean the line where the inline function was invoked?

AFAIK, a stack trace is a printout of stack frames. Calling an inline function by definition does not append another stack frame to the stack trace.

The stack trace is generated by JVM and I’m not aware of any way to augment or post-process that stack trace, are you?

For lack of that we have to choose between the readability of raw stack traces and ability to debug the inline functions. Given that the first could be alleviated with the “Analyze stacktrace” tool, we have chosen the second for the user-defined inline functions.

See my reply in the other thread: Stacktrace points to line after end of file? - #9 by ubuntudroid

TL;DR: Try to normalize the stack trace in the Analyze Stack Trace dialog first.