NAME
xref - A Cross Reference Tool for analyzing dependencies between functions, modules, applications and releases.DESCRIPTION
Xref is a cross reference tool that can be used for finding dependencies between functions, modules, applications and releases. Calls between functions are either local calls like f(), or external calls like m:f(). Module data, which are extracted from BEAM files, include local functions, exported functions, local calls and external calls. By default, calls to built-in functions (BIF) are ignored, but if the option builtins, accepted by some of this module's functions, is set to true, calls to BIFs are included as well. It is the analyzing OTP version that decides what functions are BIFs. Functional objects are assumed to be called where they are created (and nowhere else). Unresolved calls are calls to apply or spawn with variable module, variable function, or variable arguments. Examples are M:F(a), apply(M, f, [a]), and spawn(m, f(), Args). Unresolved calls are represented by calls where variable modules have been replaced with the atom '$M_EXPR', variable functions have been replaced with the atom '$F_EXPR', and variable number of arguments have been replaced with the number -1. The above mentioned examples are represented by calls to '$M_EXPR':'$F_EXPR'/1, '$M_EXPR':f/1, and m:'$F_EXPR'/-1. The unresolved calls are a subset of the external calls.Warning:
Unresolved calls make module data incomplete, which implies that the results of
analyses may be invalid.
- -deprecated({f,1}).:
- The exported function f/1 is deprecated. Nothing is said whether f/1 will be removed or not.
- -deprecated({f,1,"Use g/1 instead"}).:
- As above but with a descriptive string. The string is currently unused by xref but other tools can make use of it.
- -deprecated({f,'_'}).:
- All exported functions f/0, f/1 and so on are deprecated.
- -deprecated(module).:
- All exported functions in the module are deprecated. Equivalent to -deprecated({'_','_'})..
- -deprecated([{g,1,next_version}]).:
- The function g/1 is deprecated and will be removed in next version.
- -deprecated([{g,2,next_major_release}]).:
- The function g/2 is deprecated and will be removed in next major release.
- -deprecated([{g,3,eventually}]).:
- The function g/3 is deprecated and will eventually be removed.
- -deprecated({'_','_',eventually}).:
- All exported functions in the module are deprecated and will eventually be removed.
- *
- Expression ::= Constants
- *
- Constants ::= Consts | Consts : Type | RegExpr
- *
- Consts ::= Constant | [Constant, ...] | {Constant, ...}
- *
- Constant ::= Call | Const
- *
- Call ::= FunSpec -> FunSpec | {MFA, MFA } | AtomConst -> AtomConst | {AtomConst, AtomConst }
- *
- Const ::= AtomConst | FunSpec | MFA
- *
- AtomConst ::= Application | Module | Release
- *
- FunSpec ::= Module : Function / Arity
- *
- MFA ::= {Module, Function, Arity}
- *
- RegExpr ::= RegString : Type | RegFunc | RegFunc : Type
- *
- RegFunc ::= RegModule : RegFunction / RegArity
- *
- RegModule ::= RegAtom
- *
- RegFunction ::= RegAtom
- *
- RegArity ::= RegString | Number | _ | -1
- *
- RegAtom ::= RegString | Atom | _
- *
- RegString ::= - a regular expression, as described in the re module, enclosed in double quotes -
- *
- Type ::= Fun | Mod | App | Rel
- *
- Function ::= Atom
- *
- Application ::= Atom
- *
- Module ::= Atom
- *
- Release ::= Atom
- *
- Arity ::= Number | -1
- *
- Atom ::= - same as Erlang atoms -
- *
- Number ::= - same as non-negative Erlang integers -
- *
- Expression ::= Variable
- *
- Variable ::= - same as Erlang variables -
- E:
- Call Graph Edges (*).
- V:
- Call Graph Vertices (*).
- M:
- Modules. All modules: analyzed modules, used library modules, and unknown modules.
- A:
- Applications.
- R:
- Releases.
- ME:
- Module Edges. All module calls.
- AE:
- Application Edges. All application calls.
- RE:
- Release Edges. All release calls.
- L:
- Local Functions (*). All local functions of analyzed modules.
- X:
- Exported Functions. All exported functions of analyzed modules and all used exported functions of library modules.
- F:
- Functions (*).
- B:
- Used BIFs. B is empty if builtins is false for all analyzed modules.
- U:
- Unknown Functions.
- UU:
- Unused Functions (*). All local and exported functions of analyzed modules that have not been used.
- XU:
- Externally Used Functions. Functions of all modules - including local functions - that have been used in some external call.
- LU:
- Locally Used Functions (*). Functions of all modules that have been used in some local call.
- OL:
- Functions with an attribute tag on_load (*).
- LC:
- Local Calls (*).
- XC:
- External Calls (*).
- AM:
- Analyzed Modules.
- UM:
- Unknown Modules.
- LM:
- Used Library Modules.
- UC:
- Unresolved Calls. Empty in modules mode.
- EE:
- Inter Call Graph Edges (*).
- DF:
- Deprecated Functions. All deprecated exported functions and all used deprecated BIFs.
- DF_1:
- Deprecated Functions. All deprecated functions to be removed in next version.
- DF_2:
- Deprecated Functions. All deprecated functions to be removed in next version or next major release.
- DF_3:
- Deprecated Functions. All deprecated functions to be removed in next version, next major release, or later.
- *
- F is equal to L + X.
- *
- V is equal to X + L + B + U, where X, L, B and U are pairwise disjoint (that is, have no elements in common).
- *
- UU is equal to V - (XU + LU), where LU and XU may have elements in common. Put in another way:
- *
- V is equal to UU + XU + LU.
- *
- OL is a subset of F.
- *
- E is equal to LC + XC. Note that LC and XC may have elements in common, namely if some function is locally and externally used from one and the same function.
- *
- U is a subset of XU.
- *
- B is a subset of XU.
- *
- LU is equal to range LC.
- *
- XU is equal to range XC.
- *
- LU is a subset of F.
- *
- UU is a subset of F.
- *
- range UC is a subset of U.
- *
- M is equal to AM + LM + UM, where AM, LM and UM are pairwise disjoint.
- *
- ME is equal to (Mod) E.
- *
- AE is equal to (App) E.
- *
- RE is equal to (Rel) E.
- *
- (Mod) V is a subset of M. Equality holds if all analyzed modules have some local, exported, or unknown function.
- *
- (App) M is a subset of A. Equality holds if all applications have some module.
- *
- (Rel) A is a subset of R. Equality holds if all releases have some application.
- *
- DF_1 is a subset of DF_2.
- *
- DF_2 is a subset of DF_3.
- *
- DF_3 is a subset of DF.
- *
- DF is a subset of X + B.
- *
- Expression ::= ( Type ) Expression
- *
- Expression ::= Expression BinarySetOp Expression
- *
- BinarySetOp ::= + | * | -
- *
- Expression ::= UnarySetOp Expression
- *
- UnarySetOp ::= domain | range | strict
- *
- Expression ::= Expression RestrOp Expression
- *
- RestrOp ::= |
- *
- RestrOp ::= ||
- *
- RestrOp ::= |||
- |:
- The subset of calls from any of the vertices.
- ||:
- The subset of calls to any of the vertices.
- |||:
- The subset of calls to and from any of the vertices. For all sets of calls CS and all sets of vertices VS, CS ||| VS is equivalent to CS | VS * CS || VS.
- *
- Expression ::= Expression BinaryGraphOp Expression
- *
- Expression ::= UnaryGraphOp Expression
- *
- UnaryGraphOp ::= components | condensation
- *
- BinaryGraphOp ::= of
- *
- Expression ::= ClosureOp Expression
- *
- ClosureOp ::= closure
- *
- Expression ::= ( LineOp) Expression
- *
- Expression ::= ( XLineOp) Expression
- *
- LineOp ::= Lin | ELin | LLin | XLin
- *
- XLineOp ::= XXL
- *
- the Lin operator is defined for Call Graph Edges;
- *
- the LLin operator is defined for Local Calls.
- *
- the XLin operator is defined for External Calls.
- *
- the ELin operator is defined for Inter Call Graph Edges.
- *
- Expression ::= CountOp Expression
- *
- CountOp ::= #
- *
- +, -
- *
- *
- *
- #
- *
- |, ||, |||
- *
- of
- *
- (Type)
- *
- closure, components, condensation, domain, range, strict
- *
- Expression ::= ( Expression )
- *
- Query ::= Statement, ...
- *
- Statement ::= Assignment | Expression
- *
- Assignment ::= Variable := Expression | Variable = Expression
DATA TYPES
application() = atom()call() = {atom(), atom()} | funcall()constant() = xmfa() | module() | application() | release()directory() = atom() | file:filename()file() = file:filename()file_error() = atom()funcall() = {xmfa(), xmfa()}function_name() = atom()library() = atom()library_path() = path() | code_pathmode() = functions | modulespath() = [file()]release() = atom()string_position() = integer() >= 1variable() = atom()xarity() = arity() | -1xmfa() = {module(), function_name(), xarity()}xref() = atom() | pid()
EXPORTS
add_application(XrefServer, Directory) -> {ok, application()} | {error, module(), Reason}
add_application(XrefServer, Directory, Options) -> {ok, application()} | {error, module(), Reason}
Types:
XrefServer = xref()
Directory = directory()
Options = Option | [Option]
Option =
{builtins, boolean()} |
{name, application()} |
{verbose, boolean()} |
{warnings, boolean()} |
builtins | verbose | warnings
Reason =
{application_clash, {application(), directory(), directory()}} |
add_dir_rsn()
{builtins, boolean()} |
{name, application()} |
{verbose, boolean()} |
{warnings, boolean()} |
builtins | verbose | warnings
{application_clash, {application(), directory(), directory()}} |
add_dir_rsn()
add_dir_rsn() ={file_error, file(), file_error()} |{invalid_filename, term()} |{invalid_options, term()} |{unrecognized_file, file()} |beam_lib:chnk_rsn()
Adds an application, the modules of the application and module data of the
modules to an Xref server. The modules will be members of the application. The
default is to use the base name of the directory with the version removed as
application name, but this can be overridden by the name option.
Returns the name of the application.
If the given directory has a subdirectory named ebin, modules (BEAM
files) are searched for in that directory, otherwise modules are searched for
in the given directory.
If the mode of the Xref server is functions, BEAM files that contain no
debug information are ignored.
add_directory(XrefServer, Directory) -> {ok, Modules} | {error, module(), Reason}
add_directory(XrefServer, Directory, Options) -> {ok, Modules} | {error, module(), Reason}
Types:
XrefServer = xref()
Directory = directory()
Options = Option | [Option]
Option =
{builtins, boolean()} |
{recurse, boolean()} |
{verbose, boolean()} |
{warnings, boolean()} |
builtins | recurse | verbose | warnings
Modules = [module()]
Reason = add_dir_rsn()
{builtins, boolean()} |
{recurse, boolean()} |
{verbose, boolean()} |
{warnings, boolean()} |
builtins | recurse | verbose | warnings
add_dir_rsn() ={file_error, file(), file_error()} |{invalid_filename, term()} |{invalid_options, term()} |{unrecognized_file, file()} |beam_lib:chnk_rsn()
Adds the modules found in the given directory and the modules' data to an Xref
server. The default is not to examine subdirectories, but if the option
recurse has the value true, modules are searched for in
subdirectories on all levels as well as in the given directory. Returns a
sorted list of the names of the added modules.
The modules added will not be members of any applications.
If the mode of the Xref server is functions, BEAM files that contain no
debug information are ignored.
add_module(XrefServer, File) -> {ok, module()} | {error, module(), Reason}
add_module(XrefServer, File, Options) -> {ok, module()} | {error, module(), Reason}
Types:
XrefServer = xref()
File = file:filename()
Options = Option | [Option]
Option =
{builtins, boolean()} |
{verbose, boolean()} |
{warnings, boolean()} |
builtins | verbose | warnings
Reason = add_mod_rsn()
{builtins, boolean()} |
{verbose, boolean()} |
{warnings, boolean()} |
builtins | verbose | warnings
add_mod_rsn() ={file_error, file(), file_error()} |{invalid_filename, term()} |{invalid_options, term()} |{module_clash, {module(), file(), file()}} |{no_debug_info, file()} |beam_lib:chnk_rsn()
Adds a module and its module data to an Xref server. The module will not be
member of any application. Returns the name of the module.
If the mode of the Xref server is functions, and the BEAM file contains
no debug information, the error message no_debug_info is
returned.
add_release(XrefServer, Directory) -> {ok, release()} | {error, module(), Reason}
add_release(XrefServer, Directory, Options) -> {ok, release()} | {error, module(), Reason}
Types:
XrefServer = xref()
Directory = directory()
Options = Option | [Option]
Option =
{builtins, boolean()} |
{name, release()} |
{verbose, boolean()} |
{warnings, boolean()} |
builtins | verbose | warnings
Reason =
{application_clash, {application(), directory(), directory()}} |
{release_clash, {release(), directory(), directory()}} |
add_dir_rsn()
{builtins, boolean()} |
{name, release()} |
{verbose, boolean()} |
{warnings, boolean()} |
builtins | verbose | warnings
{application_clash, {application(), directory(), directory()}} |
{release_clash, {release(), directory(), directory()}} |
add_dir_rsn()
add_dir_rsn() ={file_error, file(), file_error()} |{invalid_filename, term()} |{invalid_options, term()} |{unrecognized_file, file()} |beam_lib:chnk_rsn()
Adds a release, the applications of the release, the modules of the
applications, and module data of the modules to an Xref server. The
applications will be members of the release, and the modules will be members
of the applications. The default is to use the base name of the directory as
release name, but this can be overridden by the name option. Returns
the name of the release.
If the given directory has a subdirectory named lib, the directories in
that directory are assumed to be application directories, otherwise all
subdirectories of the given directory are assumed to be application
directories. If there are several versions of some application, the one with
the highest version is chosen.
If the mode of the Xref server is functions, BEAM files that contain no
debug information are ignored.
analyze(XrefServer, Analysis) -> {ok, Answer} | {error, module(), Reason}
analyze(XrefServer, Analysis, Options) -> {ok, Answer} | {error, module(), Reason}
Types:
XrefServer = xref()
Analysis = analysis()
Options = Option | [Option]
Option = {verbose, boolean()} | verbose
Answer = [term()]
Reason = analyze_rsn()
analysis() =undefined_function_calls | undefined_functions |locals_not_used | exports_not_used |deprecated_function_calls |{deprecated_function_calls, DeprFlag :: depr_flag()} |deprecated_functions |{deprecated_functions, DeprFlag :: depr_flag()} |{call, FuncSpec :: func_spec()} |{use, FuncSpec :: func_spec()} |{module_call, ModSpec :: mod_spec()} |{module_use, ModSpec :: mod_spec()} |{application_call, AppSpec :: app_spec()} |{application_use, AppSpec :: app_spec()} |{release_call, RelSpec :: rel_spec()} |{release_use, RelSpec :: rel_spec()}
app_spec() = application() | [application()]
depr_flag() = next_version | next_major_release | eventually
func_spec() = xmfa() | [xmfa()]
mod_spec() = module() | [module()]
rel_spec() = release() | [release()]
analyze_rsn() ={invalid_options, term()} |{parse_error, string_position(), term()} |{unavailable_analysis, term()} |{unknown_analysis, term()} |{unknown_constant, string()} |{unknown_variable, variable()}
Evaluates a predefined analysis. Returns a sorted list without duplicates of
call() or constant(), depending on the chosen analysis. The
predefined analyses, which operate on all analyzed modules, are (analyses
marked with (*) are available in functionsmode only):
- undefined_function_calls(*):
- Returns a list of calls to undefined functions.
- undefined_functions:
- Returns a list of undefined functions.
- locals_not_used(*):
- Returns a list of local functions that have not been locally used.
- exports_not_used:
- Returns a list of exported functions that have not been externally used. Note that in modules mode, M:behaviour_info/1 is never reported as unused.
- deprecated_function_calls(*):
- Returns a list of external calls to deprecated functions.
- {deprecated_function_calls, DeprFlag}(*):
- Returns a list of external calls to deprecated functions. If DeprFlag is equal to next_version, calls to functions to be removed in next version are returned. If DeprFlag is equal to next_major_release, calls to functions to be removed in next major release are returned as well as calls to functions to be removed in next version. Finally, if DeprFlag is equal to eventually, all calls to functions to be removed are returned, including calls to functions to be removed in next version or next major release.
- deprecated_functions:
- Returns a list of externally used deprecated functions.
- {deprecated_functions, DeprFlag}:
- Returns a list of externally used deprecated functions. If DeprFlag is equal to next_version, functions to be removed in next version are returned. If DeprFlag is equal to next_major_release, functions to be removed in next major release are returned as well as functions to be removed in next version. Finally, if DeprFlag is equal to eventually, all functions to be removed are returned, including functions to be removed in next version or next major release.
- {call, FuncSpec}(*):
- Returns a list of functions called by some of the given functions.
- {use, FuncSpec}(*):
- Returns a list of functions that use some of the given functions.
- {module_call, ModSpec}:
- Returns a list of modules called by some of the given modules.
- {module_use, ModSpec}:
- Returns a list of modules that use some of the given modules.
- {application_call, AppSpec}:
- Returns a list of applications called by some of the given applications.
- {application_use, AppSpec}:
- Returns a list of applications that use some of the given applications.
- {release_call, RelSpec}:
- Returns a list of releases called by some of the given releases.
- {release_use, RelSpec}:
- Returns a list of releases that use some of the given releases.
d(Directory) -> [DebugInfoResult] | [NoDebugInfoResult] | {error, module(), Reason}
Types:
Directory = directory()
DebugInfoResult =
{deprecated, [funcall()]} |
{undefined, [funcall()]} |
{unused, [mfa()]}
NoDebugInfoResult =
{deprecated, [xmfa()]} | {undefined, [xmfa()]}
Reason =
{file_error, file(), file_error()} |
{invalid_filename, term()} |
{unrecognized_file, file()} |
beam_lib:chnk_rsn()
{deprecated, [funcall()]} |
{undefined, [funcall()]} |
{unused, [mfa()]}
{deprecated, [xmfa()]} | {undefined, [xmfa()]}
{file_error, file(), file_error()} |
{invalid_filename, term()} |
{unrecognized_file, file()} |
beam_lib:chnk_rsn()
The modules found in the given directory are checked for calls to deprecated
functions, calls to undefined functions, and for unused local functions. The
code path is used as library path.
If some of the found BEAM files contain debug information, then those modules
are checked and a list of tuples is returned. The first element of each tuple
is one of:
If no BEAM file contains debug information, then a list of tuples is returned.
The first element of each tuple is one of:
- *
- deprecated, the second element is a sorted list of calls to deprecated functions;
- *
- undefined, the second element is a sorted list of calls to undefined functions;
- *
- unused, the second element is a sorted list of unused local functions.
- *
- deprecated, the second element is a sorted list of externally used deprecated functions;
- *
- undefined, the second element is a sorted list of undefined functions.
forget(XrefServer) -> ok
forget(XrefServer, Variables) -> ok | {error, module(), Reason}
Types:
XrefServer = xref()
Variables = variable() | [variable()]
Reason = {not_user_variable, term()}
forget/1 and forget/2 remove all or some of the user variables of
an Xref server.
format_error(Error) -> io_lib:chars()
Types:
Error = {error, module(), Reason :: term()}
Given the error returned by any function of this module, the function
format_error returns a descriptive string of the error in English. For
file errors, the function file:format_error/1 is called.
get_default(XrefServer) -> [{Option, Value}]
get_default(XrefServer, Option) -> {ok, Value} | {error, module(), Reason}
Types:
XrefServer = xref()
Option = builtins | recurse | verbose | warnings
Value = boolean()
Reason = {invalid_options, term()}
Returns the default values of one or more options.
get_library_path(XrefServer) -> {ok, LibraryPath}
Types:
XrefServer = xref()
LibraryPath = library_path()
Returns the library path.
info(XrefServer) -> [Info]
info(XrefServer, Category) -> [{Item, [Info]}] | {error, module(), {no_such_info, Category}}
info(XrefServer, Category, Items) -> [{Item, [Info]}] | {error, module(), Reason}
Types:
XrefServer = xref()
Category = modules | applications | releases | libraries
Items = Item | [Item]
Item = module() | application() | release() | library()
Info = info()
Reason =
{no_such_application, Item} |
{no_such_info, Category} |
{no_such_library, Item} |
{no_such_module, Item} |
{no_such_release, Item}
{no_such_application, Item} |
{no_such_info, Category} |
{no_such_library, Item} |
{no_such_module, Item} |
{no_such_release, Item}
info() ={application, Application :: [application()]} |{builtins, boolean()} |{directory, directory()} |{library_path, library_path()} |{mode, mode()} |{no_analyzed_modules, integer() >= 0} |{no_applications, integer() >= 0} |{no_calls,{NoResolved :: integer() >= 0,NoUnresolved :: integer() >= 0}} |{no_function_calls,{NoLocal :: integer() >= 0,NoResolvedExternal :: integer() >= 0,NoUnresolved :: integer() >= 0}} |{no_functions,{NoLocal :: integer() >= 0,NoExternal :: integer() >= 0}} |{no_inter_function_calls, integer() >= 0} |{no_releases, integer() >= 0} |{release, Release :: [release()]} |{version, Version :: [integer() >= 0]}
The info functions return information as a list of pairs {Tag, term()} in
some order about the state and the module data of an Xref server.
info/1 returns information with the following tags (tags marked with (*)
are available in functions mode only):
info/2 and info/3 return information about all or some of the
analyzed modules, applications, releases or library modules of an Xref server.
The following information is returned for every analyzed module:
The following information is returned for every application:
The following information is returned for every release:
The following information is returned for every library module:
For every number of calls, functions etc. returned by the no_ tags, there
is a query returning the same number. Listed below are examples of such
queries. Some of the queries return the sum of a two or more of the no_
tags numbers. mod (app, rel) refers to any module
(application, release).
- *
- library_path, the library path;
- *
- mode, the mode;
- *
- no_releases, number of releases;
- *
- no_applications, total number of applications (of all releases);
- *
- no_analyzed_modules, total number of analyzed modules;
- *
- no_calls (*), total number of calls (in all modules), regarding instances of one function call in different lines as separate calls;
- *
- no_function_calls (*), total number of local calls, resolved external calls and unresolved calls;
- *
- no_functions (*), total number of local and exported functions;
- *
- no_inter_function_calls (*), total number of calls of the Inter Call Graph.
- *
- application, an empty list if the module does not belong to any application, otherwise a list of the application name;
- *
- builtins, whether calls to BIFs are included in the module's data;
- *
- directory, the directory where the module's BEAM file is located;
- *
- no_calls (*), number of calls, regarding instances of one function call in different lines as separate calls;
- *
- no_function_calls (*), number of local calls, resolved external calls and unresolved calls;
- *
- no_functions (*), number of local and exported functions;
- *
- no_inter_function_calls (*), number of calls of the Inter Call Graph;
- *
- directory, the directory where the modules' BEAM files are located;
- *
- no_analyzed_modules, number of analyzed modules;
- *
- no_calls (*), number of calls of the application's modules, regarding instances of one function call in different lines as separate calls;
- *
- no_function_calls (*), number of local calls, resolved external calls and unresolved calls of the application's modules;
- *
- no_functions (*), number of local and exported functions of the application's modules;
- *
- no_inter_function_calls (*), number of calls of the Inter Call Graph of the application's modules;
- *
- release, an empty list if the application does not belong to any release, otherwise a list of the release name;
- *
- version, the application's version as a list of numbers. For instance, the directory "kernel-2.6" results in the application name kernel and the application version [2,6]; "kernel" yields the name kernel and the version [].
- *
- directory, the release directory;
- *
- no_analyzed_modules, number of analyzed modules;
- *
- no_applications, number of applications;
- *
- no_calls (*), number of calls of the release's modules, regarding instances of one function call in different lines as separate calls;
- *
- no_function_calls (*), number of local calls, resolved external calls and unresolved calls of the release's modules;
- *
- no_functions (*), number of local and exported functions of the release's modules;
- *
- no_inter_function_calls (*), number of calls of the Inter Call Graph of the release's modules.
- *
- directory, the directory where the library module's BEAM file is located.
- *
- no_analyzed_modules
- *
- "# AM" (info/1)
- *
- "# (Mod) app:App" (application)
- *
- "# (Mod) rel:Rel" (release)
- *
- no_applications
- *
- "# A" (info/1)
- *
- no_calls. The sum of the number of resolved and unresolved calls:
- *
- "# (XLin) E + # (LLin) E" (info/1)
- *
- "T = E | mod:Mod, # (LLin) T + # (XLin) T" (module)
- *
- "T = E | app:App, # (LLin) T + # (XLin) T" (application)
- *
- "T = E | rel:Rel, # (LLin) T + # (XLin) T" (release)
- *
- no_functions. Functions in library modules and the functions module_info/0,1 are not counted by info. Assuming that "Extra := _:module_info/\"(0|1)\" + LM" has been evaluated, the sum of the number of local and exported functions are:
- *
- "# (F - Extra)" (info/1)
- *
- "# (F * mod:Mod - Extra)" (module)
- *
- "# (F * app:App - Extra)" (application)
- *
- "# (F * rel:Rel - Extra)" (release)
- *
- no_function_calls. The sum of the number of local calls, resolved external calls and unresolved calls:
- *
- "# LC + # XC" (info/1)
- *
- "# LC | mod:Mod + # XC | mod:Mod" (module)
- *
- "# LC | app:App + # XC | app:App" (application)
- *
- "# LC | rel:Rel + # XC | mod:Rel" (release)
- *
- no_inter_function_calls
- *
- "# EE" (info/1)
- *
- "# EE | mod:Mod" (module)
- *
- "# EE | app:App" (application)
- *
- "# EE | rel:Rel" (release)
- *
- no_releases
- *
- "# R" (info/1)
m(FileOrModule) -> [DebugInfoResult] | [NoDebugInfoResult] | {error, module(), Reason}
Types:
FileOrModule = file:filename() | module()
DebugInfoResult =
{deprecated, [funcall()]} |
{undefined, [funcall()]} |
{unused, [mfa()]}
NoDebugInfoResult =
{deprecated, [xmfa()]} | {undefined, [xmfa()]}
Reason =
{cover_compiled, Module} |
{file_error, file(), file_error()} |
{interpreted, Module} |
{invalid_filename, term()} |
{no_such_module, Module} |
beam_lib:chnk_rsn()
{deprecated, [funcall()]} |
{undefined, [funcall()]} |
{unused, [mfa()]}
{deprecated, [xmfa()]} | {undefined, [xmfa()]}
{cover_compiled, Module} |
{file_error, file(), file_error()} |
{interpreted, Module} |
{invalid_filename, term()} |
{no_such_module, Module} |
beam_lib:chnk_rsn()
The given BEAM file (with or without the .beam extension) or the file
found by calling code:which(Module) is checked for calls to deprecated
functions, calls to undefined functions, and for unused local functions. The
code path is used as library path.
If the BEAM file contains debug information, then a list of tuples is returned.
The first element of each tuple is one of:
If the BEAM file does not contain debug information, then a list of tuples is
returned. The first element of each tuple is one of:
- *
- deprecated, the second element is a sorted list of calls to deprecated functions;
- *
- undefined, the second element is a sorted list of calls to undefined functions;
- *
- unused, the second element is a sorted list of unused local functions.
- *
- deprecated, the second element is a sorted list of externally used deprecated functions;
- *
- undefined, the second element is a sorted list of undefined functions.
q(XrefServer, Query) -> {ok, Answer} | {error, module(), Reason}
q(XrefServer, Query, Options) -> {ok, Answer} | {error, module(), Reason}
Types:
XrefServer = xref()
Query = string() | atom()
Options = Option | [Option]
Option = {verbose, boolean()} | verbose
Answer = answer()
Reason = q_rsn()
answer() =false |[constant()] |[(Call :: call()) |(ComponentCall :: {component(), component()})] |[Component :: component()] |integer() >= 0 |[DefineAt :: define_at()] |[CallAt :: {funcall(), LineNumbers :: [integer() >= 0]}] |[AllLines ::{{define_at(), define_at()},LineNumbers :: [integer() >= 0]}]
define_at() = {xmfa(), LineNumber :: integer() >= 0}
component() = [constant()]
q_rsn() ={invalid_options, term()} |{parse_error, string_position(), term()} |{type_error, string()} |{type_mismatch, string(), string()} |{unknown_analysis, term()} |{unknown_constant, string()} |{unknown_variable, variable()} |{variable_reassigned, string()}
Evaluates a query in the context of an Xref server, and returns the value of the
last statement. The syntax of the value depends on the expression:
For both CallAt and AllLines it holds that for no list element is
LineNumbers an empty list; such elements have been removed. The
constants of component and the integers of LineNumbers are
sorted and without duplicates.
- *
- A set of calls is represented by a sorted list without duplicates of call().
- *
- A set of constants is represented by a sorted list without duplicates of constant().
- *
- A set of strongly connected components is a sorted list without duplicates of Component.
- *
- A set of calls between strongly connected components is a sorted list without duplicates of ComponentCall.
- *
- A chain of calls is represented by a list of constant(). The list contains the From vertex of every call and the To vertex of the last call.
- *
- The of operator returns false if no chain of calls between the given constants can be found.
- *
- The value of the closure operator (the digraph representation) is represented by the atom 'closure()'.
- *
- A set of line numbered functions is represented by a sorted list without duplicates of DefineAt.
- *
- A set of line numbered function calls is represented by a sorted list without duplicates of CallAt.
- *
- A set of line numbered functions and function calls is represented by a sorted list without duplicates of AllLines.
remove_application(XrefServer, Applications) -> ok | {error, module(), Reason}
Types:
XrefServer = xref()
Applications = application() | [application()]
Reason = {no_such_application, application()}
Removes applications and their modules and module data from an Xref
server.
remove_module(XrefServer, Modules) -> ok | {error, module(), Reason}
Types:
XrefServer = xref()
Modules = module() | [module()]
Reason = {no_such_module, module()}
Removes analyzed modules and module data from an Xref server.
remove_release(XrefServer, Releases) -> ok | {error, module(), Reason}
Types:
XrefServer = xref()
Releases = release() | [release()]
Reason = {no_such_release, release()}
Removes releases and their applications, modules and module data from an Xref
server.
replace_application(XrefServer, Application, Directory) -> {ok, Application} | {error, module(), Reason}
replace_application(XrefServer, Application, Directory, Options) -> {ok, Application} | {error, module(), Reason}
Types:
XrefServer = xref()
Application = application()
Directory = directory()
Options = Option | [Option]
Option =
{builtins, boolean()} |
{verbose, boolean()} |
{warnings, boolean()} |
builtins | verbose | warnings
Reason =
{application_clash, {application(), directory(), directory()}} |
{no_such_application, Application} |
add_dir_rsn()
{builtins, boolean()} |
{verbose, boolean()} |
{warnings, boolean()} |
builtins | verbose | warnings
{application_clash, {application(), directory(), directory()}} |
{no_such_application, Application} |
add_dir_rsn()
add_dir_rsn() ={file_error, file(), file_error()} |{invalid_filename, term()} |{invalid_options, term()} |{unrecognized_file, file()} |beam_lib:chnk_rsn()
Replaces the modules of an application with other modules read from an
application directory. Release membership of the application is retained. Note
that the name of the application is kept; the name of the given directory is
not used.
replace_module(XrefServer, Module, File) -> {ok, Module} | {error, module(), Reason}
replace_module(XrefServer, Module, File, Options) -> {ok, Module} | {error, module(), Reason}
Types:
XrefServer = xref()
Module = module()
File = file()
Options = Option | [Option]
Option =
{verbose, boolean()} |
{warnings, boolean()} |
verbose | warnings
Reason =
{module_mismatch, Module, ReadModule :: module()} |
{no_such_module, Module} |
add_mod_rsn()
{verbose, boolean()} |
{warnings, boolean()} |
verbose | warnings
{module_mismatch, Module, ReadModule :: module()} |
{no_such_module, Module} |
add_mod_rsn()
add_mod_rsn() ={file_error, file(), file_error()} |{invalid_filename, term()} |{invalid_options, term()} |{module_clash, {module(), file(), file()}} |{no_debug_info, file()} |beam_lib:chnk_rsn()
Replaces module data of an analyzed module with data read from a BEAM file.
Application membership of the module is retained, and so is the value of the
builtins option of the module. An error is returned if the name of the
read module differs from the given module.
The update function is an alternative for updating module data of
recompiled modules.
set_default(XrefServer, Option, Value) -> {ok, OldValue} | {error, module(), Reason}
set_default(XrefServer, OptionValues) -> ok | {error, module(), Reason}
Types:
XrefServer = xref()
OptionValues = OptionValue | [OptionValue]
OptionValue = {Option, Value}
Option = builtins | recurse | verbose | warnings
Value = boolean()
Reason = {invalid_options, term()}
Sets the default value of one or more options. The options that can be set this
way are:
The initial default values are set when creating an Xref server.
- *
- builtins, with initial default value false;
- *
- recurse, with initial default value false;
- *
- verbose, with initial default value false;
- *
- warnings, with initial default value true.
set_library_path(XrefServer, LibraryPath) -> ok | {error, module(), Reason}
set_library_path(XrefServer, LibraryPath, Options) -> ok | {error, module(), Reason}
Types:
XrefServer = xref()
LibraryPath = library_path()
Options = Option | [Option]
Option = {verbose, boolean()} | verbose
Reason = {invalid_options, term()} | {invalid_path, term()}
Sets the library path. If the given path is a list of directories, the set of
library modules is determined by choosing the first module encountered while
traversing the directories in the given order, for those modules that occur in
more than one directory. By default, the library path is an empty list.
The library path code_path is used by the functions m/1 and
d/1, but can also be set explicitly. Note however that the code path
will be traversed once for each used library module while setting up module
data. On the other hand, if there are only a few modules that are used but not
analyzed, using code_path may be faster than setting the library path
to code:get_path().
If the library path is set to code_path, the set of library modules is
not determined, and the info functions will return empty lists of
library modules.
start(NameOrOptions) -> {ok, pid()} | {error, {already_started, pid()}}
Types:
NameOrOptions = Name | Options
Name = atom()
Options = Option | [Option]
Option = {xref_mode, mode()} | term()
Creates an Xref server. The process may optionally be given a name. The default
mode is functions. Options that are not recognized by Xref are passed
on to gen_server:start/4.
start(Name, Options) -> {ok, pid()} | {error, {already_started, pid()}}
Types:
Name = atom()
Options = Option | [Option]
Option = {xref_mode, mode()} | term()
Creates an Xref server with a given name. The default mode is functions.
Options that are not recognized by Xref are passed on to
gen_server:start/4.
stop(XrefServer) -> stopped
Types:
XrefServer = xref()
Stops an Xref server.
update(XrefServer) -> {ok, Modules} | {error, module(), Reason}
update(XrefServer, Options) -> {ok, Modules} | {error, module(), Reason}
Types:
XrefServer = xref()
Options = Option | [Option]
Option =
{verbose, boolean()} |
{warnings, boolean()} |
verbose | warnings
Modules = [module()]
Reason =
{module_mismatch, module(), ReadModule :: module()} |
add_mod_rsn()
{verbose, boolean()} |
{warnings, boolean()} |
verbose | warnings
{module_mismatch, module(), ReadModule :: module()} |
add_mod_rsn()
add_mod_rsn() ={file_error, file(), file_error()} |{invalid_filename, term()} |{invalid_options, term()} |{module_clash, {module(), file(), file()}} |{no_debug_info, file()} |beam_lib:chnk_rsn()
Replaces the module data of all analyzed modules the BEAM files of which have
been modified since last read by an add function or update.
Application membership of the modules is retained, and so is the value of the
builtins option. Returns a sorted list of the names of the replaced
modules.
variables(XrefServer) -> {ok, [VariableInfo]}
variables(XrefServer, Options) -> {ok, [VariableInfo]}
Types:
XrefServer = xref()
Options = Option | [Option]
Option = predefined | user | {verbose, boolean()} | verbose
VariableInfo =
{predefined, [variable()]} | {user, [variable()]}
{predefined, [variable()]} | {user, [variable()]}
Returns a sorted lists of the names of the variables of an Xref server. The
default is to return the user variables only.
SEE ALSO
beam_lib(3erl), digraph(3erl), digraph_utils(3erl), re(3erl), TOOLS User's Guidetools 3.5.3 | Ericsson AB |