20062013 Ericsson AB. All Rights Reserved. The contents of this file are subject to the Erlang Public License, Version 1.1, (the "License"); you may not use this file except in compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. dialyzer
dialyzer The Dialyzer, a DIscrepancy AnalYZer for ERlang programs

The Dialyzer is a static analysis tool that identifies software discrepancies such as definite type errors, code which has become dead or unreachable due to some programming error, 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

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:

Usage:

Options:

(for backwards compatibility also as: Use Dialyzer from the command line to detect defects in the specified files or directories containing or files, depending on the type of the analysis. Same as the previous but the specified directories are searched recursively for subdirectories containing or files in them, depending on the type of analysis. Option typically used when building or modifying a plt as in: to conveniently refer to library applications corresponding to the Erlang/OTP installation. However, the option is general and can also be used during analysis in order to refer to Erlang/OTP applications. In addition, file or directory names can also be included, as in: (or ) When using Dialyzer from the command line, send the analysis results to the specified outfile rather than to stdout. When using Dialyzer from the command line, output the raw analysis results (Erlang terms) instead of the formatted result. The raw format is easier to post-process (for instance, to filter warnings or to output HTML pages). Override the default, which is to analyze BEAM files, and analyze starting from Erlang source code instead. (or ) When analyzing from source, pass the define to Dialyzer. (**) When analyzing from source, pass the to Dialyzer. (**) Include in the path for Erlang (useful when analyzing files that have directives). Store the plt at the specified file after building it. Use the specified plt as the initial plt (if the plt was built during setup the files will be checked for consistency). Merge the specified plts to create the initial plt -- requires that the plts are disjoint (i.e., do not have any module appearing in more than one plt). The plts are created in the usual way: and then can be used in either of the following ways: or: (Note the -- delimiter in the second case) A family of options which selectively turn on/off warnings (for help on the names of warnings use ). Do not disable the Erlang shell while running the GUI. (or ) Print the Dialyzer version and some more information and exit. (or ) Print this message and exit. (or ) Make Dialyzer a bit more quiet. Make Dialyzer a bit more verbose. Prints information about the progress of execution (analysis phases, time spent in each and size of the relative input). The analysis starts from an empty plt and creates a new one from the files specified with and . Only works for beam files. Use or to override the default plt location. The plt is extended to also include the files specified with and . Use to specify which plt to start from, and to specify where to put the plt. Note that the analysis might include files from the plt if they depend on the new files. This option only works with beam files. The information from the files specified with and is removed from the plt. Note that this may cause a re-analysis of the remaining dependent files. Check the plt for consistency and rebuild it if it is not up-to-date. Skip the plt check when running Dialyzer. Useful when working with installed plts that never change. Make Dialyzer print information about the plt and then quit. The plt can be specified with . Make Dialyzer emit warnings even when manipulating the plt. Warnings are only emitted for files that are actually analyzed. Dump the call graph into the specified file whose format is determined by the file name extension. Supported extensions are: raw, dot, and ps. If something else is used as file name extension, default format '.raw' will be used. (or ) Bypass the native code compilation of some key files that Dialyzer heuristically performs when dialyzing many files; this avoids the compilation time but it may result in (much) longer analysis time. Display the full path names of files for which warnings are emitted. Use the GUI.

* denotes that multiple occurrences of these options are possible.

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

Warning options:

Suppress warnings for functions that will never return a value. 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 patterns that are unused or cannot match. Suppress warnings for violations of opaqueness of data types. Suppress warnings about behaviour callbacks which drift from the published recommended interfaces. *** Include warnings for function calls which ignore a structured return value or do not match against one of many possible return value(s). *** Include warnings for functions that only return by means of an exception. *** Include warnings for possible race conditions. *** Warn about underspecified functions (the -spec is strictly more allowing than the success typing).

The following options are also available but their use is not recommended: (they are mostly for Dialyzer developers and internal debugging)

*** Warn about overspecified functions (the -spec is strictly less allowing than the success typing). *** Warn when the -spec is different than the success typing.

*** Identifies options that turn 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 versions are 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} Dialyzer GUI version OptList -- see below

Dialyzer GUI version.

run(OptList) -> Warnings Dialyzer command line version OptList -- see gui/0,1 Warnings -- see below

Dialyzer command line version.

format_warning(Msg) -> string() Get the string version of a warning message. Msg = {Tag, Id, msg()} -- See run/1

Get a string from warnings as returned by dialyzer:run/1.

plt_info(string()) -> {'ok', [{atom(), any()}]} | {'error', atom()} Returns information about the specified plt.

Returns information about the specified plt.