aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2015-03-11 16:04:12 +0100
committerDan Gudmundsson <[email protected]>2015-03-11 16:04:12 +0100
commit5d11a9f728de74b2df0c374658ce21ad318f4b93 (patch)
tree296a8b962c1744ce1fcdf477153f98c15d9b9cb2 /lib
parentc5da5547dbf63e324ae3584035c48ce936eddc7c (diff)
parent57ff0be8b90392a0f881c3f5f7f85e3a69ea2356 (diff)
downloadotp-5d11a9f728de74b2df0c374658ce21ad318f4b93.tar.gz
otp-5d11a9f728de74b2df0c374658ce21ad318f4b93.tar.bz2
otp-5d11a9f728de74b2df0c374658ce21ad318f4b93.zip
Merge branch 'dgud/observer/misc-fixes'
* dgud/observer/misc-fixes: observer: Fix external monitors to registered processes in cdv observer: Cleanup io server parts observer: Fix range test
Diffstat (limited to 'lib')
-rw-r--r--lib/observer/src/crashdump_viewer.erl46
-rw-r--r--lib/observer/src/observer_pro_wx.erl2
-rw-r--r--lib/observer/src/observer_procinfo.erl40
3 files changed, 64 insertions, 24 deletions
diff --git a/lib/observer/src/crashdump_viewer.erl b/lib/observer/src/crashdump_viewer.erl
index 2ba65c9a4d..ef14ba46e2 100644
--- a/lib/observer/src/crashdump_viewer.erl
+++ b/lib/observer/src/crashdump_viewer.erl
@@ -320,6 +320,8 @@ handle_call(general_info,_From,State=#state{file=File}) ->
"Some information might be missing."];
false -> []
end,
+ ets:insert(cdv_reg_proc_table,
+ {cdv_dump_node_name,GenInfo#general_info.node_name}),
{reply,{ok,GenInfo,TW},State#state{wordsize=WS, num_atoms=NumAtoms}};
handle_call({expand_binary,{Offset,Size,Pos}},_From,State=#state{file=File}) ->
Fd = open(File),
@@ -926,7 +928,7 @@ general_info(File) ->
N;
[] ->
case lookup_index(?no_distribution) of
- [_] -> "nonode@nohost";
+ [_] -> "'nonode@nohost'";
[] -> "unknown"
end
end,
@@ -1167,6 +1169,19 @@ parse_pid(Str) ->
{Pid,Rest} = parse_link(Str,[]),
{{Pid,Pid},Rest}.
+parse_monitor("{"++Str) ->
+ %% Named process
+ {Name,Node,Rest1} = parse_name_node(Str,[]),
+ Pid = get_pid_from_name(Name,Node),
+ case parse_link(string:strip(Rest1,left,$,),[]) of
+ {Ref,"}"++Rest2} ->
+ %% Bug in break.c - prints an extra "}" for remote
+ %% nodes... thus the strip
+ {{Pid,"{"++Name++","++Node++"} ("++Ref++")"},
+ string:strip(Rest2,left,$})};
+ {Ref,[]} ->
+ {{Pid,"{"++Name++","++Node++"} ("++Ref++")"},[]}
+ end;
parse_monitor(Str) ->
case parse_link(Str,[]) of
{Pid,","++Rest1} ->
@@ -1188,6 +1203,35 @@ parse_link([],Acc) ->
%% truncated
{lists:reverse(Acc),[]}.
+parse_name_node(","++Rest,Name) ->
+ parse_name_node(Rest,Name,[]);
+parse_name_node([H|T],Name) ->
+ parse_name_node(T,[H|Name]);
+parse_name_node([],Name) ->
+ %% truncated
+ {lists:reverse(Name),[],[]}.
+
+parse_name_node("}"++Rest,Name,Node) ->
+ {lists:reverse(Name),lists:reverse(Node),Rest};
+parse_name_node([H|T],Name,Node) ->
+ parse_name_node(T,Name,[H|Node]);
+parse_name_node([],Name,Node) ->
+ %% truncated
+ {lists:reverse(Name),lists:reverse(Node),[]}.
+
+get_pid_from_name(Name,Node) ->
+ case ets:lookup(cdv_reg_proc_table,cdv_dump_node_name) of
+ [{_,Node}] ->
+ case ets:lookup(cdv_reg_proc_table,Name) of
+ [{_,Pid}] when is_pid(Pid) ->
+ pid_to_list(Pid);
+ _ ->
+ "<unkonwn_pid>"
+ end;
+ _ ->
+ "<unknown_pid_other_node>"
+ end.
+
maybe_other_node(Id) ->
Channel =
case split($.,Id) of
diff --git a/lib/observer/src/observer_pro_wx.erl b/lib/observer/src/observer_pro_wx.erl
index 0be8c18893..026693ff56 100644
--- a/lib/observer/src/observer_pro_wx.erl
+++ b/lib/observer/src/observer_pro_wx.erl
@@ -578,7 +578,7 @@ get_row(From, Row, pid, Info) ->
end,
From ! {self(), Pid};
get_row(From, Row, Col, Info) ->
- Data = case Row > array:size(Info) of
+ Data = case Row >= array:size(Info) of
true ->
"";
false ->
diff --git a/lib/observer/src/observer_procinfo.erl b/lib/observer/src/observer_procinfo.erl
index a8512894f9..2a840dc49e 100644
--- a/lib/observer/src/observer_procinfo.erl
+++ b/lib/observer/src/observer_procinfo.erl
@@ -338,7 +338,7 @@ init_log_page(Parent, Pid, Table) ->
Update = fun() ->
Fd = spawn_link(fun() -> io_server() end),
rpc:call(node(Pid), rb, rescan, [[{start_log, Fd}]]),
- rpc:call(node(Pid), rb , grep, [local_pid_str(Pid)]),
+ rpc:call(node(Pid), rb, grep, [local_pid_str(Pid)]),
Logs = io_get_data(Fd),
%% Replace remote local pid notation to global notation
Pref = global_pid_node_pref(Pid),
@@ -453,7 +453,7 @@ global_pid_node_pref(Pid) ->
io_get_data(Pid) ->
Pid ! {self(), get_data_and_close},
receive
- {Pid, data, Data} -> lists:flatten(Data)
+ {Pid, data, Data} -> lists:flatten(Data)
end.
io_server() ->
@@ -461,29 +461,25 @@ io_server() ->
io_server(State) ->
receive
- {io_request, From, ReplyAs, Request} ->
- case io_request(Request,State) of
- {Tag, Reply, NewState} when Tag =:= ok; Tag =:= error ->
- From ! {io_reply, ReplyAs, Reply},
- io_server(NewState);
- {stop, Reply, _NewState} ->
- From ! {io_reply, ReplyAs, Reply},
- exit(Reply)
- end;
- {Pid, get_data_and_close} ->
- Pid ! {self(), data, lists:reverse(State#io.rdata)},
- normal;
- _Unknown ->
- io:format("~p: Unknown msg: ~p ~n",[?LINE, _Unknown]),
- io_server(State)
+ {io_request, From, ReplyAs, Request} ->
+ {_, Reply, NewState} = io_request(Request,State),
+ From ! {io_reply, ReplyAs, Reply},
+ io_server(NewState);
+ {Pid, get_data_and_close} ->
+ Pid ! {self(), data, lists:reverse(State#io.rdata)},
+ normal;
+ _Unknown ->
+ io_server(State)
end.
io_request({put_chars, _Encoding, Chars}, State = #io{rdata=Data}) ->
{ok, ok, State#io{rdata=[Chars|Data]}};
io_request({put_chars, Encoding, Module, Function, Args}, State) ->
- try io_request({put_chars, Encoding, apply(Module, Function, Args)}, State)
- catch _:_ -> {error, {error,Function}, State}
+ try
+ io_request({put_chars, Encoding, apply(Module, Function, Args)}, State)
+ catch _:_ ->
+ {error, {error, Function}, State}
end;
-io_request(Req, State) ->
- io:format("~p: Unknown req: ~p ~n",[?LINE, Req]),
- State.
+io_request(_Req, State) ->
+ %% io:format("~p: Unknown req: ~p ~n",[?LINE, _Req]),
+ {ok, {error, request}, State}.