feat(runtime): report where a title stops and break into an attached debugger #65

Manually merged
github merged 1 commit from gh-pr/65/head into gh-pr/65/base 2026-11-26 19:17:07 +00:00
Owner

@⁠Dark3581 on GitHub · 2026-11-23 01:48 UTC · original
Dark3581:feat/bringup-debugging → main · +249 −8 · 9 files · 1 commits · merged 2026-11-23 01:51 UTC

What

Debugging support for the first runs of a real executable. A stop now says where in the title it was reached, and a debugger can be attached at the right moment:

  • Backtraces in the run report and the log. AbxNotImplemented and AbxUnsupported capture up to 32 frames of the stopping thread. A crash unwinds the faulting context with the modules' unwind tables (frames without unwind data are read as leaves, bounded by the thread's stack). The report's stop gains:

    • frames: each frame's module, offset and address;
    • caller: the first frame outside AnyBox's ab_* modules and the Windows directory, which is the title's call site, or null when the title is not on the stack (for example on an AnyBox worker thread).

    The relinker leaves the title's sections in place, so the caller's offset is the same RVA in the original executable to open in Ghidra or IDA.

  • The log gets called from title.exe+0x… or crashed in … and the numbered frames. The run_report_summary.py line ends with (called from module+offset).

  • Debugger break: with a debugger attached, a stop breaks into it after writing the report and before the process exits, so the title's state at the call can be inspected. ANYBOX_BREAK=0 turns it off.

  • ANYBOX_WAIT_DEBUGGER=<seconds>: logs the process ID, waits for a debugger to attach, and breaks before the title's entry point. This is for titles that a launcher starts.

  • The schema gains caller and frames as optional fields, so existing reports stay valid at version 1.

  • docs/dev/GAME_TESTING.md gets a "Debugging a stop" section (how to go from a caller offset to the call in a disassembler, plus the environment variables), and the README links to it.

Tested

Windows 10, MinGW (GCC) and MSVC 2022.

  • The e2e tests relink the fake title and assert on its report and log:
    • stub, unsupported and device stops: caller is title.exe+0x…, the first frame is in ab_xgameruntime.dll, and the log has the called from line;
    • a stop on an AnyBox worker thread: caller is null and the frames are present;
    • both crash scenarios: the first frame is the faulting instruction in title.exe and matches exception.offset.
  • New e2e_stub_debugger: starts the relinked title with ANYBOX_WAIT_DEBUGGER, attaches a minimal debugger (DebugActiveProcess) once the waiting line appears, and checks the start-up break and the break at the stop. Exit code is still 0xAB01. It passed 8 repeats. A manual run with ANYBOX_BREAK=0 gets only the start-up and attach breaks, and ANYBOX_WAIT_DEBUGGER=1 without a debugger continues after the wait.
  • MinGW ctest: 73 of 73. With MSVC the stub, crash, device, worker and debugger e2e tests pass, and every target builds except ab_gameinput, which needs gameinput.lib, which this machine doesn't have. python tools/check_conventions.py and debt_fold.py --check: ok.

Example log line from the stub scenario: [anybox] called from title.exe+0x31013.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • python tools/check_conventions.py passes (no comments in code, one declaration per export, Conventional Commit subjects)
  • Unimplemented paths stop (AbxNotImplemented / AbxUnsupported); silent stubs are listed under Silent stubs through a debt fragment
  • Known gaps added, changed or removed through docs/dev/debt/changes/<branch>.md
  • Generic behaviour, not specific to one title
  • No game files, keys, notes or logs added to the repository
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • Source of behaviour: Win32 documentation (RtlCaptureStackBackTrace, RtlLookupFunctionEntry, RtlVirtualUnwind, IsDebuggerPresent, DebugActiveProcess)
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-23 01:48 UTC · [original](https://github.com/Dark3581/AnyBox/pull/65) `Dark3581:feat/bringup-debugging` → `main` · +249 −8 · 9 files · 1 commits · merged 2026-11-23 01:51 UTC ### What Debugging support for the first runs of a real executable. A stop now says where in the title it was reached, and a debugger can be attached at the right moment: - **Backtraces in the run report and the log.** `AbxNotImplemented` and `AbxUnsupported` capture up to 32 frames of the stopping thread. A crash unwinds the faulting context with the modules' unwind tables (frames without unwind data are read as leaves, bounded by the thread's stack). The report's `stop` gains: - `frames`: each frame's module, offset and address; - `caller`: the first frame outside AnyBox's `ab_*` modules and the Windows directory, which is the title's call site, or null when the title is not on the stack (for example on an AnyBox worker thread). The relinker leaves the title's sections in place, so the caller's offset is the same RVA in the original executable to open in Ghidra or IDA. - The log gets `called from title.exe+0x…` or `crashed in …` and the numbered frames. The `run_report_summary.py` line ends with `(called from module+offset)`. - **Debugger break:** with a debugger attached, a stop breaks into it after writing the report and before the process exits, so the title's state at the call can be inspected. `ANYBOX_BREAK=0` turns it off. - **`ANYBOX_WAIT_DEBUGGER=<seconds>`:** logs the process ID, waits for a debugger to attach, and breaks before the title's entry point. This is for titles that a launcher starts. - The schema gains `caller` and `frames` as optional fields, so existing reports stay valid at version 1. - `docs/dev/GAME_TESTING.md` gets a "Debugging a stop" section (how to go from a caller offset to the call in a disassembler, plus the environment variables), and the README links to it. ### Tested Windows 10, MinGW (GCC) and MSVC 2022. - The e2e tests relink the fake title and assert on its report and log: - stub, unsupported and device stops: `caller` is `title.exe+0x…`, the first frame is in `ab_xgameruntime.dll`, and the log has the `called from` line; - a stop on an AnyBox worker thread: `caller` is null and the frames are present; - both crash scenarios: the first frame is the faulting instruction in `title.exe` and matches `exception.offset`. - New `e2e_stub_debugger`: starts the relinked title with `ANYBOX_WAIT_DEBUGGER`, attaches a minimal debugger (`DebugActiveProcess`) once the waiting line appears, and checks the start-up break and the break at the stop. Exit code is still `0xAB01`. It passed 8 repeats. A manual run with `ANYBOX_BREAK=0` gets only the start-up and attach breaks, and `ANYBOX_WAIT_DEBUGGER=1` without a debugger continues after the wait. - MinGW `ctest`: 73 of 73. With MSVC the stub, crash, device, worker and debugger e2e tests pass, and every target builds except `ab_gameinput`, which needs `gameinput.lib`, which this machine doesn't have. `python tools/check_conventions.py` and `debt_fold.py --check`: ok. Example log line from the stub scenario: `[anybox] called from title.exe+0x31013`. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] `python tools/check_conventions.py` passes (no comments in code, one declaration per export, Conventional Commit subjects) - [x] Unimplemented paths stop (`AbxNotImplemented` / `AbxUnsupported`); silent stubs are listed under Silent stubs through a debt fragment - [x] Known gaps added, changed or removed through `docs/dev/debt/changes/<branch>.md` - [x] Generic behaviour, not specific to one title - [x] No game files, keys, notes or logs added to the repository - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] Source of behaviour: Win32 documentation (`RtlCaptureStackBackTrace`, `RtlLookupFunctionEntry`, `RtlVirtualUnwind`, `IsDebuggerPresent`, `DebugActiveProcess`) - [x] AI-assisted: yes
Stops and crashes now record up to 32 frames and the caller, the first frame in the title, as module and offset, which is the same RVA in the original executable. With a debugger attached a stop breaks into it before the process exits, and ANYBOX_WAIT_DEBUGGER waits for one at start-up and breaks before the title runs.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:17:05 +00:00
github manually merged commit 947cff90c2 into gh-pr/65/base 2026-11-26 19:17:07 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.