diff options
author | Björn Gustavsson <[email protected]> | 2011-08-25 11:25:29 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2011-08-25 11:25:29 +0200 |
commit | 142700357d3c76aa4c916f0cd5f915a947cbf94c (patch) | |
tree | 3af82388a86d708b3185fc142013a459c0201652 /lib/debugger/test/int_eval_SUITE_data | |
parent | 756a93ca2064b9e0eba3d82a7bd37aeae0f39be1 (diff) | |
parent | 26cceb7a0718182e74083b4ad044985e8f624ee2 (diff) | |
download | otp-142700357d3c76aa4c916f0cd5f915a947cbf94c.tar.gz otp-142700357d3c76aa4c916f0cd5f915a947cbf94c.tar.bz2 otp-142700357d3c76aa4c916f0cd5f915a947cbf94c.zip |
Merge branch 'bjorn/line-numbers-in-exceptions/OTP-9468' into major
* bjorn/line-numbers-in-exceptions/OTP-9468: (51 commits)
debugger: By default, only save non-tail-recursive calls
debugger: Add line_number_SUITE
debugger: Include line numbers in exceptions
Update examples in the documentation to include line numbers
Update documentation for erlang:raise/3 and erlang:get_stacktrace/0
beam_lib: Retain the "Line" chunk when stripping BEAM files
erl: Add +L to suppress loading of line number information
compiler: Add no_line_info for suppressing line/1 instructions
exception_SUITE: Test line numbers in exceptions
common_test: Use line numbers in exceptions
common_test tests: Don't do detailed testing of the stack backtrace
test_server: Refactor init_per_testcase/3 into two functions
Implement process_info(Pid, current_{location,stacktrace})
beam_emu: Factor out saving of stack trace from save_stacktrace()
compiler: Don't create filenames starting with "./"
ops.tab: Remove line instructions before tail-recursive calls
Lookup and include filenames and line numbers in exceptions
Fix decrement of continuation pointers
Refactor building of the exception stacktrace
BEAM loader: Load the line table
...
Diffstat (limited to 'lib/debugger/test/int_eval_SUITE_data')
-rw-r--r-- | lib/debugger/test/int_eval_SUITE_data/my_int_eval_module.erl | 4 | ||||
-rw-r--r-- | lib/debugger/test/int_eval_SUITE_data/stacktrace.erl | 130 |
2 files changed, 132 insertions, 2 deletions
diff --git a/lib/debugger/test/int_eval_SUITE_data/my_int_eval_module.erl b/lib/debugger/test/int_eval_SUITE_data/my_int_eval_module.erl index 997ee6e17d..90f83e80e8 100644 --- a/lib/debugger/test/int_eval_SUITE_data/my_int_eval_module.erl +++ b/lib/debugger/test/int_eval_SUITE_data/my_int_eval_module.erl @@ -117,7 +117,7 @@ more_nocatch(Fun) -> %% External calls. external_call_test(Data) -> - {'EXIT',{undef,[{?MODULE,not_exported,[42,Data]}|_]}} = + {'EXIT',{undef,[{?MODULE,not_exported,[42,Data],_}|_]}} = (catch ?MODULE:not_exported(42, Data)), {yes,Data} = i_am_exported(Data), {yes,Data} = ?MODULE:i_am_exported(Data), @@ -127,7 +127,7 @@ external_call_test(Data) -> {ok,Data,[a,b]} = not_exported(Data, [a,b]), {yes,Data} = i_am_exported(Data), {ok,Data,[a,b]} = not_exported(Data, [a,b]), - {'EXIT',{undef,[{?MODULE,not_exported,[7,Data]}|_]}} = + {'EXIT',{undef,[{?MODULE,not_exported,[7,Data],_}|_]}} = (catch ?MODULE:not_exported(7, Data)), {yes,Data} = ?MODULE:i_am_exported(Data), ok. diff --git a/lib/debugger/test/int_eval_SUITE_data/stacktrace.erl b/lib/debugger/test/int_eval_SUITE_data/stacktrace.erl new file mode 100644 index 0000000000..3380178fdc --- /dev/null +++ b/lib/debugger/test/int_eval_SUITE_data/stacktrace.erl @@ -0,0 +1,130 @@ +-module(stacktrace). +-export([?MODULE/0]). + +?MODULE() -> + OldDepth = erlang:system_flag(backtrace_depth, 32), + done = (catch do_try()), + Stk = trim(erlang:get_stacktrace()), + erlang:system_flag(backtrace_depth, OldDepth), + {done,Stk}. + +trim([{int_eval_SUITE,_,_,_}|_]) -> + []; +trim([H|T]) -> + [H|trim(T)]; +trim([]) -> []. + +do_try() -> + try + 0 = id(42) + catch + error:{badmatch,42} -> + do_try2() %Tail-recursive + end. + +do_try2() -> + try + 0 = id(42) + catch + error:{badmatch,42} -> + do_try3() %Not tail-recursive + end, + ?LINE. + +do_try3() -> + try id(42) of + 42 -> do_try4() %Tail-recursive + catch + error:ignore -> %Should never catch + ?LINE + end. + +do_try4() -> + try + do_recv() %Not tail-recursive + catch + error:ignore -> %Should never catch + ?LINE + end. + +do_recv() -> + self() ! x, + receive + x -> do_recv2() %Not tail-recursive + end, + ?LINE. + +do_recv2() -> + self() ! y, + receive + y -> do_recv3() %Tail-recursive + end. + +do_recv3() -> + receive + after 0 -> do_recv4() %Tail-recursive + end. + +do_recv4() -> + receive + after 0 -> do_if(true) %Not tail-recursive + end, + ?LINE. + +do_if(Bool) -> + if + Bool -> do_if2(Bool) %Tail-recursive + end. + +do_if2(Bool) -> + if + Bool -> do_case(Bool) %Not tail-recursive + end, + ?LINE. + + +do_case(Bool) -> + case Bool of + true -> do_case2(Bool) %Tail-recursive + end. + +do_case2(Bool) -> + case Bool of + true -> do_fun(Bool) %Not tail-recursive + end, + ?LINE. + +do_fun(Bool) -> + F = fun(true) -> + do_fun2(Bool) %Tail-recursive + end, + F(Bool). %Tail-recursive + +do_fun2(Bool) -> + F = fun(true) -> + cons(Bool) %Tail-recursive + end, + F(Bool), %Not tail-recursive + ?LINE. + +cons(Bool) -> + [Bool|tuple()]. + +tuple() -> + {ok,op()}. + +op() -> + 1 + lc(). + +lc() -> + [done() || true]. + +done() -> + tail(100), + throw(done). + +tail(0) -> ok; +tail(N) -> tail(N-1). + +id(I) -> + I. |