# `DalaDev.Remote.Debugger`
[🔗](https://github.com/manhvu/dala_dev/blob/main/lib/dala_dev/remote.ex#L212)

Remote debugging functions for inspecting and controlling remote nodes.

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

# `eval`

```elixir
@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`

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

- [Erlang sys:get_state/1](https://www.erlang.org/doc/apps/stdlib/sys.html#get_state/1)

# `inspect_process`

```elixir
@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`

```elixir
@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`

```elixir
@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`

```elixir
@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)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
