AgentSkillsCN

troubleshoot-amiberry

Amiberry Bug 的自主排查工作流。适用于调查、复现或修复 Amiberry 中的 Bug 时使用。借助 Amiberry MCP 服务器工具,提供完整的编辑→构建→运行→测试→修复循环,用于流程管理、IPC 控制、截图分析、日志监控与崩溃检测。

SKILL.md
--- frontmatter
name: troubleshoot-amiberry
description: Autonomous troubleshooting workflow for Amiberry bugs. Use this when investigating, reproducing, or fixing bugs in Amiberry. Provides a complete edit-build-run-test-fix cycle using the Amiberry MCP server tools for process management, IPC control, screenshot analysis, log monitoring, and crash detection.
allowed-tools: Bash(cmake:*), Bash(make:*), Bash(wsl:*), Read, Write, Edit, Grep, Glob
argument-hint: [bug description or issue number]

Amiberry Autonomous Troubleshooting

Debug and fix Amiberry bugs through iterative edit-build-run-test-fix cycles with minimal user interaction.

Bug to investigate

$ARGUMENTS

Environment

Amiberry source is at the current working directory (or a nearby amiberry/ directory). The MCP server (amiberry-mcp-server) provides tools for runtime control.

Determine the platform before building:

  • macOS: Build natively with cmake
  • Linux / WSL2: Build with cmake (use wsl -e prefix if on Windows host)

Build Commands

bash
# Configure (first time or after CMake changes)
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DUSE_IPC_SOCKET=ON

# Build (subsequent changes)
cmake --build build -j$(nproc)

On Windows host targeting WSL2:

bash
wsl -e bash -c "cd ~/amiberry && cmake --build build -j$(nproc)"

Troubleshooting Workflow

Phase 1: Understand the Bug

  1. Read the bug description / issue carefully
  2. Identify which subsystem is likely involved (graphics, input, audio, CPU emulation, chipset, config, GUI, etc.)
  3. Search the codebase for relevant code:
    • Use Grep to find related functions, variables, error messages
    • Use Glob to find relevant source files
    • Read the code to understand the current behavior
  4. Form a hypothesis about the root cause

Phase 2: Reproduce

  1. Launch Amiberry with appropriate config:

    • Use launch_and_wait_for_ipc to start Amiberry and wait for IPC readiness
    • Specify a model (A500, A1200, etc.) or config file as needed
    • This automatically enables logging
  2. Verify it's running:

    • Use health_check to confirm process + IPC + emulation status
  3. Set up the reproduction scenario:

    • Use runtime_load_config to load specific configurations
    • Use runtime_insert_floppy to insert disk images
    • Use send_key to navigate menus or trigger actions
    • Use runtime_set_config to change specific options
  4. Observe the behavior:

    • Use runtime_screenshot_view to see what's on screen
    • Use tail_log to monitor log output
    • Use runtime_get_fps to check performance
    • Use runtime_get_cpu_regs / runtime_get_custom_regs for hardware state
  5. If it crashes:

    • Use get_crash_info to detect the crash and analyze signals + log patterns
    • Use get_process_info for exit code and signal details

Phase 3: Fix

  1. Make code changes using Edit tool on the Amiberry source files
  2. Keep changes minimal - fix only what's broken, don't refactor surrounding code
  3. Kill the running instance: Use kill_amiberry
  4. Rebuild:
    bash
    cmake --build build -j$(nproc)
    
  5. Check build output for errors. If build fails, fix and retry.

Phase 4: Verify

  1. Restart with same config: Use restart_amiberry or launch_and_wait_for_ipc

  2. Run the same reproduction steps from Phase 2

  3. Check results:

    • runtime_screenshot_view - does the screen look correct?
    • tail_log - are there still errors/warnings?
    • get_crash_info - did it crash again?
    • health_check - is everything still running?
  4. If NOT fixed: Go back to Phase 3 with new hypothesis

  5. If fixed: Clean up and report findings

Phase 5: Report

Summarize:

  • What the bug was (root cause)
  • What was changed (files and line numbers)
  • How to verify the fix
  • Any side effects or concerns

Available MCP Tools Reference

Process Lifecycle

ToolPurpose
check_process_aliveIs Amiberry running? Returns PID + exit code
get_process_infoDetailed info: PID, status, signal, crash detection
kill_amiberryForce kill (SIGTERM then SIGKILL)
wait_for_exitBlock until process exits (with timeout)
restart_amiberryKill + relaunch with same command

Workflow

ToolPurpose
launch_and_wait_for_ipcLaunch with logging, wait for IPC ready
health_checkCombined: process + IPC ping + status + FPS

Observation

ToolPurpose
runtime_screenshot_viewScreenshot returned as image data
tail_logNew log lines since last read
wait_for_log_patternWait for regex in log (with timeout)
get_crash_infoProcess signals + log crash pattern scanning

Emulation Control

ToolPurpose
pause_emulation / resume_emulationPause/resume
reset_emulationSoft or hard reset
frame_advanceStep N frames when paused
runtime_set_config / runtime_get_configChange/query config at runtime
runtime_load_configLoad a .uae config file

Debugging

ToolPurpose
runtime_get_cpu_regsAll CPU registers (D0-D7, A0-A7, PC, SR)
runtime_get_custom_regsCustom chip registers (DMACON, INTENA, etc.)
runtime_read_memoryRead Amiga memory (1/2/4 bytes)
runtime_write_memoryWrite Amiga memory
runtime_disassembleDisassemble at address
runtime_set_breakpoint / runtime_clear_breakpointBreakpoints
runtime_debug_activate / runtime_debug_stepDebugger control
runtime_debug_step_overStep over JSR/BSR
runtime_get_copper_state / runtime_get_blitter_stateHardware state

Media & Display

ToolPurpose
runtime_insert_floppy / runtime_eject_floppyFloppy management
runtime_insert_cd / runtime_eject_cdCD management
send_keySend keyboard input (Amiga keycodes)
runtime_set_display_modeWindow/fullscreen/fullwindow
runtime_set_ntscPAL/NTSC switching

Amiga Keycodes (common)

KeyCodeKeyCode
Return0x44Space0x40
Escape0x45Backspace0x41
Up0x4CDown0x4D
Left0x4FRight0x4E
F1-F100x50-0x59Help0x5F
Left Amiga0x66Right Amiga0x67
A-Z0x20,0x35,0x33,0x22,0x12,0x23,0x24,0x25,0x17,0x26,0x27,0x28,0x37,0x36,0x18,0x19,0x10,0x13,0x21,0x14,0x16,0x34,0x11,0x32,0x15,0x31

To send a keypress, call send_key twice: once with state=1 (press), then state=0 (release).

Key Source Directories

DirectoryContents
src/Core emulation (UAE-derived)
src/osdep/Platform abstraction (Linux/macOS/Android)
src/osdep/imgui/GUI panels (Dear ImGui)
src/include/Headers and interfaces
src/osdep/amiberry_ipc_socket.cppIPC socket implementation
src/osdep/amiberry_gfx.cppGraphics/display
src/osdep/amiberry_input.cppInput handling
src/osdep/amiberry.cppCore platform layer

Tips

  • Always use --log (handled automatically by launch_and_wait_for_ipc) for log output
  • Use tail_log frequently to catch errors early
  • If the screen looks wrong, pause_emulation + runtime_screenshot_view gives a stable frame
  • For timing-sensitive bugs, use runtime_set_config to change CPU speed or floppy speed
  • For crashes, the signal name in get_crash_info tells you a lot: SIGSEGV = null pointer/bad memory, SIGABRT = assertion/abort, SIGBUS = alignment
  • Build with Debug type (-DCMAKE_BUILD_TYPE=Debug) for better crash info
  • If you need to test multiple configs, use kill_amiberry + launch_and_wait_for_ipc between each