1
%% ``The contents of this file are subject to the Erlang Public License,
4
%% Copyright Ericsson AB 1999-2009. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
2
7
%% Version 1.1, (the "License"); you may not use this file except in
3
8
%% compliance with the License. You should have received a copy of the
4
9
%% Erlang Public License along with this software. If not, it can be
5
%% retrieved via the world wide web at http://www.erlang.org/.
10
%% retrieved online at http://www.erlang.org/.
7
12
%% Software distributed under the License is distributed on an "AS IS"
8
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
14
%% the License for the specific language governing rights and limitations
10
15
%% under the License.
12
%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
13
%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
14
%% AB. All Rights Reserved.''
18
19
-module(erts_debug).
84
89
is_term_seen(_, []) -> false.
86
%% df(Mod) -- Disassemble Mod to file Mod.dis.
87
%% df(Mod, Func) -- Disassemble Mod:Func/Any to file Mod_Func.dis.
88
%% df(Mod, Func, Arity) -- Disassemble Mod:Func/Arity to file Mod_Func_Arity.dis.
91
%% df(Mod) -- Disassemble Mod to file Mod.dis.
92
%% df(Mod, Func) -- Disassemble Mod:Func/Any to file Mod_Func.dis.
93
%% df(Mod, Func, Arity) -- Disassemble Mod:Func/Arity to file Mod_Func_Arity.dis.
95
-type df_ret() :: 'ok' | {'error', {'badopen', module()}} | {'undef', module()}.
97
-spec df(module()) -> df_ret().
90
99
df(Mod) when is_atom(Mod) ->
91
case catch Mod:module_info(functions) of
100
try Mod:module_info(functions) of
92
101
Fs0 when is_list(Fs0) ->
93
102
Name = lists:concat([Mod, ".dis"]),
94
103
Fs = [{Mod,Func,Arity} || {Func,Arity} <- Fs0],
105
catch _:_ -> {undef,Mod}
108
-spec df(module(), atom()) -> df_ret().
100
110
df(Mod, Func) when is_atom(Mod), is_atom(Func) ->
101
case catch Mod:module_info(functions) of
111
try Mod:module_info(functions) of
102
112
Fs0 when is_list(Fs0) ->
103
Name = lists:concat([Mod,"_",Func,".dis"]),
113
Name = lists:concat([Mod, "_", Func, ".dis"]),
104
114
Fs = [{Mod,Func1,Arity} || {Func1,Arity} <- Fs0, Func1 =:= Func],
116
catch _:_ -> {undef,Mod}
119
-spec df(module(), atom(), arity()) -> df_ret().
110
121
df(Mod, Func, Arity) when is_atom(Mod), is_atom(Func) ->
111
case catch Mod:module_info(functions) of
122
try Mod:module_info(functions) of
112
123
Fs0 when is_list(Fs0) ->
113
Name = lists:concat([Mod,"_",Func,"_",Arity,".dis"]),
124
Name = lists:concat([Mod, "_", Func, "_", Arity, ".dis"]),
114
125
Fs = [{Mod,Func1,Arity1} || {Func1,Arity1} <- Fs0,
115
126
Func1 =:= Func, Arity1 =:= Arity],
128
catch _:_ -> {undef,Mod}
121
131
dff(File, Fs) when is_pid(File), is_list(Fs) ->