-
Notifications
You must be signed in to change notification settings - Fork 3.4k
IEx.Helpers.process_info/1 #14418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IEx.Helpers.process_info/1 #14418
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One suggestion and we can ship it. Let's add docs too.
end | ||
|
||
defp print_process_overview(info) do | ||
print_pane("Overview") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, let's print the process itself in the overview, it is useful if you do Enum.map(pids, &process_info/1).
Co-authored-by: José Valim <[email protected]>
end | ||
end | ||
|
||
defp print_process_stacktrace([]), do: :ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this ever happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe if the process is hibernating? 🤔 But I think it is a good clause to have anyway, it may happen in other scenarios.
defp pid_or_port_details(pid) when is_pid(pid), do: to_process_details(pid) | ||
defp pid_or_port_details(name) when is_atom(name), do: to_process_details(name) | ||
defp pid_or_port_details(port) when is_port(port), do: to_port_details(port) | ||
defp pid_or_port_details(reference) when is_reference(reference), do: reference | ||
|
||
defp to_process_details(pid) when is_pid(pid) do | ||
case Process.info(pid, [:initial_call, :dictionary, :registered_name]) do | ||
[{:initial_call, initial_call}, {:dictionary, dictionary}, {:registered_name, name}] -> | ||
initial_call = Keyword.get(dictionary, :"$initial_call", initial_call) | ||
|
||
format_registered_name(name) || | ||
format_process_label(Keyword.get(dictionary, :"$process_label")) || | ||
format_initial_call(initial_call) | ||
|
||
_ -> | ||
"-" | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part is adjusted from https://github.com/phoenixframework/phoenix_live_dashboard/blob/8c80084ac9d2bc417115fe00bbde0a7c66222226/lib/phoenix/live_dashboard/system_info.ex#L794-L817; I'm not 100% sure what this implies about LICENSE attribution.
💚 💙 💜 💛 ❤️ |
@josevalim as discussed, a first draft for a
process_info
helper in IEx.