4 The Cross-Reference Tool
4.1 The Cross-Reference Tool (exref)
exref
is an incremental cross reference tool which builds a cross reference graph for selected modules. Information such as module dependencies and usage graphs can be derived from the cross reference graph produced byexref
.A function vertex is represented as:
.
{{Mod, Fun, Arity}, {Type, File, Line}}In this representation, the
Type
argument equals:local | exported | {exported, compiler} | {local, compiler} | {Void(), record}A call edge is represented as:
{EdgeId, {Mod1, Fun1, Arity1}, {Modd2, Fun2, Arity2}, Line}The following functions are available for configuring and using the cross reference tool:
start() -> {ok, Pid} | {error, {already_started, Pid}}
starts theexref
server. The server must be started before any other functions in moduleexref
can be used.stop() -> stopped
stops theexref
server.module(Module) -> true
loads the specified module, or modules, into the cross reference graph.module(Module, Options) -> true
loads the moduleModule
into the cross reference graph.Module
may also be a list of modules. Type can be any of the following:
module = atom() | [atom()]
Options = [Option]
, whereOption = search | verbose | auto | warnings | recursive
, where
search
searches for source file in code path and replaces the pathX/ebin
withX/src
.verbose
creates an output of module names during loading.auto
includes all referenced modules in the graph, with the exception of modules listed in the excludes(Modules) function shown below.warnings
emits warnings about the application and the spawning of variables. The reason for this is thatapply
calls lead to an incomplete graph for variable modules or functions. Theapply
call is inserted into the graph instead of the actual call. The same applies tospawn
.recursive
recursively includes all files in a directory.directory(Directory)
loads all modules in a directory into the cross reference graph.directory(Directory, Module)
loads specific modules from a directory other than the current directory into the cross reference graph.directory(Directory, Module, Options)
loads specific modules from a directory other than the current directory into the cross reference graph.delete_module(Module)
deletes a module from the cross reference path.Module
can be a list of modules.excludes(Modules)
excludes a module, or list of modules, from the cross reference path.includes(Dirs)
specifies where to search for Erlanginclude
files.defs(Defs)
adds definitions to be used when processing source code. This function appends the definitions specified withDefs
to the definition list used byerl_pp
.analyse(Type [,Arg]) -> Result
analyses the cross reference graph and returns an Erlang term of a format which depends on theType
specified. The result from this analysis can be pretty printed with thepretty/1
function listed below. Some ofType
can have optional arguments. Refer to the Reference Manual, the sectiontools
, moduleexref
for details.pretty(AnalyseResult) -> ok
prints a verbose textual representation of the analysis result produced by theanalyse/2
function shown above. The result produced from a user defined analysis cannot be used as input to this function.