Erlang程序的编译运行、崩溃分析

10095阅读 0评论2013-01-03 scq2099yt
分类:Python/Ruby

一、编译运行
    Erlang程序运行主要有三种方式:
    1、在Erlang shell中编译运行:
        c(hello).
        hello:start().
    2、在命令提示符下编译运行:
        erlc hello.erl.
        erl -noshell -s hello start -s init stop.
    3、把程序当作escript脚本来运行,无需预先编译:
        chmod u+x hello,
        ./hello。
    附注:在Erlang shell中编译.erl文件时出现错误:hello.erl:none: no such file or directory,是由于.erl文件不在Erlang当前工作目录中导致的。调用pwd()获取当前工作目录,调用c:cd("X:/your_erlang_directory")可以切换当前工作目录。

二、崩溃分析
    Erlang崩溃后会产生erl_crash.dump文件,通过webtool:start()能启动一个基于Web的崩溃分析器,用浏览器访问就可以开始详细地研究错误日志文件了。

    erlang:get_stacktrace效果类似于gdb中的bt,Linux中的coredump,Windows中的dump。


上一篇:C/C++比对Erlang
下一篇:Erlang编程模型