[erlang-questions] How to get the line number of current executable code?

Richard Carlsson <>
Tue Aug 26 11:15:38 CEST 2008

Mats Cronqvist wrote:
>  it is not true that the only way to inspect the stack is by forcing an
> exception.
>  i'm too lazy to write actual code, but try this in the shell;
> ()41> {_,BT}=erlang:process_info(self(),backtrace).
> ()42> S=fun(B,{_,[_,{F,L}|_]})->
> <<_:F/binary,R:L/binary,_/binary>> =B, R end.
> ()43> S(BT,re:run(BT,"Return
> addr\\s[0-9a-z]+\\s\\(([^\\s]*)")).
> <<"erl_eval:expr/5">>

Ugh! I didn't know that flag to process_info existed, but I'm happy to
see that Mats' talent for sniffing out the dark corners of Erlang and
using them for unspeakable deeds is as strong as ever.


More information about the erlang-questions mailing list