[erlang-questions] Getting line number in backtrace?

Brian Candler B.Candler@REDACTED
Fri Dec 3 13:50:17 CET 2010

On Fri, Dec 03, 2010 at 10:57:03AM +0100, Lukas Larsson wrote:
> there is right now no good way to get line numbers from crashes. In
> common_test suites the code is instrumented using a parse_transform to
> do this, but that solution works only when used within common_test. 
> There have been many discussions about this before, for one discussion
> see
> http://www.erlang.org/pipermail/erlang-questions/2005-August/016477.html

Thank you for the update. I found some old discussions, some of which had
responses along the lines of "this is a reasonable thing to want, we'll get
round to it eventually".

Undoubtedly it gets easier with experience, but even with a 5-line function,
it would still save me some brain work to be told which of those 5 lines the
badmatch error occured on.

I notice that the abstract format has the line numbers already, and this is
available as a beam chunk when you compile with +debug_info.

So a simple way to achieve the desired effect with little chance of breaking
anything, would be to have a further beam chunk type, which maps ranges of
bytecode offsets to source line numbers. I guess it depends how much
shuffling and optimisation of beam code takes palce.



More information about the erlang-questions mailing list