Beam files, module beam_lib and source code

Robert Virding rv@REDACTED
Wed Jan 24 15:39:39 CET 2001


Try:

> {ok, {_,[{_,{_,Forms}}]}} = beam_lib:chunks(YourBeamFile,[abstract_code]).
...
> lists:foreach(fun(F) -> io:put_chars(user,[erl_pp:form(F),"\n"]) end, Forms).

<Your erlang program will be written out>

To help the debugger the source code in abstract form can be included in
the beam file.  Unfortunately the default is to include it.  Giving 
the option 'no_debug_info' causes the compiler to not include the code.

While it is very nice to have a debugger I don't think source should be
included as default.  Here is a little patch to compile.erl which
inverts this behaviour, the default is to NOT include the source and you
must give the option 'debug_info' to include source.

*** compile.erl~        Wed Jan 24 14:40:36 2001
--- compile.erl Wed Jan 24 15:05:16 2001
***************
*** 335,341 ****
       {iff,dexp,{listing,"expand"}},
       {iff,'E',{src_listing,"E"}},
       {iff,'abstr',{listing,"abstr"}},
!      {unless,no_debug_info,?pass(save_abstract_code)},
  
       %% Core Erlang passes.
       {pass,v3_core},
--- 335,341 ----
       {iff,dexp,{listing,"expand"}},
       {iff,'E',{src_listing,"E"}},
       {iff,'abstr',{listing,"abstr"}},
!      {iff,debug_info,?pass(save_abstract_code)},
  
       %% Core Erlang passes.
       {pass,v3_core},

Apply the patch to lib/compiler/src/compile.erl and remake.

	Robert





More information about the erlang-questions mailing list