[Ericsson AB]





The Dialyzer, a DIscrepancy AnalYZer for ERlang programs


The Dialyzer is a static analysis tool that identifies software discrepancies such as type errors, unreachable code, unnecessary tests, etc in single Erlang modules or entire (sets of) applications. Currently, Dialyzer starts its analysis from either BEAM bytecode or from Erlang source code and reports to its user the functions where the discrepancies occur and an indication of what the discrepancy is about. Dialyzer currently supports various modes of operation and its analysis is precise (in particular, there are no false positives) and quite fast.

Read more about Dialyzer and about how to use it from the GUI in Dialyzer User's Guide.

Using the Dialyzer from the command line

Dialyzer also has a command line version for automated use. Below is a brief description of the list of its options. The same information can be obtained by writing

      dialyzer --help

in a shell. Please refer to the GUI description for more details on the operation of Dialyzer.

The exit status of the command line version is:

      0 - No problems were encountered during the analysis and no
          warnings were emitted.
      1 - Problems were encountered during the analysis.
      2 - No problems were encountered, but warnings were emitted.


      dialyzer [--help] [--version] [--shell] [--quiet] [--verbose]
               [-pa dir]* [-plt plt] [-Ddefine]* [-I include_dir]* 
               [--output_plt file] [-Wwarn]*  [--src] 
               [-c applications] [-r applications] [-o outfile]


-c applications(or --command-line applications)
use Dialyzer from the command line (no GUI) to detect defects in the specified applications (directories or .erl or .beam files)
-r applications
same as -c only that directories are searched recursively for subdirectories containing .erl or .beam files (depending on the type of analysis)
-o outfile(or --output outfile)
when using Dialyzer from the command line, send the analysis results in the specified outfile rather than in stdout
overwrite the default, which is to analyze BEAM bytecode, and analyze starting from Erlang source code instead
-Dname(or -Dname=value)
when analyzing from source, pass the define to Dialyzer (**)
-I include_dir
when analyzing from source, pass the include_dir to Dialyzer (**)
-pa dir
Include dir in the path for Erlang. Useful when analyzing files that have -include_lib() directives.
--output_plt file
Store the plt at the specified location after building it.
Suppress warnings when analyzing an inline compiled bytecode file.
-plt plt
Use the specified plt as the initial plt. If the plt was built during setup the files will be checked for consistency.
a family of option which selectively turn on/off warnings. (for help on the names of warnings use dialyzer -Whelp)
Only checks if the init plt is up to date. For installed systems this also forces the rebuilding of the plt if this is not the case.
do not disable the Erlang shell while running the GUI
--version (or -v)
prints the Dialyzer version and some more information and exits
--help (or -h)
prints this message and exits
--quiet (or -q)
makes Dialyzer a bit more quiet
makes Dialyzer a bit more verbose
Makes Dialyzer use dataflow analysis to find discrepancies. (Default)
Makes Dialyzer use success typings to find discrepancies.

* denotes that multiple occurrences of these options are possible.

** options -D and -I work both from command-line and in the Dialyzer GUI; the syntax of defines and includes is the same as that used by erlc.

Warning options:

Suppress warnings for functions of no return.
Suppress warnings for unused functions.
Suppress warnings for construction of improper lists.
Suppress warnings for using tuples instead of funs.
Suppress warnings for fun applications that will fail.
Suppress warnings for pattern matching operations that will never succeed.
Suppress warnings for term comparisons that will always return false.
Suppress warnings for guards that will always fail.
Suppress warnings for unsafe BEAM code produced by an old BEAM compiler.
Include warnings for functions that only return by means of an exception.

*** This is the only option that turns on warnings rather than turning them off.

Using the Dialyzer from Erlang

You can also use Dialyzer directly from Erlang. Both the gui and the command line version is available. The options are similar to the ones given from the command line, so please refer to the sections above for a description of these.


gui() -> ok | {error, Msg}
gui(OptList) -> ok | {error, Msg}


OptList -- see below

Dialyzer GUI version.

OptList  : [Option]
Option   : {files,          [Filename : string()]}
         | {files_rec,      [DirName : string()]}
         | {defines,        [{Macro: atom(), Value : term()}]}
         | {from,           src_code | byte_code} %% Defaults to byte_code
         | {init_plt,       FileName : string()}  %% If changed from default
         | {include_dirs,   [DirName : string()]} 
         | {output_file,    FileName : string()}
         | {supress_inline, bool()}               %% Defaults to true
         | {warnings,       [WarnOpts]}

WarnOpts : no_return
         | no_unused
         | no_improper_lists
         | no_tuple_as_fun
         | no_fun_app
         | no_match
         | no_comp
         | no_guards
         | no_unsafe_beam
         | no_fail_call
         | error_handling

run(OptList) -> {ok, Warnings, Errors} | {ok, Warnings} | {error, Message}


OptList -- see gui/0,1
Warnings = [{MFA, string()}]
 MFA = {Module, Function, Arity}
  Module = Function = atom()
  Arity = int()
Errors = string()
Message = string()

Dialyzer command line version.

dialyzer 1.7.1
Copyright © 1991-2007 Ericsson AB