The |
The exref
tool is an incremental cross reference server
which builds a cross reference graph for all modules loaded into it.
Information which can be derived from the cross reference graph includes
use graphs and module dependencies.
The call graph is represented as a directed graph (see digraph(3)).
A function vertex is represented as:
{{Mod, Fun, Arity}, {Type, File, Line}}
In this code:
Type = local | exported | {exported, compiler} | {local, compiler} | {void(), record}
A call edge is represented as:
{EdgeId, {Mod1, Fun1, Arity1}, {Mod2, Fun2, Arity2}, Line}.
start()-> {ok, Pid} | {error, {already_started, Pid}}
Starts the exref
server. The exref
server must be started before
any other functions in module exref
can be used.
Stops the exref
server.
This is a short form for calling module(Module,[search,verbose])
(see below).
module(Module, Options) -> true
Module = atom() | [atom()]
Options = [Option]
Option = search | verbose | auto | warnings | recursive | no_libs
Loads the module Module
into the cross reference graph.
Module
can also be a list of modules. Options
is a
list with the following possible options:
search
X/ebin
with
the path X/src
.
verbose
auto
excludes/1
function. See also the
no_libs
option.
recursive
no_libs
option.
warnings
apply
, with
variable modules or functions, leads to an incomplete call
graph. The apply
call will be inserted into the call
graph instead of the actual call. The same applies to
spawn. no_libs
auto
and
recursive
, this
options prevents modules in the standard libraries from
being loaded into the cross reference graph.
directory(Directory)
directory(Directory, Options)
Loads all modules found in the directory Directory
into
the cross
reference graph. Options are the same as for module/2
.
The function directory/1
is equivalent to
directory(Directory,[verbose])
.
directory_module(Directory, Module)
directory_module(Directory, Module, Options)
Loads the module Module
located in the directory
Directory
. Module
can also be a list of modules.
Options are the same as for module/2
.
The function directory_module/2
is equivalent to
directory_module(Directory,Module,[verbose])
.
Deletes the module Module
from the cross reference graph.
Module
can also be a list of modules.
Appends the modules of the Modules
list to the list of modules
which
are excluded from the cross reference graph.
Appends the directories of the Dirs
list to the include search
path for Erlang include files (see epp(3)).
Appends the definitions in the Defs
list to the definition list
used by epp
(see epp(3)).
analyse(Type [,Arg]) -> Result
Performs various analyses of the cross reference graph and returns an
Erlang term with a format that depends on the Type
of analyse.
Some analyse types can have an optional argument Arg
.
The result can be formatted to a textual printout with
pretty/1
.
The available Type
and Arg
combinations are:
call
call, Module
Module
,
call, Function
Function
, which has
the format {Mod, Fun, Arity}
.
use
use, Module
Module
.
use, Function
Function
, which has
the format {Mod, Fun, Arity}
.
module_call
M1
has
calls to M2
,
this analysis emits M1: M2 ...
module_use
M1
is called by modules M2
and M3
,
the analysis emits M1: M2 M3
.
exports_not_called
locals_not_called
undefined_functions
recursive_modules
user_defined, {Mod, Fun}
exref
server process.
my_analysis(G) -> io:format("MY ANALYSIS ... ~n", Args), ...
G
is the cross reference graph as described above. The return value from a user-defined analysis is ignored.
This function pretty-prints a verbose textual representation of
AnalyseResult
which must be the output from
analyse(Type[,Arg])
. The result from a user-defined
analysis cannot be used as input to this function.
digraph(3), xref(3)