diff options
author | Björn Gustavsson <[email protected]> | 2011-03-31 07:31:14 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2011-08-16 08:58:47 +0200 |
commit | e0fe23461cc94a80e02a9542ab2182f62badd5de (patch) | |
tree | 2ec0499d0b23c64d88880eb1c8e8c8830dfce8ea /lib/debugger/src/dbg_debugged.erl | |
parent | 3ccc4730e54f0f9e86bf96360b7600ab8c9e1d47 (diff) | |
download | otp-e0fe23461cc94a80e02a9542ab2182f62badd5de.tar.gz otp-e0fe23461cc94a80e02a9542ab2182f62badd5de.tar.bz2 otp-e0fe23461cc94a80e02a9542ab2182f62badd5de.zip |
Don't build stacktrace until erlang:get_stacktrace() is called
Currently, dbg_istk:exception_stacktrace/2 does not do a very good job
imitating BEAM's stacktrace. The reason is that it need to be
relatively fast since a simulated stacktrace is constructed not only
when an exception oocurs, but also before every call to
non-interpreted code.
To prepare for a future more thorough (and slower) stacktrace
construction, refactor the building of the stacktrace so that
it only is done when erlang:get_stacktrace/0 is called.
Diffstat (limited to 'lib/debugger/src/dbg_debugged.erl')
-rw-r--r-- | lib/debugger/src/dbg_debugged.erl | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/debugger/src/dbg_debugged.erl b/lib/debugger/src/dbg_debugged.erl index 3732c40c73..76ed49fa93 100644 --- a/lib/debugger/src/dbg_debugged.erl +++ b/lib/debugger/src/dbg_debugged.erl @@ -76,8 +76,8 @@ msg_loop(Meta, Mref, SaveStacktrace) -> msg_loop(Meta, Mref, SaveStacktrace); %% Meta needs something evaluated within context of real process - {sys, Meta, {command, Command, Stacktrace}} -> - Reply = handle_command(Command, Stacktrace), + {sys, Meta, {command,Command}} -> + Reply = handle_command(Command), Meta ! {sys, self(), Reply}, msg_loop(Meta, Mref, SaveStacktrace); @@ -93,11 +93,12 @@ msg_loop(Meta, Mref, SaveStacktrace) -> end end. -handle_command(Command, Stacktrace) -> - try reply(Command) +handle_command(Command) -> + try + reply(Command) catch Class:Reason -> - Stacktrace2 = stacktrace_f(erlang:get_stacktrace()), - {exception, {Class,Reason,Stacktrace2++Stacktrace}} + Stacktrace = stacktrace_f(erlang:get_stacktrace()), + {exception,{Class,Reason,Stacktrace}} end. reply({apply,M,F,As}) -> |