> ## Documentation Index
> Fetch the complete documentation index at: https://docs.embedder.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Debug Mode

> Switch to a hardware-aware mode where Embedder can drive a debugger and bench instruments to diagnose your firmware

Debug mode is a dedicated agent mode for diagnosing real hardware problems. You stay in plain language — describe what's wrong, ask for what you want to know — and Embedder uses GDB, logic analyzers, oscilloscopes, and power analyzers to investigate.

Use it when you have a board on the bench and a problem you can't pin down from source alone: an MCU that hangs, an I²C bus that NACKs intermittently, sleep current that's 10× expected, a clock that won't lock.

## Enter debug mode

<Tabs>
  <Tab title="Slash command">
    ```txt embedder theme={"system"}
    /debug
    ```
  </Tab>

  <Tab title="Keyboard">
    Press `Shift+Tab` to cycle Act → Plan → Debug. Works in the terminal TUI, the VS Code extension, and the standalone app.
  </Tab>

  <Tab title="Mode pill (VS Code / standalone)">
    Click the **Debug** option in the mode pill at the top of the composer.
  </Tab>
</Tabs>

<Frame caption="Switching to debug mode in the TUI">
  <img src="https://mintcdn.com/embedder/nSMaECJmg2LXNFbW/images/enter-debug.gif?s=7a5dc54ee7c46cd8279cb0bcbbb81785" alt="Embedder TUI cycling Act → Plan → Debug with Shift+Tab" width="800" height="533" data-path="images/enter-debug.gif" />
</Frame>

On entry, Embedder checks for a connected J-Link probe (and offers to install J-Link software if missing), runs `hardware_status` to list every connected instrument, and auto-loads the helper docs for each one. Python helpers for power analyzers (`ppk2-api`, `joulescope`) and logic analyzers (`logic2-automation`, `dwfpy`) are installed on first use, not at mode entry — you'll get a confirmation prompt the first time the agent tries to run a script for a given device.

<Tip>
  Always enter debug mode *before* asking the agent to probe. Outside of debug mode, the GDB and instrument tools are unavailable and the agent can't run them.
</Tip>

## How to prompt in debug mode

Describe the symptom in natural language. Embedder picks the right instrument and writes the script for you.

```txt embedder theme={"system"}
> the device isn't logging anything — use gdb to figure out where it's hanging
```

```txt embedder theme={"system"}
> capture 2 seconds of I²C on the BME280 and show me the addresses
```

```txt embedder theme={"system"}
> measure sleep current on this board at 3.3V for 5 seconds
```

```txt embedder theme={"system"}
> the chip resets when the motor PWM kicks in — find out why
```

You don't need to name the tool. If you say "is this clock signal clean?" the agent reaches for the scope; "capture UART" reaches for the logic analyzer. Naming the tool ("use gdb", "use the Joulescope") narrows the choice when there's ambiguity.

## What the agent does behind the scenes

For every problem, Embedder follows a structured **Observe → Hypothesize → Probe → Verify** loop:

<Steps>
  <Step title="Observe">
    Reads the `hardware_status` snapshot, recent serial / RTT history, current GDB state, and the source files involved.
  </Step>

  <Step title="Hypothesize">
    Lists candidate root causes and prioritizes them by likelihood and ease of verification.
  </Step>

  <Step title="Probe">
    Writes and runs a Python script under `.embedder/hardware/` that drives the chosen instruments.
  </Step>

  <Step title="Verify">
    Checks the probe results against each hypothesis. Either narrows the next probe or reports the root cause.
  </Step>
</Steps>

## Sub-guides

<CardGroup cols={2}>
  <Card title="GDB" icon="bug" href="/debug-mode/gdb">
    Inspect register state, set breakpoints, walk RTOS task lists, snapshot a live target without resetting it.
  </Card>

  <Card title="Logic analyzer" icon="wave-square" href="/debug-mode/logic-analyzer">
    Capture and decode SPI, I²C, UART, CAN, USB, and 18 other digital protocols.
  </Card>

  <Card title="Power analyzer" icon="bolt" href="/debug-mode/power-analyzer">
    Profile sleep current, boot energy, and active draw with PPK2 or Joulescope.
  </Card>

  <Card title="Oscilloscope" icon="chart-line" href="/debug-mode/oscilloscope">
    Probe analog signals — clock, reset, power rails, comm lines.
  </Card>
</CardGroup>

<Card title="Combined workflows" icon="diagram-project" href="/debug-mode/combined-workflows">
  Worked scenarios that need multiple instruments — sleep-current regression, intermittent I²C NACK, brown-out under load.
</Card>

## Tips

* Re-prompt with "refresh hardware status" if you plug in a new instrument mid-session — the agent only auto-detects on entry.
* The agent prefers non-destructive probes by default. If you want it to flash firmware, reset the chip, or erase memory, say so explicitly.
* Sessions in debug mode block `submitWork` — you'll need to leave debug mode (or end the session) to mark the work as done.

## Availability

Debug mode is enabled in standard Embedder builds. Some enterprise builds (e.g. the `infineon` distribution) ship with debug mode disabled — in those cases the `/debug` slash command is hidden and the agent will report "Debug mode unavailable" if asked to switch.
