diff options
author | Lukas Larsson <[email protected]> | 2017-11-20 10:32:25 +0100 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2017-11-20 10:32:25 +0100 |
commit | 3b5fced77873fa6ee87a81a6162acf9d9f43c6de (patch) | |
tree | 44c92f6f39660dfef847c303b20fd260c6cd0f84 /lib/compiler/src | |
parent | f977d258d3e69da8ce0549f0a7bc3d8d9ccf82a6 (diff) | |
parent | d8d07a7593d811a6adad060951bc425ee0d81446 (diff) | |
download | otp-3b5fced77873fa6ee87a81a6162acf9d9f43c6de.tar.gz otp-3b5fced77873fa6ee87a81a6162acf9d9f43c6de.tar.bz2 otp-3b5fced77873fa6ee87a81a6162acf9d9f43c6de.zip |
Merge branch 'lukas/compiler/add_to_dis/OTP-14784' into maint
* lukas/compiler/add_to_dis/OTP-14784:
compiler: Add +to_dis option that dumps loaded asm
Diffstat (limited to 'lib/compiler/src')
-rw-r--r-- | lib/compiler/src/beam_listing.erl | 14 | ||||
-rw-r--r-- | lib/compiler/src/compile.erl | 6 |
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/compiler/src/beam_listing.erl b/lib/compiler/src/beam_listing.erl index 94b47cf568..836378727b 100644 --- a/lib/compiler/src/beam_listing.erl +++ b/lib/compiler/src/beam_listing.erl @@ -24,6 +24,7 @@ -include("core_parse.hrl"). -include("v3_kernel.hrl"). -include("v3_life.hrl"). +-include("beam_disasm.hrl"). -import(lists, [foreach/2]). @@ -59,6 +60,19 @@ module(Stream, {Mod,Exp,Attr,Code,NumLabels}) -> [Name, Arity, Entry]), io:put_chars(Stream, format_asm(Asm)) end, Code); +module(Stream, Code) when is_binary(Code) -> + #beam_file{ module = Module, compile_info = CInfo } = beam_disasm:file(Code), + Loaded = code:is_loaded(Module), + Sticky = code:is_sticky(Module), + [code:unstick_mod(Module) || Sticky], + + {module, Module} = code:load_binary(Module, proplists:get_value(source, CInfo), Code), + ok = erts_debug:df(Stream, Module), + + %% Restore loaded module + _ = [{module, Module} = code:load_file(Module) || Loaded =/= false], + [code:stick_mod(Module) || Sticky], + ok; module(Stream, [_|_]=Fs) -> %% Form-based abstract format. foreach(fun (F) -> io:format(Stream, "~p.\n", [F]) end, Fs). diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index aa2d224bb4..50b0ba76f8 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -787,8 +787,10 @@ asm_passes() -> | binary_passes()]. binary_passes() -> - [{native_compile,fun test_native/1,fun native_compile/2}, - {unless,binary,?pass(save_binary,not_werror)}]. + [{iff,'to_dis',{listing,"dis"}}, + {native_compile,fun test_native/1,fun native_compile/2}, + {unless,binary,?pass(save_binary,not_werror)} + ]. %%% %%% Compiler passes. |