aboutsummaryrefslogtreecommitdiffstats
path: root/lib/debugger/src/dbg_iserver.erl
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2016-07-20 14:12:24 +0200
committerPeter Andersson <[email protected]>2016-07-20 14:20:07 +0200
commitbc544c51d84bfd61f3dafc5048e86cea02641b43 (patch)
tree0c34ba9f898ec3d2269c7eff95f4995d69e406a1 /lib/debugger/src/dbg_iserver.erl
parent7c10598da79e28c9b802029d94269cbebba2f21e (diff)
downloadotp-bc544c51d84bfd61f3dafc5048e86cea02641b43.tar.gz
otp-bc544c51d84bfd61f3dafc5048e86cea02641b43.tar.bz2
otp-bc544c51d84bfd61f3dafc5048e86cea02641b43.zip
Make sure exit in non-interpreted code doesn't crash the debugger
Diffstat (limited to 'lib/debugger/src/dbg_iserver.erl')
-rw-r--r--lib/debugger/src/dbg_iserver.erl40
1 files changed, 22 insertions, 18 deletions
diff --git a/lib/debugger/src/dbg_iserver.erl b/lib/debugger/src/dbg_iserver.erl
index 3561454685..3e959e8e30 100644
--- a/lib/debugger/src/dbg_iserver.erl
+++ b/lib/debugger/src/dbg_iserver.erl
@@ -214,7 +214,6 @@ handle_call({new_process, Pid, Meta, Function}, _From, State) ->
%% Code loading
handle_call({load, Mod, Src, Bin}, _From, State) ->
-
%% Create an ETS table for storing information about the module
Db = State#state.db,
ModDb = ets:new(Mod, [ordered_set, public]),
@@ -285,23 +284,28 @@ handle_call({contents, Mod, Pid}, _From, State) ->
{reply, {ok, Bin}, State};
handle_call({raw_contents, Mod, Pid}, _From, State) ->
Db = State#state.db,
- [{{Mod, refs}, ModDbs}] = ets:lookup(Db, {Mod, refs}),
- ModDb = if
- Pid =:= any -> hd(ModDbs);
- true ->
- lists:foldl(fun(T, not_found) ->
- [{T, Pids}] = ets:lookup(Db, T),
- case lists:member(Pid, Pids) of
- true -> T;
- false -> not_found
- end;
- (_T, T) -> T
- end,
- not_found,
- ModDbs)
- end,
- [{mod_raw, Bin}] = ets:lookup(ModDb, mod_raw),
- {reply, {ok, Bin}, State};
+ case ets:lookup(Db, {Mod, refs}) of
+ [{{Mod, refs}, ModDbs}] ->
+ ModDb =
+ if
+ Pid =:= any -> hd(ModDbs);
+ true ->
+ lists:foldl(fun(T, not_found) ->
+ [{T, Pids}] = ets:lookup(Db, T),
+ case lists:member(Pid, Pids) of
+ true -> T;
+ false -> not_found
+ end;
+ (_T, T) -> T
+ end,
+ not_found,
+ ModDbs)
+ end,
+ [{mod_raw, Bin}] = ets:lookup(ModDb, mod_raw),
+ {reply, {ok, Bin}, State};
+ [] -> % code not interpreted
+ {reply, not_found, State}
+ end;
handle_call({is_interpreted, Mod, Name, Arity}, _From, State) ->
Db = State#state.db,
Reply = case ets:lookup(Db, {Mod, refs}) of