dialyzer命令

Dialyzer是erlang指定的静态分析工具,可在运行之前发现 很多低级或者隐藏的错误。

1.命令行使用dialyzer 

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]
命令选项
 --files_or_dirs(向后兼容使用:-c files_or_dirs)
	该命令用于指定分析的文件或包含.beam 或.erl文件(具体依赖于指定的文件类型)的目录。该命令不包含子目录中的文件。
 -r dirs
	跟上一个命令类似,用于指定分析的文件或包含.beam 或.erl文件(具体依赖于指定的文件类型)的目录,但是该命令会递归子目录。
 --apps applications
	当创建或者修改plt时方便指定Erlang/OTP应用库,如  dialyzer --build_plt --apps erts kernel stdlib mnesia ... ;也可以在分析是指定Erlang/OTP应用库,也可以指定文件或目录。如  dialyzer --apps inets ssl ./ebin ../other_lib/ebin/my_module.beam
 -o outfile (or --output outfile)
	     在使用dialyzer命令时指定将结果输出到指定文件中。
 --raw
 输出原始的分析结果(erlang term),原始的输出更容易用于后处理(如过滤警告或者输出到网页上)。
 --src
 分析erlang源文件(.erl),默认情况是分析.beam文件。
 -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
	指定plt输出文件名
 --plt plt
	指定初始plt
 --plts plt*
	合并指定的plts,生产初始的plt,要求这些plt不相交(任何模块都只能出现在一个plt中)。这些plt用常规的方法创建的
	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 --plts plt_1 ... plt_n -- files_to_analyze
(注意第二种情况下用分隔符 --)
 -Wwarn
	一个可选可以关闭或打开警告(可以这么用 dialyzer -Whelp)。
 --shell
 不禁用erlang shell在运行GUI时。
 --version (or -v)
  输出dialyzer版本已经更多的信息,然后退出。
 --help (or -h) 
 数据帮助信息,然后 退出。

 
 
  
   --quiet (or -q)
 
 
 
 
Make Dialyzer a bit more quiet.
--verbose
Make Dialyzer a bit more verbose. --statistics
 输出执行进度信息(分析阶段,每个相应输出话费时间)。
 --build_plt
 从指定的文件(用-c 或 -r)创建一个新的plt,文件只能是.beam文件。用--plt or --output_plt覆盖默认的plt。
 --add_to_plt
 扩展plt 通过-c or -r 指定的文件。用 --plt指定plt起始,--output_plt指定输出。该选项只能使用beam文
 --remove_from_plt
	从已有的plt中删除应用。
 --check_plt
	检查plt的一致性,如果不是最新的重建它。
 --no_check_plt
	在执行dialyzer时跳过检查plt,在安装的plts没用变化时很有用。
 --plt_info
	打印plt信息,plt可以通过 --plt(s)指定。
 --get_warnings
 Make Dialyzer emit warnings even when manipulating the plt. Warnings are only emitted for files that are actually analyzed.       
 --dump_callgraph file
	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.
 --no_native (or -nn)
  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.
 --fullpath
 打印出发出警告文件的完整路径。
 --gui
 使用GUI
Warning options:
 -Wno_return
	不产生 函数没有返回值的警告
 -Wno_unused
 产生无用的函数警告
 -Wno_improper_lists
 不产生构建一个不当的lists警告
 -Wno_fun_app
 不产生警告应用将会失败
 -Wno_match
 不产生模式不匹配警告
 -Wno_opaque
	Suppress warnings for violations of opaqueness of data types.
 -Wno_fail_call
 不产生失败的call警告
 -Wno_contracts
 Suppress warnings about invalid contracts.
 -Wno_behaviours
 Suppress warnings about behaviour callbacks which drift from the published recommended interfaces.
 不产生行为回调函数实现与模板不一致警告
 -Wno_undefined_callbacks 
 不产生没有实现行为的回调函数警告
 -Wunmatched_returns***
 Include warnings for function calls which ignore a structured return value or do not match against one of many possible return value(s).
 -Werror_handling***
 Include warnings for functions that only return by means of an exception.
 -Wrace_conditions*** 
 Include warnings for possible race conditions. 
 -Wunderspecs***
  Warn about underspecified functions (the -spec is strictly more allowing than the success typing). 
以下选项可用,但是不建议使用。

 
 
  
  -Woverspecs***
 
 
 
 
  
  		Warn about overspecified functions (the -spec is strictly less allowing than the success typing).
 
 
 
 
  
  -Wspecdiffs***
 
 
 
 
Warn when the -spec is different than the success typing.
2.程序中使用Dialyzer	
	你也可以直接在erlang中使用Dialyzer,无论是GUI还是命令行。选项类似于命令行给出的,所以请参阅上述部分。

EXPORTS

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

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

run(OptList)-> Warnings

format_warning(Msg)->string()
	
plt_info(sring())->{'ok',[{atom(),any()}]} | {'error',atom()}
 
以上翻译仅供参考。
具体信息请查阅文档http://www.erlang.org/doc/man/dialyzer.html


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值