Skip to main content

Autonomous Debugging

Overview​

In autonomous mode, the AI launches and fully controls the debug session. No human in the loop during the session. The AI spawns mcu-debug as a subprocess, controls stdin, and reads all output from stdout.

Starting a Session​

The AI spawns mcu-debug in terminal mode (stdout is redirected, so no-tui activates automatically):

mcu-debug debug -c "Launch PSoC6 CM4"

Additional arguments to mcu-debug can be sent as the need arises. See mcu-debug debug --help

Or explicitly:

mcu-debug debug -c "Launch PSoC6 CM4" --no-tui

Stdout is the tagged mux stream. Stdin accepts GDB commands and meta-commands.

Session Initialization​

At session start, the AI should:

  1. Wait for the [mcu-debug] Target halted message (or similar — check with status)
  2. Run status to get the complete session state — socket path, log file, notes file location, connected sources
  3. Read .mcu-debug/notes.json to resume any prior investigation context
status

Reading Session Notes​

# Read notes from a prior session
cat .mcu-debug/notes.json

If notes exist, start from the current working theory and ruled-out list rather than starting fresh.

The Debug Loop​

Typical autonomous AI debugging cycle:

  1. Issue status to orient — understand current halt state, active sources
  2. Read existing notes from .mcu-debug/notes.json
  3. Run the target: continue
  4. Observe tagged output stream for anomalies
  5. Issue !!SIGINT to pause when interesting output appears
  6. Inspect state with GDB commands: backtrace, print variable, x/16x address
  7. Update notes via !!NOTE to record findings
  8. Form a hypothesis, add instrumentation, rebuild firmware, restart session
  9. Repeat

CI/CD Use​

In CI/CD pipelines, mcu-debug can be used for automated hardware-in-the-loop testing:

# Run a script of commands unattended, then exit
mcu-debug debug -c "Test Config" --batch --script tests/run_tests.txt

With --batch, commands run one at a time. Each continue or step waits until the target stops again. The session exits when the script ends: with status 0 when every command succeeded, and with status 1 at the first one that failed. That status is the CI/CD pipeline result. See --batch for the details.

Logging​

All session output is written to .mcu-debug/cli.log. This provides a complete record for post-session analysis. The log file path is included in the status output.

grep "ERROR\|FAULT\|assert" .mcu-debug/cli.log