Skip to content

Commit

Permalink
fixup! Add (and use) proc_lib:set(and get)_process_description/1
Browse files Browse the repository at this point in the history
  • Loading branch information
dgud committed Nov 10, 2023
1 parent 39962c7 commit eba3d1b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
20 changes: 15 additions & 5 deletions lib/observer/src/observer_procinfo.erl
Original file line number Diff line number Diff line change
Expand Up @@ -451,18 +451,28 @@ get_name(Pid) ->
[] ->
case observer_wx:try_rpc(node(Pid), proc_lib, get_label, [Pid]) of
{error, _} ->
io_lib:format("~p",[Pid]);
io_lib:format("~w",[Pid]);
undefined ->
io_lib:format("~p",[Pid]);
Id ->
io_lib:format("~tp (~p)",[Id, Pid])
io_lib:format("~w",[Pid]);
Label ->
format_label(Label, Pid)
end;
{registered_name, Registered} ->
io_lib:format("~tp (~p)",[Registered, Pid]);
io_lib:format("~0.tp ~w",[Registered, Pid]);
undefined ->
throw(process_undefined)
end.

format_label(Id, Pid) when is_list(Id); is_binary(Id) ->
case unicode:characters_to_binary(Id) of
{error, _, _} ->
io_lib:format("~0.tp ~w", [Id, Pid]);
BinString ->
io_lib:format("~ts ~w", [BinString, Pid])
end;
format_label(Id, Pid) ->
io_lib:format("~0.tp ~w", [Id, Pid]).

stringify_bins(Data) ->
Bins = proplists:get_value(binary, Data),
[lists:flatten(io_lib:format("<< ~s, refc ~w>>", [observer_lib:to_str({bytes,Sz}),Refc]))
Expand Down
22 changes: 13 additions & 9 deletions lib/runtime_tools/src/appmon_info.erl
Original file line number Diff line number Diff line change
Expand Up @@ -711,18 +711,12 @@ format(P) when is_pid(P) ->
case process_info(P, registered_name) of
{registered_name, Name} -> atom_to_list(Name);
_ ->
%% Needs to be unique
case proc_lib:get_label(P) of
undefined ->
pid_to_list(P);
Id when is_binary(Id) ->
case unicode:characters_to_list(Id) of
{error, _, _} ->
io_lib:format("~0.tp", [Id]);
StringId ->
StringId
end;
Id ->
io_lib:format("~0.tp", [Id])
Label ->
format_label(Label, P)
end
end;
format(P) when is_port(P) ->
Expand All @@ -735,6 +729,16 @@ format(X) ->
io:format("What: ~p~n", [X]),
"???".

format_label(Id, Pid) when is_list(Id); is_binary(Id) ->
case unicode:characters_to_binary(Id) of
{error, _, _} ->
io_lib:format("~0.tp ~w", [Id, Pid]);
BinString ->
io_lib:format("~ts ~w", [BinString, Pid])
end;
format_label(Id, Pid) ->
io_lib:format("~0.tp ~w", [Id, Pid]).


%%----------------------------------------------------------------------
%%**********************************************************************
Expand Down

0 comments on commit eba3d1b

Please sign in to comment.