find out which line my Erlang program crash

litao同学告诉我的:

The run-time system's error reports tell you which function crashed, but not the line number. Consider this module:

        -module(crash).
        -export([f/0]).

        f() ->
          g().

        g() ->
          A = 4,
          b = 5,  % Error is on this line.
          A.
       

        3> crash:f().
        ** exited: {{badmatch,5},[{crash,g,0},{shell,exprs,6},{shell,eval_loop,3}]} **
       

The crash message tells us that the crash was in the function crash:g/1, and that it was a badmatch. For programs with short functions, this is enough information for an experienced programmer to find the problem.

In cases where you want more information, there are two options. The first is to use the erlang debugger to single-step the program.

Another option is to compile your code using the smart exceptions package, available from the jungerl. Smart exceptions then provide line number information:

        4> c(crash, [{parse_transform, smart_exceptions}]).   
        {ok,crash}
        5> crash:f().
        ** exited: {{crash,g,0},{line,9},match,[5]} **

smart_exception包在这里下载  http://pepper.sherry.jp/mikage/smart_exceptions.tar.gz
这个包的年代比较久了  makefile有些问题
这样编译 erlc *.erl 一堆警告不怕。

你可能感兴趣的:(C++,c,windows,erlang,F#)