tooling: end a startup debugger run when <logdir>/stop appears #2468

Merged
denn0x merged 3 commits from upstream-pr/2476 into main 2026-11-25 20:25:16 +00:00
denn0x commented 2026-11-25 17:52:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-25T17:52:18Z.


What

tools/startup/debug_launch.py can only be ended early by killing it, and killing it skips the final thread dump. With this change, the launcher checks twice a second for a file named stop in the log directory.

  • On a stop file: the run ends the way it does at the timeout. The thread stacks go to threads.txt, X2W_DUMP runs, and the rip histogram is printed. The summary and finished.txt say stopped by request after X s (stop file) instead of timeout after X s, and events.txt logs stop file found.
  • Stale file: a stop file left over from an earlier run in a reused log directory is removed at start, like trap.log and finished.txt.

Test

tests/startup_debug_check.py (the existing startup_debug CTest) gains two cases on the source-built probe. The probe waits 3 s before it exits.

  • Stop file: the check creates <logdir>/stop 1.5 s into the run. The run reports stopped by request, not process exited. events.txt logs it, and threads.txt holds stacks.
  • Control: a stop file present in the directory before the run is removed at start, and the probe exits 0.
  • Negative control: with main's debug_launch.py, the stop-file case fails, because the probe runs to its own exit.
python -B tests/startup_debug_check.py out/build/<dir>/startup_debug_probe.exe out/build/<dir>/startup_debug_calls.dll
startup_debug: PASS (stop at a chosen assert, timed thread dump, large-allocation log, debug heap off, call hooks opt-in, bounded register and qword logging)

Environment

  • Build: all builds (Ninja Release, MSVC Build Tools 18).
  • Software: Windows 10.0.26300.9974.
  • GPU: no GPU involved, no capability skips.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6610421475 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2476). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-25T17:52:18Z. --- ## What `tools/startup/debug_launch.py` can only be ended early by killing it, and killing it skips the final thread dump. With this change, the launcher checks twice a second for a file named `stop` in the log directory. - **On a stop file:** the run ends the way it does at the timeout. The thread stacks go to `threads.txt`, `X2W_DUMP` runs, and the rip histogram is printed. The summary and `finished.txt` say `stopped by request after X s (stop file)` instead of `timeout after X s`, and `events.txt` logs `stop file found`. - **Stale file:** a stop file left over from an earlier run in a reused log directory is removed at start, like `trap.log` and `finished.txt`. ## Test `tests/startup_debug_check.py` (the existing `startup_debug` CTest) gains two cases on the source-built probe. The probe waits 3 s before it exits. - **Stop file:** the check creates `<logdir>/stop` 1.5 s into the run. The run reports `stopped by request`, not `process exited`. `events.txt` logs it, and `threads.txt` holds stacks. - **Control:** a stop file present in the directory before the run is removed at start, and the probe exits 0. - **Negative control:** with `main`'s `debug_launch.py`, the stop-file case fails, because the probe runs to its own exit. ``` python -B tests/startup_debug_check.py out/build/<dir>/startup_debug_probe.exe out/build/<dir>/startup_debug_calls.dll startup_debug: PASS (stop at a chosen assert, timed thread dump, large-allocation log, debug heap off, call hooks opt-in, bounded register and qword logging) ``` **Environment** - **Build:** `all` builds (Ninja Release, MSVC Build Tools 18). - **Software:** Windows 10.0.26300.9974. - **GPU:** no GPU involved, no capability skips.
tedin7 commented 2026-11-25 19:03:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T18:40:27Z.

Review: COMMENTED


Review of head da6342a (tooling only, 2 files, +44/-3). No startup-progress claim, so nothing here needs a game result.

Code (tools/startup/debug_launch.py)

  • The stop file is removed at start together with trap.log and finished.txt, so a reused log dir starts clean.
  • The poll runs every 0.5 s inside the existing loop and breaks into the same post-loop path as the timeout. The process is still alive there, so it reaches the else branch (thread dump, X2W_DUMP, rip histogram). Only the summary text differs. Correct.

Test (tests/startup_debug_check.py)

  • It extends the existing startup_debug check on the source-built probe, with no new CTest. It has a stop case and a stale-file control. The PR text also describes a negative control against main's launcher.
  • Minor, not blocking: run_with_stop writes <logdir>/stop after a fixed 1.5 s sleep. If the launcher has not created <logdir> yet (slow Python start on a loaded runner), write_text raises FileNotFoundError. A logdir.mkdir(exist_ok=True) before the write removes that flake.
  • Minor: the module docstring line got long.
  • Minor: docs/startup-runtime.md documents the launcher but does not mention the stop file.

Windows results

  • The author posted a Windows run (startup_debug: PASS) in the PR body. The body gives no head SHA, so I cannot say which head it covers. I did not re-run it.
  • The negative control is stated by the author. I did not verify it, because the test needs the Windows probe exe.

Commands I ran locally (Linux worktree at the head SHA)

  • git diff --check origin/main...HEAD: clean
  • python3 -I -m py_compile on both files: OK
  • python3 tests/docs_links_check.py: pass
  • python3 tests/bidi_controls_check.py: pass
  • PR CI: 3 SUCCESS, 2 SKIPPED
  • Mutation of the code under test: not run, the test cannot execute on Linux.

No duplicate PR found (searched "debug_launch stop file"). No Windows VM was used and no merge action is taken here.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6063049881 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2476#pullrequestreview-6063049881). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T18:40:27Z. **Review:** COMMENTED --- Review of head da6342a (tooling only, 2 files, +44/-3). No startup-progress claim, so nothing here needs a game result. **Code (`tools/startup/debug_launch.py`)** - The stop file is removed at start together with `trap.log` and `finished.txt`, so a reused log dir starts clean. - The poll runs every 0.5 s inside the existing loop and `break`s into the same post-loop path as the timeout. The process is still alive there, so it reaches the `else` branch (thread dump, `X2W_DUMP`, rip histogram). Only the summary text differs. Correct. **Test (`tests/startup_debug_check.py`)** - It extends the existing `startup_debug` check on the source-built probe, with no new CTest. It has a stop case and a stale-file control. The PR text also describes a negative control against `main`'s launcher. - Minor, not blocking: `run_with_stop` writes `<logdir>/stop` after a fixed 1.5 s sleep. If the launcher has not created `<logdir>` yet (slow Python start on a loaded runner), `write_text` raises FileNotFoundError. A `logdir.mkdir(exist_ok=True)` before the write removes that flake. - Minor: the module docstring line got long. - Minor: `docs/startup-runtime.md` documents the launcher but does not mention the stop file. **Windows results** - The author posted a Windows run (`startup_debug: PASS`) in the PR body. The body gives no head SHA, so I cannot say which head it covers. I did not re-run it. - The negative control is stated by the author. I did not verify it, because the test needs the Windows probe exe. **Commands I ran locally (Linux worktree at the head SHA)** - `git diff --check origin/main...HEAD`: clean - `python3 -I -m py_compile` on both files: OK - `python3 tests/docs_links_check.py`: pass - `python3 tests/bidi_controls_check.py`: pass - PR CI: 3 SUCCESS, 2 SKIPPED - Mutation of the code under test: not run, the test cannot execute on Linux. No duplicate PR found (searched "debug_launch stop file"). No Windows VM was used and no merge action is taken here. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 20:04:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T19:05:26Z.

Review: COMMENTED


Review of head 79093c7b (same change as da6342a7 plus a merge of main).

  • tools/startup/debug_launch.py: the stop file is polled every 0.5 s, the loop breaks into the same path as the timeout (thread dump, X2W_DUMP, histogram), and a stale stop is removed at start. Message and events.txt line match the description.
  • tests/startup_debug_check.py: new stop-file case (file created 1.5 s into a 3 s probe, expects stopped by request, events.txt line and threads.txt stacks) and a stale-file control. This extends the existing startup_debug CTest, no new test target.
  • Not a main executable change and no startup claim, so no game run is needed.

Commands run locally: python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py, git diff --check origin/main...HEAD, python3 -m py_compile on both files (all OK). Win2025: ctest -R '^startup_debug' dev 1/1 and release 1/1 passed (receipt below). I did not re-run the negative control against main's launcher myself; the PR body states it.

No blocking findings.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6063383785 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2476#pullrequestreview-6063383785). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T19:05:26Z. **Review:** COMMENTED --- Review of head 79093c7b (same change as da6342a7 plus a merge of main). - `tools/startup/debug_launch.py`: the stop file is polled every 0.5 s, the loop breaks into the same path as the timeout (thread dump, `X2W_DUMP`, histogram), and a stale `stop` is removed at start. Message and `events.txt` line match the description. - `tests/startup_debug_check.py`: new stop-file case (file created 1.5 s into a 3 s probe, expects `stopped by request`, `events.txt` line and `threads.txt` stacks) and a stale-file control. This extends the existing `startup_debug` CTest, no new test target. - Not a main executable change and no startup claim, so no game run is needed. Commands run locally: `python3 tests/docs_links_check.py`, `python3 tests/bidi_controls_check.py`, `git diff --check origin/main...HEAD`, `python3 -m py_compile` on both files (all OK). Win2025: `ctest -R '^startup_debug'` dev 1/1 and release 1/1 passed (receipt below). I did not re-run the negative control against main's launcher myself; the PR body states it. No blocking findings. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 20:04:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T19:05:24Z.


Win2025 WARP receipt for head 79093c7b after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 79093c7b82bf5cfa8867692f7eded84bc22cadad:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target startup_debug_calls startup_debug_probe -- -j 2): 0.13s (configure 2.40s)
    • Test (ctest --preset dev -R '^startup_debug' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (53.12s: startup_debug 52.95s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target startup_debug_calls startup_debug_probe -- -j 2): 53.14s (configure 2.81s)
    • Test (ctest --preset release -R '^startup_debug' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (53.94s: startup_debug 53.80s)
  • Windows Python checks: tests/startup_run_ps1_check.py ok (12.7s)
  • sccache: 241/947 hits; wall 132.4s

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7171805090 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2476#issuecomment-7171805090). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T19:05:24Z. --- Win2025 WARP receipt for head 79093c7b after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `79093c7b82bf5cfa8867692f7eded84bc22cadad`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target startup_debug_calls startup_debug_probe -- -j 2`): `0.13s` (configure `2.40s`) - Test (`ctest --preset dev -R '^startup_debug' --parallel 2 --no-tests=error --output-on-failure`): **1/1 passed** (`53.12s`: `startup_debug` `52.95s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target startup_debug_calls startup_debug_probe -- -j 2`): `53.14s` (configure `2.81s`) - Test (`ctest --preset release -R '^startup_debug' --parallel 2 --no-tests=error --output-on-failure`): **1/1 passed** (`53.94s`: `startup_debug` `53.80s`) - **Windows Python checks**: `tests/startup_run_ps1_check.py` ok (`12.7s`) - `sccache`: 241/947 hits; wall `132.4s` AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 20:04:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T19:06:04Z.


Update: after #1794 landed on main, this branch conflicts in tools/startup/debug_launch.py (gh pr update-branch refuses). The change itself reviewed fine (see review above). @denn0x, please merge main into the branch and resolve that file. After that it needs a fresh Win2025 receipt on the new head before merge.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7171819460 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2476#issuecomment-7171819460). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T19:06:04Z. --- Update: after #1794 landed on main, this branch conflicts in `tools/startup/debug_launch.py` (`gh pr update-branch` refuses). The change itself reviewed fine (see review above). @denn0x, please merge main into the branch and resolve that file. After that it needs a fresh Win2025 receipt on the new head before merge. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 21:01:04 +00:00
tedin7 commented 2026-11-25 21:01:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:21:55Z.

Review: COMMENTED


Review of head fa8197f5 against current main (comment only).

Checked:

  • tools/startup/debug_launch.py: the stop file is polled every 0.5 s inside the existing main loop and breaks out the same way the timeout does, so threads.txt, X2W_DUMP and the rip histogram still run. The summary and finished.txt text switch to stopped by request only when the flag is set. A stale stop is removed with trap.log and finished.txt. Works with --timeout 0.
  • tests/startup_debug_check.py: extends the existing startup_debug check (no new CTest). The stop case creates the file only after the probe is logged as running, so it cannot pass by the probe exiting on its own (process exited is asserted absent). The stale-file control asserts a normal exit and that the file is gone.
  • No other open or merged PR covers this slice (searched "stop file debug_launch").
  • Scope is tooling only (2 files); no game or startup-progress claim is made.

Commands run (Linux):

  • python3 -I -m py_compile tools/startup/debug_launch.py tests/startup_debug_check.py OK
  • python3 tests/docs_links_check.py OK
  • python3 tests/bidi_controls_check.py OK
  • git diff --check origin/main...HEAD clean

Not run here: the check itself needs the Windows probe exe, so it is exercised by the Win2025 run and CI.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6064406397 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2476#pullrequestreview-6064406397). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T20:21:55Z. **Review:** COMMENTED --- Review of head fa8197f5 against current main (comment only). Checked: - `tools/startup/debug_launch.py`: the stop file is polled every 0.5 s inside the existing main loop and breaks out the same way the timeout does, so `threads.txt`, `X2W_DUMP` and the rip histogram still run. The summary and `finished.txt` text switch to `stopped by request` only when the flag is set. A stale `stop` is removed with `trap.log` and `finished.txt`. Works with `--timeout 0`. - `tests/startup_debug_check.py`: extends the existing `startup_debug` check (no new CTest). The stop case creates the file only after the probe is logged as running, so it cannot pass by the probe exiting on its own (`process exited` is asserted absent). The stale-file control asserts a normal exit and that the file is gone. - No other open or merged PR covers this slice (searched "stop file debug_launch"). - Scope is tooling only (2 files); no game or startup-progress claim is made. Commands run (Linux): - `python3 -I -m py_compile tools/startup/debug_launch.py tests/startup_debug_check.py` OK - `python3 tests/docs_links_check.py` OK - `python3 tests/bidi_controls_check.py` OK - `git diff --check origin/main...HEAD` clean Not run here: the check itself needs the Windows probe exe, so it is exercised by the Win2025 run and CI. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 21:01:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:25:06Z.


Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit fa8197f5a1dc6eeaa0a066c66f3931ea47badcad:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target startup_debug_calls startup_debug_probe -- -j 2): 0.12s (configure 0.00s)
    • Test (ctest --preset dev -R '^startup_debug$' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (67.90s: startup_debug 67.76s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target startup_debug_calls startup_debug_probe -- -j 2): 67.91s (configure 0.00s)
    • Test (ctest --preset release -R '^startup_debug$' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (54.94s: startup_debug 54.84s)
  • Windows Python checks: tests/startup_run_ps1_check.py ok (10.9s), tests/startup_run_sh_check.py skipped (0.1s)
  • sccache: 0/-5 hits; wall 144.4s
    AI-assisted; commands listed were executed locally.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7173641102 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2476#issuecomment-7173641102). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T20:25:06Z. --- Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `fa8197f5a1dc6eeaa0a066c66f3931ea47badcad`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target startup_debug_calls startup_debug_probe -- -j 2`): `0.12s` (configure `0.00s`) - Test (`ctest --preset dev -R '^startup_debug$' --parallel 2 --no-tests=error --output-on-failure`): **1/1 passed** (`67.90s`: `startup_debug` `67.76s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target startup_debug_calls startup_debug_probe -- -j 2`): `67.91s` (configure `0.00s`) - Test (`ctest --preset release -R '^startup_debug$' --parallel 2 --no-tests=error --output-on-failure`): **1/1 passed** (`54.94s`: `startup_debug` `54.84s`) - **Windows Python checks**: `tests/startup_run_ps1_check.py` ok (`10.9s`), `tests/startup_run_sh_check.py` skipped (`0.1s`) - `sccache`: 0/-5 hits; wall `144.4s` AI-assisted; commands listed were executed locally.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2468
No description provided.