Skip to content

Instantly share code, notes, and snippets.

@andelf
Created March 19, 2013 03:25
Show Gist options
  • Save andelf/5193480 to your computer and use it in GitHub Desktop.
Save andelf/5193480 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))]).
@dolambinhminh
Copy link

Hi! Tried your but i have exception [{abstract_code,no_abstract_code}]. I don't know what's happen? Please! Can you help me fix this error!
I'm running Erlang on Window.
Thankyou!

@jfacorro
Copy link

jfacorro commented May 6, 2016

@dolambinhminh The problem is that for this piece of code to work the module has to be compiled with the debuf_info flag, otherwise the abstract code is not included in the binary.

@2666fff
Copy link

2666fff commented Jan 3, 2021

Hi jfacorro
I had the following errors, I dont know you still programming with erlang or not. Just try to ask if you can help.

** exception error: bad argument
in function io:format/3
called as io:format(<0.65.0>,"sn",
[[45,102,105,108,101,40,34,115,114,99,47,109,111,
100,47,100,97,116,97,47,115,107,105,108,108|...]])

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