diff options
Diffstat (limited to 'lib/debugger/src/dbg_iserver.erl')
-rw-r--r-- | lib/debugger/src/dbg_iserver.erl | 59 |
1 files changed, 33 insertions, 26 deletions
diff --git a/lib/debugger/src/dbg_iserver.erl b/lib/debugger/src/dbg_iserver.erl index 28e8012f71..3e959e8e30 100644 --- a/lib/debugger/src/dbg_iserver.erl +++ b/lib/debugger/src/dbg_iserver.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1998-2012. All Rights Reserved. +%% Copyright Ericsson AB 1998-2016. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -72,17 +72,17 @@ cast(Int, Request) -> gen_server:cast(Int, Request). safe_call(Request) -> - ensure_started(), + {ok, _} = ensure_started(), call(Request). safe_cast(Request) -> - ensure_started(), + {ok, _} = ensure_started(), cast(Request). ensure_started() -> case whereis(?MODULE) of undefined -> start(); - _Pid -> ignore + Pid -> {ok, Pid} end. %%--Module database--------------------------------------------------- @@ -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 @@ -402,8 +406,10 @@ handle_cast({set_status, Meta, Status, Info}, State) -> send_all(subscriber, {new_status, Proc#proc.pid, Status, Info}, State), if Status =:= break -> - auto_attach(break, State#state.auto, Proc); - true -> ignore + _ = auto_attach(break, State#state.auto, Proc), + ok; + true -> + ok end, Proc2 = Proc#proc{status=Status, info=Info}, {noreply, State#state{procs=lists:keyreplace(Meta, #proc.meta, @@ -470,7 +476,7 @@ handle_info({'EXIT',Who,Why}, State) -> [self(),AttPid,Pid,Why,ExitInfo]); undefined -> %% Otherwise, auto attach if necessary - auto_attach(exit, State#state.auto, Pid), + _ = auto_attach(exit, State#state.auto, Pid), Who end, send_all(subscriber, {new_status,Pid,exit,Why}, State), @@ -583,7 +589,8 @@ send_all(Pids, Msg) -> lists:foreach(fun(Pid) -> send(Pid, Msg) end, Pids). send(Pid, Msg) -> - Pid ! {int, Msg}. + Pid ! {int, Msg}, + ok. get_proc({Type, Pid}, Procs) -> Index = case Type of |