From 9f1f9179fb02fd2381e01c7960c082182176fabe Mon Sep 17 00:00:00 2001
From: xsipewe 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 is a static analysis tool that identifies software
+ discrepancies, such as definite type errors, code that has become dead
+ or unreachable because of programming error, and unnecessary tests,
+ 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). 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: Dialyzer has a command-line version for automated use. This
+ section provides a brief description of the options. The same information
+ can be obtained by writing the following in a shell: Usage: For more details about the operation of Dialyzer, see section
+ Exit status of the command-line version: No problems were found during the analysis and no warnings were
+ emitted. Problems were found during the analysis. No problems were found during the analysis, but warnings were
+ emitted. Usage: Options: * denotes that multiple occurrences of the option are possible. Options: The PLT is extended to also include the files specified with
+ This option is typically used when building or modifying a PLT as
+ in: to refer conveniently to library applications corresponding to the
+ Erlang/OTP installation. However, this option is general and can also
+ be used during analysis to refer to Erlang/OTP applications.
+ File or directory names can also be included, as in: The analysis starts from an empty PLT and creates a new one from
+ the files specified with Check the PLT for consistency and rebuild it if it is not
+ up-to-date. When analyzing from source, pass the define to Dialyzer.
+ (**) Dump the call graph into the specified file whose format is
+ determined by the filename extension. Supported extensions are:
+ Use Dialyzer from the command line to detect defects in the
+ specified files or directories containing Display the full path names of files for which warnings are
+ emitted. Make Dialyzer emit warnings even when manipulating the PLT.
+ Warnings are only emitted for files that are analyzed. Use the GUI. Print this message and exit. When analyzing from source, pass the Skip the PLT check when running Dialyzer. This is useful when
+ working with installed PLTs that never change. Bypass the native code compilation of some key files that
+ Dialyzer heuristically performs when dialyzing many files.
+ This avoids the compilation time, but can result in (much) longer
+ analysis time. By default, Dialyzer caches the results of native compilation
+ in directory When using Dialyzer from the command line, send the analysis
+ results to the specified outfile rather than to Store the PLT at the specified file after building it. Include Use the specified PLT as the initial PLT. If the PLT was built
+ during setup, the files are checked for consistency. Make Dialyzer print information about the PLT and then quit.
+ The PLT can be specified with Merge the specified PLTs to create the initial PLT. This requires
+ that the PLTs are disjoint (that is, do not have any module
+ appearing in more than one PLT).
+ The PLTs are created in the usual way: They can then be used in either of the following ways: or Notice the Make Dialyzer a bit more quiet. Same as 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 example, to filter warnings or to
+ output HTML pages). The information from the files specified with
+ Do not disable the Erlang shell while running the GUI. Override the default, which is to analyze BEAM files, and
+ analyze starting from Erlang source code instead. Print information about the progress of execution (analysis phases,
+ time spent in each, and size of the relative input). Make Dialyzer a bit more verbose. Print the Dialyzer version and some more information and
+ exit. A family of options that selectively turn on/off warnings.
+ (For help on the names of warnings, use
+ * denotes that multiple occurrences of these options are possible. ** options ** options Warning options: Warning options: Include warnings for functions that only return by an exception. Suppress warnings about behavior callbacks that drift from the
+ published recommended interfaces. Suppress warnings about invalid contracts. Suppress warnings for failing calls. Suppress warnings for fun applications that will fail. Suppress warnings for construction of improper lists. Suppress warnings for patterns that are unused or cannot match. Suppress warnings about calls to missing functions. Suppress warnings for violations of opaqueness of data types. Suppress warnings for functions that will never return a value. Suppress warnings about behaviors that have no
+ Suppress warnings for unused functions. Include warnings for possible race conditions. Notice that the
+ analysis that finds data races performs intra-procedural data flow
+ analysis and can sometimes explode in time. Enable it at your own
+ risk. Warn about underspecified functions (the specification is strictly
+ more allowing than the success typing). Let warnings about unknown functions and types affect the
+ exit status of the command-line version. The default is to ignore
+ warnings about unknown functions and types when setting the exit
+ status. When using Dialyzer from Erlang, warnings about unknown
+ functions and types are returned; the default is not to return
+ these warnings. Include warnings for function calls that ignore a structured return
+ value or do not match against one of many possible return
+ value(s). The following options are also available but their use is not
- recommended: (they are mostly for Dialyzer developers and internal
- debugging) 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 specification is strictly
+ less allowing than the success typing). Warn when the specification is different than the success typing. *** Identifies options that turn on warnings rather than
- turning them off. *** denotes options that turn on warnings rather than
+ turning them off. 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. Dialyzer can be used directly from Erlang. Both the GUI and the
+ command-line versions are also available. The options are similar to the
+ ones given from the command line, see section
+
- The Attribute
- dialyzer --help
-
- 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] [--plts plt*] [-Ddefine]*
- [-I include_dir]* [--output_plt file] [-Wwarn]* [--raw]
- [--src] [--gui] [files_or_dirs] [-r dirs]
- [--apps applications] [-o outfile]
- [--build_plt] [--add_to_plt] [--remove_from_plt]
- [--check_plt] [--no_check_plt] [--plt_info] [--get_warnings]
- [--dump_callgraph file] [--no_native] [--fullpath]
- [--statistics] [--no_native_cache]
-
- dialyzer --build_plt --apps erts kernel stdlib mnesia ...
- 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:
+dialyzer --build_plt --apps erts kernel stdlib mnesia ...
+
- dialyzer --apps inets ssl ./ebin ../other_lib/ebin/my_module.beam
- dialyzer --build_plt --output_plt plt_1 files_to_include
- ...
- dialyzer --build_plt --output_plt plt_n files_to_include
- and then can be used in either of the following ways:
+dialyzer --build_plt --output_plt plt_1 files_to_include
+...
+dialyzer --build_plt --output_plt plt_n files_to_include
+
- dialyzer files_to_analyze --plts plt_1 ... plt_n
- or:
+dialyzer files_to_analyze --plts plt_1 ... plt_n
+
- dialyzer --plts plt_1 ... plt_n -- files_to_analyze
- (Note the -- delimiter in the second case)
--dialyzer({nowarn_function, f/0}).
-
+
+-dialyzer({nowarn_function, f/0}).
+
To turn off warnings for improper lists, add the following line - to the source file: -
-
--dialyzer(no_improper_lists).
-
- The
--dialyzer([{nowarn_function, [f/0]}, no_improper_lists]).
-
- - Warning options can be restricted to functions: -
-
--dialyzer({no_improper_lists, g/0}).
-
-
--dialyzer({[no_return, no_match], [g/0, h/0]}).
-
-
- For help on the warning options use
+-dialyzer(no_improper_lists).
+
+ Attribute
+-dialyzer([{nowarn_function, [f/0]}, no_improper_lists]).
+
+ Warning options can be restricted to functions:
+ +
+-dialyzer({no_improper_lists, g/0}).
+
+
+-dialyzer({[no_return, no_match], [g/0, h/0]}).
+
+ For help on the warning options, use
- The
Attribute
- The warning option
Warning option
- The
--dialyzer(unmatched_returns).
-
- - can help in assuring that no new unmatched return warnings are - introduced. -
+ +Attribute
+-dialyzer(unmatched_returns).
Get a string from warnings as returned by
+
Dialyzer GUI version.
@@ -368,9 +504,12 @@ 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 - | {plts, [FileName :: string()]} %% If changed from default + | {from, src_code | byte_code} + %% Defaults to byte_code + | {init_plt, FileName :: string()} + %% If changed from default + | {plts, [FileName :: string()]} + %% If changed from default | {include_dirs, [DirName :: string()]} | {output_file, FileName :: string()} | {output_plt, FileName :: string()} @@ -383,76 +522,71 @@ Option :: {files, [Filename :: string()]} | {warnings, [WarnOpts]} | {get_warnings, bool()} -WarnOpts :: no_return - | no_unused - | no_improper_lists +WarnOpts :: error_handling + | no_behaviours + | no_contracts + | no_fail_call | no_fun_app + | no_improper_lists | no_match + | no_missing_calls | no_opaque - | no_fail_call - | no_contracts - | no_behaviours + | no_return | no_undefined_callbacks - | unmatched_returns - | error_handling + | no_unused | race_conditions - | overspecs | underspecs - | specdiffs - | unknown + | unknown + | unmatched_returns + | overspecs + | specdiffsDialyzer command line version.
-
-Warnings :: [{Tag, Id, Msg}]
-Tag :: 'warn_behaviour'
- | 'warn_bin_construction'
- | 'warn_callgraph'
- | 'warn_contract_not_equal'
- | 'warn_contract_range'
- | 'warn_contract_subtype'
- | 'warn_contract_supertype'
- | 'warn_contract_syntax'
- | 'warn_contract_types'
- | 'warn_failing_call'
- | 'warn_fun_app'
- | 'warn_matching'
- | 'warn_non_proper_list'
- | 'warn_not_called'
- | 'warn_opaque'
- | 'warn_race_condition'
- | 'warn_return_no_exit'
- | 'warn_return_only_exit'
- | 'warn_umatched_return'
- | 'warn_undefined_callbacks'
- | 'warn_unknown'
-Id = {File :: string(), Line :: integer()}
-Msg = msg() -- Undefined
+ Returns information about the specified PLT.
Get a string from warnings as returned by dialyzer:run/1.
-Returns information about the specified plt.
+Dialyzer command-line version.
+
+Warnings :: [{Tag, Id, Msg}]
+Tag :: 'warn_behaviour'
+ | 'warn_bin_construction'
+ | 'warn_callgraph'
+ | 'warn_contract_not_equal'
+ | 'warn_contract_range'
+ | 'warn_contract_subtype'
+ | 'warn_contract_supertype'
+ | 'warn_contract_syntax'
+ | 'warn_contract_types'
+ | 'warn_failing_call'
+ | 'warn_fun_app'
+ | 'warn_matching'
+ | 'warn_non_proper_list'
+ | 'warn_not_called'
+ | 'warn_opaque'
+ | 'warn_race_condition'
+ | 'warn_return_no_exit'
+ | 'warn_return_only_exit'
+ | 'warn_umatched_return'
+ | 'warn_undefined_callbacks'
+ | 'warn_unknown'
+Id = {File :: string(), Line :: integer()}
+Msg = msg() -- Undefined
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.
-In the "File" window you will find a listing of the current directory. - Click your way to the directories/modules you want to add or type the - correct path in the entry.
-Mark the directories/modules you want to analyze for discrepancies and
- click "Add". You can either add the
Dialyzer is a static analysis tool that identifies software + discrepancies, such as definite type errors, code that has become dead + or unreachable because of programming error, and unnecessary tests, + in single Erlang modules or entire (sets of) applications.
+ +Dialyzer can be called from the command line, from Erlang, + and from a GUI.
Dialyzer has two modes of analysis, "Byte Code" or "Source Code". - These are controlled by the buttons in the top-middle part of the - main window, under "Analysis Options".
-Under the "Warnings" pull-down menu, there are buttons that control - which discrepancies are reported to the user in the "Warnings" window. - By clicking on these buttons, one can enable/disable a whole class of - warnings. Information about the classes of warnings can be found on - the "Warnings" item under the "Help" menu (at the rightmost top corner).
-If modules are compiled with inlining, spurious warnings may be emitted. - In the "Options" menu you can choose to ignore inline-compiled modules - when analyzing byte code. When starting from source code this is not a - problem since the inlining is explicitly turned off by Dialyzer. The - option causes Dialyzer to suppress all warnings from inline-compiled - modules, since there is currently no way for Dialyzer to find what - parts of the code have been produced by inlining.
+It is assumed that the reader is familiar with the Erlang programming + language.
Once you have chosen the modules or directories you want to analyze, - click the "Run" button to start the analysis. If for some reason you - want to stop the analysis while it is running, push the "Stop" button.
-The information from the analysis will be displayed in the Log and the - Warnings windows.
-Dialyzer stores the result of an analysis in a Persistent + Lookup Table (PLT). The PLT can then be used as a starting + point for later analyses. It is recommended to build a PLT with the + Erlang/OTP applications that you are using, but also to include your + own applications that you are using frequently.
+ +The PLT is built using option
When analyzing from source you might have to supply Dialyzer with a
- list of include directories and macro definitions (as you can do with
- the
+
+dialyzer --build_plt --apps erts kernel stdlib mnesia
- dialyzer -I my_includes -DDEBUG -Dvsn=42 -I one_more_dir
-
- or by adding these explicitly using the "Manage Macro Definitions" or - "Manage Include Directories" sub-menus in the "Options" menu.
-Dialyzer looks if there is an environment variable called
+
In the "File" menu there are options to save the contents of the Log - and the Warnings window. Just choose the options and enter the file to - save the contents in.
-There are also buttons to clear the contents of each window.
-Information can be added to an existing PLT using option
+
Dialyzer stores the information of the analyzed functions in a - Persistent Lookup Table (PLT). After an analysis you can inspect this - information. In the PLT menu you can choose to either search the PLT - or inspect the contents of the whole PLT. The information is presented - in edoc format.
-
+dialyzer --add_to_plt --apps compiler --output_plt my.plt
- See
Then you can add your favorite application my_app to the new + PLT:
-See
+dialyzer --add_to_plt --plt my.plt -r my_app/ebin
- But you realize that it is unnecessary to have the Erlang compiler in this + one:
-The persistent lookup table, or PLT, is used to store the - result of an analysis. The PLT can then be used as a starting - point for later analyses. It is recommended to build a PLT with - the otp applications that you are using, but also to include your - own applications that you are using frequently.
+
+dialyzer --remove_from_plt --plt my.plt --apps compiler
- The PLT is built using the --build_plt option to dialyzer. The - following command builds the recommended minimal PLT for OTP.
+Later, when you have fixed a bug in your application my_app, + you want to update the PLT so that it becomes fresh the next time + you run Dialyzer. In this case, run the following command:
+dialyzer --check_plt --plt my.plt
- dialyzer --build_plt -r $ERL_TOP/lib/stdlib/ebin\
- $ERL_TOP/lib/kernel/ebin \
- $ERL_TOP/lib/mnesia/ebin
-
+ Dialyzer then reanalyzes the changed files
+ and the files that depend on these files. Notice that this
+ consistency check is performed automatically the next time you
+ run Dialyzer with this PLT. Option
Dialyzer will look if there is an environment variable called - $DIALYZER_PLT and place the PLT at this location. If no such - variable is set, Dialyzer will place the PLT at - $HOME/.dialyzer_plt. The placement can also be specified using the - --plt, or --output_plt options.
- -You can also add information to an existing plt using the - --add_to_plt option. Suppose you want to also include the compiler - in the PLT and place it in a new PLT, then give the command
+To get information about a PLT, use the following option:
+dialyzer --plt_info
- dialyzer --add_to_plt -r $ERL_TOP/lib/compiler/ebin --output_plt my.plt
-
+ To specify which PLT, use option
Then you would like to add your favorite application my_app to - the new plt.
+To get the output printed to a file, use option
+ Notice that when manipulating the PLT, no warnings are
+ emitted. To turn on warnings during (re)analysis of the PLT, use
+ option --get_warnings .
+
Dialyzer has a command-line version for automated use.
+ See
But you realize that it is unnecessary to have compiler in this one.
+Dialyzer can also be used directly from Erlang.
+ See
+
+
+ Using Dialyzer from the GUI
+
+ Choosing the Applications or Modules
+ The File window displays a listing of the current directory.
+ Click your way to the directories/modules you want to add or type the
+ correct path in the entry.
- dialyzer --remove_from_plt --plt my.plt -r $ERL_TOP/lib/compiler/ebin
-
+ Mark the directories/modules you want to analyze for discrepancies and
+ click Add. You can either add the
Later, when you have fixed a bug in your application my_app, - you want to update the plt so that it will be fresh the next time - you run Dialyzer, run the command
+Dialyzer has two analysis modes: "Byte Code" and "Source Code". + They are controlled by the buttons in the top-middle part of the + main window, under Analysis Options.
+
+
+ Controlling the Discrepancies Reported by Dialyzer
+ Under the Warnings pull-down menu, there are buttons that
+ control which discrepancies are reported to the user in the
+ Warnings window. By clicking these buttons, you can
+ enable/disable a whole class of warnings. Information about the classes
+ of warnings is found on the "Warnings" item under the Help
+ menu (in the rightmost top corner).
+
+ If modules are compiled with inlining, spurious warnings can be
+ emitted. In the Options menu you can choose to ignore
+ inline-compiled modules when analyzing byte code.
+ When starting from source code, this is not a problem because
+ inlining is explicitly turned off by Dialyzer. The option causes
+ Dialyzer to suppress all warnings from inline-compiled
+ modules, as there is currently no way for Dialyzer to find what
+ parts of the code have been produced by inlining.
+
- dialyzer --check_plt --plt my.plt
-
+ Once you have chosen the modules or directories you want to analyze, + click the Run button to start the analysis. If you for some + reason want to stop the analysis while it is running, click the + Stop button.
-Dialyzer will then reanalyze the files that have been changed, - and the files that depend on these files. Note that this - consistency check will be performed automatically the next time - you run Dialyzer with this plt. The --check_plt option is merely - for doing so without doing any other analysis.
+The information from the analysis is displayed in the Log + window and the Warnings window.
+To get some information about a plt use the option
-
+
+ Include Directories and Macro Definitions
+ When analyzing from source, you might have to supply Dialyzer
+ with a list of include directories and macro definitions (as you can do
+ with the erlc flags
+ -I and -D ). This can be done
+ either by starting Dialyzer with these flags from the command
+ line as in:
+
+
+dialyzer -I my_includes -DDEBUG -Dvsn=42 -I one_more_dir
- dialyzer --plt_info
-
+ or by adding these explicitly using submenu + Manage Macro Definitions or + Manage Include Directories in the Options menu.
+ -You can also specify which plt with the --plt option, and get the - output printed to a file with --output_file
+The File menu includes options to save the contents of the + Log window and the Warnings window. Simply choose the + options and enter the file to save the contents in.
-Note that when manipulating the plt, no warnings are - emitted. To turn on warnings during (re)analysis of the plt, use - the option --get_warnings.
+There are also buttons to clear the contents of each window.
+Dialyzer stores the information of the analyzed functions in a
+ Persistent Lookup Table (PLT), see section
+
After an analysis, you can inspect this information.
+ In the PLT menu you can choose to either search the PLT
+ or inspect the contents of the whole PLT. The information is presented
+ in
At this point, we very much welcome user feedback (even wish-lists!). - If you notice something weird, especially if the Dialyzer reports any - discrepancy that is a false positive, please send an error report - describing the symptoms and how to reproduce them to:
-
+ We very much welcome user feedback - even wishlists! + If you notice anything weird, especially if Dialyzer reports + any discrepancy that is a false positive, please send an error report + describing the symptoms and how to reproduce them.
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 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.