From 4720a981b984fd416e0e806f94882f71e8560b72 Mon Sep 17 00:00:00 2001 From: zhongwencool Date: Sat, 19 Oct 2024 17:50:33 +0800 Subject: [PATCH 1/2] ci: use github badge build status --- .github/workflows/erlang.yml | 4 +- .gitignore | 1 + README.md | 2 +- rebar.config | 77 +++++++++++++++++++++----------- rebar.lock | 7 ++- src/observer_cli_application.erl | 2 +- src/observer_cli_escriptize.erl | 2 +- src/observer_cli_ets.erl | 4 +- src/observer_cli_inet.erl | 8 ++-- src/observer_cli_lib.erl | 32 +++++++------ src/observer_cli_plugin.erl | 4 +- src/observer_cli_port.erl | 6 +-- src/observer_cli_process.erl | 6 +-- src/observer_cli_system.erl | 12 ++--- 14 files changed, 104 insertions(+), 63 deletions(-) diff --git a/.github/workflows/erlang.yml b/.github/workflows/erlang.yml index 96350db..e1005ed 100644 --- a/.github/workflows/erlang.yml +++ b/.github/workflows/erlang.yml @@ -1,4 +1,4 @@ -name: Erlang CI +name: ci on: push @@ -8,7 +8,7 @@ jobs: name: Erlang/OTP ${{matrix.otp}} / rebar3 ${{matrix.rebar3}} strategy: matrix: - otp: ['26', '25', '24'] + otp: ['27', '26', '25', '24'] rebar3: ['3.22'] steps: - uses: actions/checkout@v4 diff --git a/.gitignore b/.gitignore index 96b5995..edf56f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .eunit +.tool-versions _build deps elvis diff --git a/README.md b/README.md index 1d511d4..55c0e71 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # observer_cli -[![Build Status](https://travis-ci.org/zhongwencool/observer_cli.svg?branch=master)](https://travis-ci.org/zhongwencool/observer_cli) +[![Build Status](https://github.com/zhongwencool/observer_cli/workflows/ci/badge.svg)](https://github.com/zhongwencool/observer_cli/actions) [![GitHub tag](https://img.shields.io/github/tag/zhongwencool/observer_cli.svg)](https://github.com/zhongwencool/observer_cli) [![MIT License](https://img.shields.io/hexpm/l/observer_cli.svg)](https://hex.pm/packages/observer_cli) [![Hex.pm Version](https://img.shields.io/hexpm/v/observer_cli.svg)](https://hex.pm/packages/observer_cli) diff --git a/rebar.config b/rebar.config index fa9a553..517203e 100644 --- a/rebar.config +++ b/rebar.config @@ -1,40 +1,67 @@ -{erl_opts, [{src_dirs, ["src", "test"]}, - warn_unused_vars, - warn_export_all, - warn_shadow_vars, - warn_unused_import, - warn_unused_function, - warn_bif_clash, - warn_unused_record, - warn_deprecated_function, - warn_obsolete_guard, - strict_validation, - warn_export_vars, - warn_exported_vars, - warn_missing_spec, - warn_untyped_record, debug_info]}. +{erl_opts, [ + {src_dirs, ["src", "test"]}, + warn_unused_vars, + warn_export_all, + warn_shadow_vars, + warn_unused_import, + warn_unused_function, + warn_bif_clash, + warn_unused_record, + warn_deprecated_function, + warn_obsolete_guard, + strict_validation, + warn_export_vars, + warn_exported_vars, + warn_missing_spec, + warn_untyped_record, + debug_info +]}. {deps_dir, "deps"}. -{deps, [recon]}. +{deps, [ + recon, + {eqwalizer_support, + {git_subdir, "https://github.com/whatsapp/eqwalizer.git", {branch, "main"}, + "eqwalizer_support"}} +]}. + +{project_plugins, [ + rebar3_format, + erlfmt, + {eqwalizer_rebar3, + {git_subdir, "https://github.com/whatsapp/eqwalizer.git", {branch, "main"}, + "eqwalizer_rebar3"}} +]}. {escript_main_app, observer_cli}. -{escript_emu_args, "%%! -escript main observer_cli_escriptize -hidden +sbtu +A0 -elixir ansi_enabled true\n"}. +{escript_emu_args, + "%%! -escript main observer_cli_escriptize -hidden +sbtu +A0 -elixir ansi_enabled true\n"}. {escript_incl_apps, [recon]}. {dialyzer_opts, [{warnings, [unmatched_returns, error_handling, race_conditions, behaviours]}]}. -{edoc_opts, [{report_missing_types, true}, {source_path, ["src"]}, {report_missing_types, true}, {todo, true}, {packages, false}, {subpackages, false}]}. +{edoc_opts, [ + {report_missing_types, true}, + {source_path, ["src"]}, + {report_missing_types, true}, + {todo, true}, + {packages, false}, + {subpackages, false} +]}. {xref_checks, [undefined_function_calls]}. +{xref_ignores, [{proc_lib, get_label, 1}]}. {cover_enabled, true}. {post_hooks, [{"(linux|darwin|solaris)", edoc, "escript doc/docsite.erl"}]}. {profiles, [ - {inet6, [ - {escript_emu_args, "%%! -escript main observer_cli_escriptize -hidden -proto_dist inet6_tcp +sbtu +A0 -elixir ansi_enabled true\n"} - ]} + {inet6, [ + {escript_emu_args, + "%%! -escript main observer_cli_escriptize -hidden -proto_dist inet6_tcp +sbtu +A0 -elixir ansi_enabled true\n"} + ]} ]}. -{project_plugins, [rebar3_format, erlfmt]}. {format, [ - {files, ["src/*.erl", "include/*.hrl"]}, - {formatter, erlfmt_formatter}, %% The erlfmt formatter interface. - {options, #{print_width => 100, ignore_pragma => true}} %% ...or no options at all. + {files, ["src/*.erl", "include/*.hrl"]}, + %% The erlfmt formatter interface. + {formatter, erlfmt_formatter}, + %% ...or no options at all. + {options, #{print_width => 100, ignore_pragma => true}} ]}. diff --git a/rebar.lock b/rebar.lock index e58cb62..2621c54 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,5 +1,10 @@ {"1.2.0", -[{<<"recon">>,{pkg,<<"recon">>,<<"2.5.5">>},0}]}. +[{<<"eqwalizer_support">>, + {git_subdir,"https://github.com/whatsapp/eqwalizer.git", + {ref,"0c099bbfa2fba1869d60e239c9b2cf2b6fb31ea9"}, + "eqwalizer_support"}, + 0}, + {<<"recon">>,{pkg,<<"recon">>,<<"2.5.5">>},0}]}. [ {pkg_hash,[ {<<"recon">>, <<"C108A4C406FA301A529151A3BB53158CADC4064EC0C5F99B03DDB8C0E4281BDF">>}]}, diff --git a/src/observer_cli_application.erl b/src/observer_cli_application.erl index 1cae91b..ff4d9a4 100644 --- a/src/observer_cli_application.erl +++ b/src/observer_cli_application.erl @@ -82,7 +82,7 @@ render_app_info(Row, CurPage, {Type, N}) -> begin {0, {element(N, I), S}, [App, C, M, R, Q, S, V]} end - || {App, I = {C, M, R, Q, S, V}} <- maps:to_list(app_info()) + || {App, I = {C, M, R, Q, S, V}} <- maps:to_list(app_info()) ], {StartPos, SortList} = observer_cli_lib:sublist(List, Row, CurPage), InitColor = [ diff --git a/src/observer_cli_escriptize.erl b/src/observer_cli_escriptize.erl index 8816ed5..aedb4ed 100644 --- a/src/observer_cli_escriptize.erl +++ b/src/observer_cli_escriptize.erl @@ -59,7 +59,7 @@ remote_load(Node) -> begin recon:remote_load([Node], Mod) end - || Mod <- ?BEAM_MODS + || Mod <- ?BEAM_MODS ]. random_local_node_name() -> diff --git a/src/observer_cli_ets.erl b/src/observer_cli_ets.erl index 8ecdf0a..e19ca9a 100644 --- a/src/observer_cli_ets.erl +++ b/src/observer_cli_ets.erl @@ -74,7 +74,7 @@ render_ets_info(Rows, CurPage, Attr) -> begin get_ets_info(Tab, Attr) end - || Tab <- ets:all() + || Tab <- ets:all() ], WordSize = erlang:system_info(wordsize), {_StartPos, SortEts} = observer_cli_lib:sublist(AllEts, Rows, CurPage), @@ -123,7 +123,7 @@ render_ets_info(Rows, CurPage, Attr) -> ?W(Owner, 14) ]) end - || {_, _, Ets} <- SortEts + || {_, _, Ets} <- SortEts ], [Title | RowView]. diff --git a/src/observer_cli_inet.erl b/src/observer_cli_inet.erl index e46e96d..12f7560 100644 --- a/src/observer_cli_inet.erl +++ b/src/observer_cli_inet.erl @@ -129,12 +129,14 @@ render_io_rows({LastIn, LastOut}) -> render_inet_rows([], Rows, #inet{func = inet_count, type = Type}) -> {[], io_lib:format("\e[32;1mGet nothing for recon:inet_count(~p, ~p)\e[0m~n", [Type, Rows])}; render_inet_rows([], Rows, #inet{func = inet_window, type = Type, interval = Interval}) -> - {[], + { + [], io_lib:format("\e[32;1mGet nothing for recon:inet_window(~p, ~p, ~p)\e[0m~n", [ Type, Rows, Interval - ])}; + ]) + }; render_inet_rows(InetList, Num, #inet{ type = Type, pages = Pages, @@ -294,7 +296,7 @@ get_remote_ip(P) -> begin erlang:integer_to_list(A) end - || A <- erlang:tuple_to_list(Addr) + || A <- erlang:tuple_to_list(Addr) ], string:join(AddrList, ".") ++ ":" ++ erlang:integer_to_list(Port); {error, Err} -> diff --git a/src/observer_cli_lib.erl b/src/observer_cli_lib.erl index fca6e9b..bbdc963 100644 --- a/src/observer_cli_lib.erl +++ b/src/observer_cli_lib.erl @@ -52,18 +52,24 @@ to_list(Float) when is_float(Float) -> erlang:float_to_list(Float, [{decimals, 4 to_list(Val) -> Val. get_menu_title(Selection, MnesiaTitle) -> - Options = [{home, "Home(H)"}, - {inet, "Network(N)"}, - {allocator, "System(S)"}, - {ets, "Ets(E)"}, - {mnesia, MnesiaTitle}, - {app, "App(A)"}, - {doc, "Doc(D)"}, - {plugin, "Plugin(P)"}], - lists:map(fun({_Key, ""}) -> unselect(""); - ({Key, Value}) when Key =:= Selection -> select(Value) ++ "|"; - ({_Key, Value}) -> unselect(Value) ++ "|" - end, Options). + Options = [ + {home, "Home(H)"}, + {inet, "Network(N)"}, + {allocator, "System(S)"}, + {ets, "Ets(E)"}, + {mnesia, MnesiaTitle}, + {app, "App(A)"}, + {doc, "Doc(D)"}, + {plugin, "Plugin(P)"} + ], + lists:map( + fun + ({_Key, ""}) -> unselect(""); + ({Key, Value}) when Key =:= Selection -> select(Value) ++ "|"; + ({_Key, Value}) -> unselect(Value) ++ "|" + end, + Options + ). -spec select(string()) -> list(). select(Title) -> [?RED_BG, Title, ?RESET_BG]. @@ -293,7 +299,7 @@ exit_processes(List) -> erlang:unlink(Pid), erlang:exit(Pid, stop) end - || Pid <- List + || Pid <- List ], flush(), ok. diff --git a/src/observer_cli_plugin.erl b/src/observer_cli_plugin.erl index 19b4b15..defd9eb 100644 --- a/src/observer_cli_plugin.erl +++ b/src/observer_cli_plugin.erl @@ -285,11 +285,11 @@ render_attributes(#{module := Module}, PrevAttrs) -> error -> ?W(Value, Width) end end - || Item <- Label + || Item <- Label ], ?render(L) end - || Label <- DiffAttrs + || Label <- DiffAttrs ], {Render, length(Render), NewAttrs} catch diff --git a/src/observer_cli_port.erl b/src/observer_cli_port.erl index ddf7065..fd6c422 100644 --- a/src/observer_cli_port.erl +++ b/src/observer_cli_port.erl @@ -145,7 +145,7 @@ render_link_monitor(Link, Monitors) -> begin observer_cli_lib:to_list(P) end - || P <- lists:sublist(Link, 30) + || P <- lists:sublist(Link, 30) ], MonitorsStr = [ begin @@ -156,7 +156,7 @@ render_link_monitor(Link, Monitors) -> observer_cli_lib:to_list(RegName) ++ "/" ++ observer_cli_lib:to_list(Node) end end - || P <- lists:sublist(Monitors, 30) + || P <- lists:sublist(Monitors, 30) ], LinkInfo = "Links(" ++ erlang:integer_to_list(erlang:length(Link)) ++ ")", MonitorInfo = "Monitors(" ++ erlang:integer_to_list(erlang:length(Monitors)) ++ ")", @@ -363,6 +363,6 @@ addr_to_str({Addr, Port}) -> begin erlang:integer_to_list(A) end - || A <- erlang:tuple_to_list(Addr) + || A <- erlang:tuple_to_list(Addr) ], string:join(AddrList, ".") ++ ":" ++ erlang:integer_to_list(Port). diff --git a/src/observer_cli_process.erl b/src/observer_cli_process.erl index a2791b4..dc0c0d7 100644 --- a/src/observer_cli_process.erl +++ b/src/observer_cli_process.erl @@ -281,7 +281,7 @@ render_link_monitor(Link, Monitors, MonitoredBy) -> begin observer_cli_lib:to_list(P) end - || P <- lists:sublist(Link, 30) + || P <- lists:sublist(Link, 30) ], MonitorsStr = [ begin @@ -292,13 +292,13 @@ render_link_monitor(Link, Monitors, MonitoredBy) -> observer_cli_lib:to_list(Pid) end end - || P <- lists:sublist(Monitors, 30) + || P <- lists:sublist(Monitors, 30) ], MonitoredByStr = [ begin observer_cli_lib:to_list(P) end - || P <- lists:sublist(MonitoredBy, 30) + || P <- lists:sublist(MonitoredBy, 30) ], LinkInfo = "Links(" ++ erlang:integer_to_list(erlang:length(Link)) ++ ")", MonitorInfo = "Monitors(" ++ erlang:integer_to_list(erlang:length(Monitors)) ++ ")", diff --git a/src/observer_cli_system.erl b/src/observer_cli_system.erl index fd8194a..b47bc71 100644 --- a/src/observer_cli_system.erl +++ b/src/observer_cli_system.erl @@ -107,7 +107,7 @@ render_cache_hit_rates(CacheHitInfo, Len) when Len =< 8 -> ?W(HitRateStr, 6) ]) end - || Seq <- lists:seq(0, Len - 1) + || Seq <- lists:seq(0, Len - 1) ], [Title | View]; render_cache_hit_rates(CacheHitInfo, Len) -> @@ -152,7 +152,7 @@ render_cache_hit_rates(CacheHitInfo, Len) -> ?W(HitRateStr4, 6) ]) end - || Seq1 <- lists:seq(1, Num) + || Seq1 <- lists:seq(1, Num) ], [Title | Rows]. @@ -188,7 +188,7 @@ render_block_size_info(AverageBlockCurs, AverageBlockMaxes, SbcsToMbcsCurs, Sbcs ?W(MSTM, 19) ]) end - || AllocKey <- ?UTIL_ALLOCATORS + || AllocKey <- ?UTIL_ALLOCATORS ], [Title | View]. @@ -237,8 +237,8 @@ render_sys_info(System, CPU, Memory, Statistics) -> begin {Key, Value} end - || {Key, Value} <- System, - Key =/= "Compiled for" andalso Key =/= "smp Support" + || {Key, Value} <- System, + Key =/= "Compiled for" andalso Key =/= "smp Support" ], [{_, TotalMem} | _R] = Memory, {bytes, TotalMemInt} = TotalMem, @@ -263,7 +263,7 @@ render_sys_info(System, CPU, Memory, Statistics) -> ?W(to_list(StatisticsVal), 11) ]) end - || Pos <- lists:seq(1, 6) + || Pos <- lists:seq(1, 6) ], Compile = ?render([ ?UNDERLINE, From a70d7a1b82fec14fa67675becadb01f83bd75cc6 Mon Sep 17 00:00:00 2001 From: zhongwencool Date: Sat, 19 Oct 2024 17:51:01 +0800 Subject: [PATCH 2/2] feat: display process lable when otp 27 --- src/observer_cli.erl | 84 +++++++++++++++++++++++++++++--------------- 1 file changed, 56 insertions(+), 28 deletions(-) diff --git a/src/observer_cli.erl b/src/observer_cli.erl index 9391685..c1f3e40 100644 --- a/src/observer_cli.erl +++ b/src/observer_cli.erl @@ -302,8 +302,10 @@ render_memory_process_line(MemSum, PortParallelism, Interval) -> {erlang:integer_to_list(RunQ), "RunQueue"}; Pid -> {_, Q} = process_info(Pid, message_queue_len), - {[erlang:integer_to_list(RunQ), "/", erlang:integer_to_list(Q)], - "RunQueue/ErrorLoggerQueue"} + { + [erlang:integer_to_list(RunQ), "/", erlang:integer_to_list(Q)], + "RunQueue/ErrorLoggerQueue" + } end, ProcMemPercent = observer_cli_lib:to_percent(ProcMem / TotalMem), AtomMemPercent = observer_cli_lib:to_percent(AtomMem / TotalMem), @@ -390,7 +392,7 @@ render_scheduler_usage(SchedulerUsage, SchedulerNum) when SchedulerNum < 8 -> CPU2 ]) end - || Seq1 <- lists:seq(1, Column) + || Seq1 <- lists:seq(1, Column) ], {Column, CPU}; %% 100 >= scheduler >= 8 split 4 part @@ -434,7 +436,7 @@ render_scheduler_usage(SchedulerUsage, SchedulerNum) when SchedulerNum =< 100 -> CPU4 ]) end - || Seq1 <- lists:seq(1, Column) + || Seq1 <- lists:seq(1, Column) ], {Column, CPU}; %% scheduler > 100 don't show process bar. @@ -512,7 +514,7 @@ render_scheduler_usage(SchedulerUsage, SchedulerNum) -> CPU10 ]) end - || Seq1 <- lists:seq(1, Column) + || Seq1 <- lists:seq(1, Column) ], {Column, CPU}. @@ -527,8 +529,8 @@ render_top_n_view(memory, MemoryList, Num, Pages, Page) -> Title = ?render([ ?W2(?GRAY_BG, "No | Pid", 16), ?W2(?RED_BG, " Memory", 14), - ?W(?GRAY_BG, "Name or Initial Call", 38), - ?W(?GRAY_BG, " Reductions", 21), + ?W(?GRAY_BG, "Name|>Lable|>Initial Call", 45), + ?W(?GRAY_BG, " Reductions", 14), ?W(?GRAY_BG, " MsgQueue", 10), ?W(?GRAY_BG, "Current Function", 32) ]), @@ -557,8 +559,8 @@ render_top_n_view(binary_memory, MemoryList, Num, Pages, Page) -> Title = ?render([ ?W2(?GRAY_BG, "No | Pid", 16), ?W2(?RED_BG, " BinMemory", 14), - ?W(?GRAY_BG, "Name or Initial Call", 38), - ?W(?GRAY_BG, " Reductions", 21), + ?W(?GRAY_BG, "Name|>Lable|>Initial Call", 45), + ?W(?GRAY_BG, " Reductions", 14), ?W(?GRAY_BG, " MsgQueue", 10), ?W(?GRAY_BG, "Current Function", 32) ]), @@ -586,8 +588,8 @@ render_top_n_view(binary_memory, MemoryList, Num, Pages, Page) -> render_top_n_view(reductions, ReductionList, Num, Pages, Page) -> Title = ?render([ ?W2(?GRAY_BG, "No | Pid", 16), - ?W2(?RED_BG, " Reductions", 21), - ?W(?GRAY_BG, "Name or Initial Call", 38), + ?W2(?RED_BG, " Reductions", 15), + ?W(?GRAY_BG, "Name|>Lable|>Initial Call", 45), ?W(?GRAY_BG, " Memory", 13), ?W(?GRAY_BG, " MsgQueue", 10), ?W(?GRAY_BG, "Current Function", 33) @@ -617,8 +619,8 @@ render_top_n_view(total_heap_size, HeapList, Num, Pages, Page) -> Title = ?render([ ?W2(?GRAY_BG, "No | Pid", 16), ?W2(?RED_BG, " TotalHeapSize", 14), - ?W(?GRAY_BG, "Name or Initial Call", 38), - ?W(?GRAY_BG, " Reductions", 21), + ?W(?GRAY_BG, "Name|>Lable|>Initial Call", 45), + ?W(?GRAY_BG, " Reductions", 14), ?W(?GRAY_BG, " MsgQueue", 10), ?W(?GRAY_BG, "Current Function", 32) ]), @@ -647,9 +649,9 @@ render_top_n_view(message_queue_len, MQLenList, Num, Pages, Page) -> Title = ?render([ ?W2(?GRAY_BG, "No | Pid", 16), ?W2(?RED_BG, " MsgQueue", 11), - ?W(?GRAY_BG, "Name or Initial Call", 37), + ?W(?GRAY_BG, "Name|>Lable|>Initial Call", 44), ?W(?GRAY_BG, " Memory", 13), - ?W(?GRAY_BG, " Reductions", 21), + ?W(?GRAY_BG, " Reductions", 14), ?W(?GRAY_BG, "Current Function", 33) ]), {Start, ChoosePos} = observer_cli_lib:get_pos(Page, Num, Pages, erlang:length(MQLenList)), @@ -682,19 +684,19 @@ notify_pause_status() -> ?output("\e[31;1m PAUSE INPUT (p, r/rr, b/bb, h/hh, m/mm) to resume or q to quit \e[0m~n"). get_memory_format(Pos, Pos) -> - "|\e[42m~-3.3w|~-12.12s|~13.13s |~-38.38s|~21.21s| ~-9.9s|~-33.33s\e[49m|~n"; + "|\e[42m~-3.3w|~-12.12s|~13.13s |~-45.45s|~14.14s| ~-9.9s|~-33.33s\e[49m|~n"; get_memory_format(_Pos, _RankPos) -> - "|~-3.3w|~-12.12s|~13.13s |~-38.38s|~21.21s| ~-9.9s|~-33.33s|~n". + "|~-3.3w|~-12.12s|~13.13s |~-45.45s|~14.14s| ~-9.9s|~-33.33s|~n". get_reduction_format(Pos, Pos) -> - "|\e[42m~-3.3w|~-12.12s|~-21.21s|~-38.38s|~13.13s| ~-9.9s|~-34.34s\e[49m|~n"; + "|\e[42m~-3.3w|~-12.12s|~-15.15s|~-45.45s|~12.12s| ~-9.9s|~-34.34s\e[49m|~n"; get_reduction_format(_Pos, _RankPos) -> - "|~-3.3w|~-12.12s|~-21.21s|~-38.38s|~13.13s| ~-9.9s|~-34.34s|~n". + "|~-3.3w|~-12.12s|~-15.15s|~-45.45s|~12.12s| ~-9.9s|~-34.34s|~n". get_message_queue_format(Pos, Pos) -> - "|\e[42m~-3.3w|~-12.12s|~-11.11s|~-37.37s|~13.13s| ~-20.20s|~-34.34s\e[49m|~n"; + "|\e[42m~-3.3w|~-12.12s|~-11.11s|~-44.44s|~13.13s| ~-13.13s|~-34.34s\e[49m|~n"; get_message_queue_format(_Pos, _RankPos) -> - "|~-3.3w|~-12.12s|~-11.11s|~-37.37s|~13.13s| ~-20.20s|~-34.34s|~n". + "|~-3.3w|~-12.12s|~-11.11s|~-44.44s|~13.13s| ~-13.13s|~-34.34s|~n". refresh_next_time(proc_count, Type, Interval) -> erlang:send_after(Interval, self(), {proc_count, Type}); @@ -756,15 +758,39 @@ process_bar_format_style(Percents, IsLastLine) -> get_top_n_info(Item) -> {Pid, Val, Call = [IsName | _]} = Item, {CurFun, InitialCall} = get_current_initial_call(Call), - NameOrCall = display_name_or_initial_call(IsName, InitialCall, Pid), - {Pid, Val, CurFun, NameOrCall}. + Flag = display_unique_flag(IsName, InitialCall, Pid), + {Pid, Val, CurFun, Flag}. + +display_unique_flag(IsName, Call, Pid) -> + case choose_name(IsName) of + undefined -> + case choose_lable(Pid) of + undefined -> choose_call(Call, Pid); + Lable -> Lable + end; + Name -> + Name + end. -display_name_or_initial_call(IsName, _Call, _Pid) when is_atom(IsName) -> +choose_name(IsName) when is_atom(IsName) -> atom_to_list(IsName); -display_name_or_initial_call(_IsName, {proc_lib, init_p, 5}, Pid) -> +choose_name(_) -> + undefined. + +choose_lable(Pid) -> + case + erlang:function_exported(proc_lib, get_label, 1) andalso + proc_lib:get_label(Pid) + of + false -> undefined; + undefined -> undefined; + Lable -> io_lib:format("~p", [Lable]) + end. + +choose_call({proc_lib, init_p, 5}, Pid) -> %% translate gen_xxx behavior observer_cli_lib:mfa_to_list(proc_lib:translate_initial_call(Pid)); -display_name_or_initial_call(_IsName, Call, _Pid) -> +choose_call(Call, _Pid) -> observer_cli_lib:mfa_to_list(Call). get_refresh_prompt(proc_count, Type, Interval, Rows) -> @@ -775,14 +801,16 @@ get_refresh_prompt(proc_window, Type, Interval, Rows) -> get_stable_system_info() -> OtpRelease = erlang:system_info(otp_release), SysVersion = erlang:system_info(system_version) -- "\n", - {[ + { + [ OtpRelease, SysVersion, erlang:system_info(process_limit), erlang:system_info(port_limit), erlang:system_info(ets_limit) ], - erlang:system_info(port_parallelism)}. + erlang:system_info(port_parallelism) + }. get_atom_status() -> try erlang:system_info(atom_limit) of