aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2011-03-17 08:33:40 +0100
committerBjörn Gustavsson <[email protected]>2011-08-16 08:58:47 +0200
commit45ec105b3a7962370413906b5fa49a6a73cf3d83 (patch)
treef28004a6a89f19623ccb9a427ef7bd63261af1f7 /lib
parent059dab74c2930eb5627737c336c428ca30f290c5 (diff)
downloadotp-45ec105b3a7962370413906b5fa49a6a73cf3d83.tar.gz
otp-45ec105b3a7962370413906b5fa49a6a73cf3d83.tar.bz2
otp-45ec105b3a7962370413906b5fa49a6a73cf3d83.zip
Make sure that erlang:raise/3 sets the emulated stacktrace
erlang:raise/3 was evaluated in the real process, which produced a correct stacktrace, but did not set emulated stacktrace for the process. Thus, a subsequent call to erlang:get_stacktrace/0 would retrieve the previous stacktrace for the process.
Diffstat (limited to 'lib')
-rw-r--r--lib/debugger/src/dbg_ieval.erl19
-rw-r--r--lib/debugger/src/dbg_iload.erl2
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/debugger/src/dbg_ieval.erl b/lib/debugger/src/dbg_ieval.erl
index 32848a00ff..a9a5e171f7 100644
--- a/lib/debugger/src/dbg_ieval.erl
+++ b/lib/debugger/src/dbg_ieval.erl
@@ -797,6 +797,25 @@ expr({dbg,Line,get_stacktrace,[]}, Bs, #ieval{level=Le}) ->
Stacktrace = get_stacktrace(),
trace(return, {Le,Stacktrace}),
{value,Stacktrace,Bs};
+expr({dbg,Line,raise,As0}, Bs0, #ieval{level=Le}=Ieval0) ->
+ %% Since erlang:get_stacktrace/0 is emulated, we will
+ %% need to emulate erlang:raise/3 too so that we can
+ %% capture the stacktrace.
+ Ieval = Ieval0#ieval{line=Line},
+ {[Class,Reason,Stk0]=As,Bs} = eval_list(As0, Bs0, Ieval),
+ trace(bif, {Le,Line,erlang,raise,As}),
+ try
+ %% Evaluate raise/3 for error checking and
+ %% truncating of the stacktrace to the correct depth.
+ Error = erlang:raise(Class, Reason, Stk0),
+ trace(return, {Le,Error}),
+ {value,Error,Bs}
+ catch
+ _:_ ->
+ Stk = erlang:get_stacktrace(), %Possibly truncated.
+ StkFun = fun(_) -> Stk end,
+ do_exception(Class, Reason, StkFun, Bs, Ieval)
+ end;
expr({dbg,Line,throw,As0}, Bs0, #ieval{level=Le}=Ieval0) ->
Ieval = Ieval0#ieval{line=Line},
{[Term],Bs} = eval_list(As0, Bs0, Ieval),
diff --git a/lib/debugger/src/dbg_iload.erl b/lib/debugger/src/dbg_iload.erl
index c94dce1b5e..db0fe0bc10 100644
--- a/lib/debugger/src/dbg_iload.erl
+++ b/lib/debugger/src/dbg_iload.erl
@@ -378,6 +378,8 @@ expr({call,Line,{remote,_,{atom,_,erlang},{atom,_,error}},[_]=As}) ->
{dbg,Line,error,expr_list(As)};
expr({call,Line,{remote,_,{atom,_,erlang},{atom,_,exit}},[_]=As}) ->
{dbg,Line,exit,expr_list(As)};
+expr({call,Line,{remote,_,{atom,_,erlang},{atom,_,raise}},[_,_,_]=As}) ->
+ {dbg,Line,raise,expr_list(As)};
expr({call,Line,{remote,_,{atom,_,erlang},{atom,_,apply}},[_,_,_]=As0}) ->
As = expr_list(As0),
{apply,Line,As};