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

Advanced debugging tools for remote Elixir nodes.

Provides process inspection, state introspection, remote code evaluation,
and memory analysis for dala Elixir cluster debugging.

## Examples

    # Inspect a process on a remote node
    {:ok, info} = DalaDev.Debugger.inspect_process(
      :"dala_qa@192.168.1.5",
      MyApp.Worker
    )

    # Get supervision tree
    {:ok, tree} = DalaDev.Debugger.get_supervision_tree(node)

    # Evaluate code on remote node
    {:ok, result} = DalaDev.Debugger.eval_remote(
      node,
      "MyApp.Config.get(:api_key)"
    )

    # Get memory report
    {:ok, report} = DalaDev.Debugger.memory_report(node)

# `node_ref`

```elixir
@type node_ref() :: node() | DalaDev.Device.t() | String.t()
```

# `process_ref`

```elixir
@type process_ref() :: pid() | atom() | {atom(), atom()} | module()
```

# `eval_remote`

```elixir
@spec eval_remote(node_ref(), String.t(), keyword()) ::
  {:ok, any()} | {:error, term()}
```

Evaluate Elixir code on a remote node.

The code string is evaluated using `Code.eval_string/1` on the remote node.

Options:
- `:timeout` - RPC timeout in ms (default: 30_000)
- `:bindings` - Variables to bind in the evaluation context

# `get_process_state_local`

```elixir
@spec get_process_state_local(pid() | atom() | {atom(), atom()}) :: term() | nil
```

Gets the state of a process.

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

- The process state, or `nil` if the process is not found or doesn't have state

## See Also

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

# `get_supervision_tree`

# `get_supervision_tree`

```elixir
@spec get_supervision_tree(
  node_ref(),
  keyword()
) :: {:ok, map()} | {:error, term()}
```

Get the supervision tree of a node.

Returns a tree structure showing all supervisors and their children.

# `inspect_process`

```elixir
@spec inspect_process(node_ref(), process_ref(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Inspect a process on a remote node.

Returns detailed information including:
- Process dictionary
- Current state (if GenServer/GenStateMachine)
- Message queue
- Links and monitors
- Memory usage

Options:
- `:timeout` - RPC timeout in ms (default: 10_000)

# `memory_report`

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

Get a detailed memory report for a node.

Returns memory breakdown including:
- Total memory
- Process memory
- Binary memory
- ETS memory
- Atom memory

# `trace_messages`

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

Trace messages sent to/from a process.

Options:
- `:duration` - Tracing duration in ms (default: 5_000)
- `:timeout` - RPC timeout in ms (default: duration + 1_000)

---

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