From eba3d1bc1ece922851207a326d02332c107e86f3 Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Fri, 10 Nov 2023 09:36:46 +0100 Subject: [PATCH] fixup! Add (and use) proc_lib:set(and get)_process_description/1 --- lib/observer/src/observer_procinfo.erl | 20 +++++++++++++++----- lib/runtime_tools/src/appmon_info.erl | 22 +++++++++++++--------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/lib/observer/src/observer_procinfo.erl b/lib/observer/src/observer_procinfo.erl index 6c828293fdd4..2b12f5306221 100644 --- a/lib/observer/src/observer_procinfo.erl +++ b/lib/observer/src/observer_procinfo.erl @@ -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])) diff --git a/lib/runtime_tools/src/appmon_info.erl b/lib/runtime_tools/src/appmon_info.erl index 856210f89b4c..d5f3858936fd 100644 --- a/lib/runtime_tools/src/appmon_info.erl +++ b/lib/runtime_tools/src/appmon_info.erl @@ -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) -> @@ -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]). + %%---------------------------------------------------------------------- %%**********************************************************************