Skip to content

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

Merged
merged 3 commits into from
Apr 10, 2025
Merged

Conversation

SteffenDE
Copy link
Contributor

@josevalim as discussed, a first draft for a process_info helper in IEx.

Copy link
Member

@josevalim josevalim left a 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")
Copy link
Member

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).

end
end

defp print_process_stacktrace([]), do: :ok
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this ever happen?

Copy link
Member

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.

Comment on lines +951 to +968
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SteffenDE SteffenDE marked this pull request as ready for review April 10, 2025 14:08
@josevalim josevalim merged commit ec4cc25 into elixir-lang:main Apr 10, 2025
11 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants