Dialyzer: detect problematic code in Erlang source code

badlop on Sat, 2007-08-25 11:07

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. This tool was developed in the Uppsala University, and is included in Erlang/OTP R11.

Dialyzer analyzes .beam files which where compiled with the debug_info option.

How to run Dialyzer for an Erlang module

Compile your Erlang source code file with debug_info enabled:

erlc +debug_info test.erl

Run dialyzer:

dialyzer -c test.beam

How to run Dialyzer for ejabberd trunk using Erlang/OTP R12

Clean all beam files:

make clean

Prepare ejabberd compilation:

./configure --enable-odbc --enable-pam

Compile ejabberd with debug enabled:

make debug=true
make debug=true

Create a PLT from all the OTP libraries that will be used by ejabberd. This step is optional. Note that it can take almost 2 hours and a half in a powerful machine to create this PLT! Set the paths correctly for your system. Note that evertyime you update Erlang/OTP you will need to regenerate this PLT.