X-Git-Url: https://git.xandkar.net/?p=beam_stats.git;a=blobdiff_plain;f=src%2Fbeam_stats_process.erl;h=412b4f855c056af74e86823c26a35f8dcf812287;hp=a06c48e2fd41fb073687720a0fc0989db0f6d37b;hb=fa175c943c5d08ca2fdf2156abc3023ccf8b9baa;hpb=5acc9b7d2c0966e92e539f9906ae9f0786ae3389 diff --git a/src/beam_stats_process.erl b/src/beam_stats_process.erl index a06c48e..412b4f8 100644 --- a/src/beam_stats_process.erl +++ b/src/beam_stats_process.erl @@ -9,6 +9,7 @@ -export( [ of_pid/1 + , print/1 ]). -type status() :: @@ -25,6 +26,10 @@ -type t() :: ?T{}. +%% ============================================================================ +%% Public API +%% ============================================================================ + -spec of_pid(pid()) -> t(). of_pid(Pid) -> @@ -42,6 +47,52 @@ of_pid(Pid) -> , message_queue_len = pid_info_exn(Pid, message_queue_len) }. +-spec print(t()) -> + ok. +print( + ?T + { pid = Pid + , registered_name = RegisteredNameOpt + , raw_initial_call = InitialCallRaw + , otp_initial_call = InitialCallOTPOpt + , otp_ancestors = AncestorsOpt + , status = Status + , memory = Memory + , total_heap_size = TotalHeapSize + , stack_size = StackSize + , message_queue_len = MsgQueueLen + } +) -> + io:format("--------------------------------------------------~n"), + io:format( + "Pid : ~p~n" + "RegisteredNameOpt : ~p~n" + "InitialCallRaw : ~p~n" + "InitialCallOTPOpt : ~p~n" + "AncestorsOpt : ~p~n" + "Status : ~p~n" + "Memory : ~p~n" + "TotalHeapSize : ~p~n" + "StackSize : ~p~n" + "MsgQueueLen : ~p~n" + "~n", + [ Pid + , RegisteredNameOpt + , InitialCallRaw + , InitialCallOTPOpt + , AncestorsOpt + , Status + , Memory + , TotalHeapSize + , StackSize + , MsgQueueLen + ] + ). + +%% ============================================================================ +%% Private helpers +%% ============================================================================ + pid_info_exn(Pid, Key) -> {some, Value} = pid_info_opt(Pid, Key), Value.