DalaDev.Remote.Debugger (dala_dev v0.0.6)

Copy Markdown View Source

Remote debugging functions for inspecting and controlling remote nodes.

These functions automatically use the node selected via DalaDev.Remote.select_node/1.

Summary

Functions

Evaluates Elixir code on the selected node.

Gets the state of a process on the selected node.

Inspects a process on the selected node.

Gets a memory report from the selected node.

Gets the supervision tree from the selected node.

Traces messages sent to/from a process on the selected node.

Functions

eval(code, opts \\ [])

@spec eval(
  String.t(),
  keyword()
) :: {:ok, term()} | {:error, term()}

Evaluates Elixir code on the selected node.

Returns {:ok, result} on success, {:error, reason} on failure.

Examples

iex> DalaDev.Remote.Debugger.eval("1 + 1")
{:ok, 2}

iex> DalaDev.Remote.Debugger.eval("Enum.map(1..3, &(&1 * 2))")
{:ok, [2, 4, 6]}

iex> DalaDev.Remote.Debugger.eval("MyApp.Config.get(:api_key)")
{:ok, "secret_key"}

get_state(pid_or_name, opts \\ [])

Gets the state of a process on the selected node.

Similar to :sys.get_state/1 from Erlang/OTP, this function retrieves the internal state of a process. The process must be a system process (e.g., a GenServer, GenStateMachine, or other process that implements the sys protocol).

Parameters

  • pid_or_name - A PID or registered name of the process

Returns

  • {:ok, state} on success, where state is the process state
  • {:error, reason} on failure

Examples

# Get state of a process by PID
iex> DalaDev.Remote.Debugger.get_state(#PID<0.123.0>)
{:ok, %{data: "...", status: :idle}}

# Get state of a process by registered name
iex> DalaDev.Remote.Debugger.get_state(:my_worker)
{:ok, %{count: 42}}

See Also

inspect_process(process_ref, opts \\ [])

@spec inspect_process(
  term(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Inspects a process on the selected node.

The process can be specified as:

  • A PID (e.g., #PID<0.123.0>)
  • A registered name (atom)
  • A module name (atom)
  • A {mod, fun} tuple

Returns {:ok, info} on success, {:error, reason} on failure.

memory_report(opts \\ [])

@spec memory_report(keyword()) :: {:ok, map()} | {:error, term()}

Gets a memory report from the selected node.

Returns {:ok, report} on success, {:error, reason} on failure.

supervision_tree(opts \\ [])

@spec supervision_tree(keyword()) :: {:ok, map()} | {:error, term()}

Gets the supervision tree from the selected node.

Returns {:ok, tree} on success, {:error, reason} on failure.

trace_messages(process_ref, opts \\ [])

@spec trace_messages(
  term(),
  keyword()
) :: {:ok, [map()]} | {:error, term()}

Traces messages sent to/from a process on the selected node.

Returns {:ok, messages} on success, {:error, reason} on failure.

Options

  • :duration - Tracing duration in ms (default: 5000)
  • :timeout - RPC timeout in ms (defaults to remote timeout)