[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. Dialyzer starts its analysis from either debug-compiled BEAM bytecode or from Erlang source code. The file and line number of a discrepancy is reported along with an indication of what the discrepancy is about. Dialyzer bases its analysis on the concept of success typings which allows for sound warnings (no false positives).

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
overide the default, which is to analyze debug compiled 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

* 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 fun applications that will fail.
Suppress warnings for pattern matching operations that will never succeed.
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_fun_app
         | no_match
         | no_fail_call
         | error_handling

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


OptList -- see gui/0,1
Warnings -- see below
Errors = [string()]
Message = string()

Dialyzer command line version.

Warnings :: [{Tag, Id, Msg}]
Tag : 'warn_return_no_exit' | 'warn_return_only_exit'
         | 'warn_not_called' | 'warn_non_proper_list'
         | 'warn_fun_app' | 'warn_matching'
         | 'warn_failing_call' | 'warn_contract_types'
         | 'warn_contract_syntax' | 'warn_contract_not_equal'
         | 'warn_contract_subtype' | 'warn_contract_supertype'
Id = {File :: string(), Line :: integer()}
Msg = msg() -- To be used as an argument to dialyzer:format_warning/1

format_warning(Msg) -> string()


Msg = msg() -- See run/1

Get a string from the message part of the warning as returned by dialyzer:run/1.

dialyzer 1.8.0
Copyright © 1991-2008 Ericsson AB