Skip to content

Instantly share code, notes, and snippets.

@shino
Forked from andelf/beam_decompile.erl
Created December 16, 2015 02:04
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shino/e5d76ced2e44cc6a21d0 to your computer and use it in GitHub Desktop.
Save shino/e5d76ced2e44cc6a21d0 to your computer and use it in GitHub Desktop.
Erlang BEAM file decompile to .erl file
#!/usr/bin/env escript
% -*- mode: erlang -*-
main([BeamFile]) ->
{ok,{_,[{abstract_code,{_,AC}}]}} = beam_lib:chunks(BeamFile,[abstract_code]),
io:fwrite("~s~n", [erl_prettypr:format(erl_syntax:form_list(AC))]).
@shino
Copy link
Author

shino commented Dec 16, 2015

Mod=f,
io:format("~s~n", [erl_prettypr:format(
    erl_syntax:form_list(element(2,element(2,hd(element(2, element(2,
        beam_lib:chunks(element(2,code:get_object_code(Mod)), [abstract_code]))))))))]).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment