Cloudys
Cloudys

Reputation: 41

(Elixir/Erlang) How to get the source code file line total numbers from an Erlang beam file?

Is this information contained in these chunks of the Beam file? Or is there another way?

beam file chunks

Upvotes: -1

Views: 225

Answers (1)

legoscia
legoscia

Reputation: 41618

For a beam file compiled from Erlang, you can get the number of lines like this:

{ok,{_ModuleName,[{debug_info,{debug_info_v1,erl_abstract_code, DebugInfoData}}]}} =
   beam_lib:chunks("my_module", [debug_info]).
{ok, Defs} = erl_abstract_code:debug_info(erlang_v1, x, DebugInfoData, []).
{eof, {Lines, _}} = lists:last(Defs).

Replace "my_module" with the file name of the beam file without the .beam extension.

Upvotes: 0

Related Questions