tools: log thread ids and per-thread gaps in traced calls #3501

Open
github-bot wants to merge 2 commits from github-bot/gh-3499 into main AGit
Owner

@⁠Leyukaka on GitHub · 2026-11-29 18:19 UTC · original
Leyukaka:tools-trace-thread-ids → main · +319 −36 · 10 files · 8 commits · draft

Refs #3479 (item 8, #3479).

Stacked on #3465: until it merges, this PR also shows its commit. The change here is the last two commits, 23fa52f8 and 9699aa4f (head).

Why

In a long local run of the application, the trace could not say which thread stopped issuing work before the stop.

What changes

  • tools/startup/debug_launch.py: return lines of runtime and movie-player calls (--trace-calls) in files.txt end with tid=<id> gap_ms=<ms|n/a>. File-hook lines (NtCreateFile, NtOpenFile, ...) keep their format.

    <seconds> <call> -> 0x00000001 tid=<id> gap_ms=<ms|n/a>
    
  • tools/startup/hook_window.py: new trace_call_suffix. The gap is per thread, from time.monotonic(), between that thread's logged trace lines, in ms with 3 decimals. The first line of a thread has gap_ms=n/a.

  • Exception and debugger stop lines in events.txt end with tid=<id>.

  • tools/startup/triage_run.py, tools/startup/exit_report.py: the debugger stop regex accepts the optional tid= suffix, with the same captures. The exception regexes are not end-anchored and needed no change.

  • live_view.py and the other consumers of these lines are unaffected.

Tests

  • tests/startup_hook_check.py, tests/startup_triage_run_check.py, tests/startup_exit_report_check.py: pass.
  • cmake --preset dev -DX2W_WITH_OPUS:BOOL=OFF, build targets startup_debug_probe and startup_debug_calls, then ctest -R '^startup_debug(_log|_hooks)?$': 3/3 passed.

Mutations, each caught by a failing check:

Mutation Fails
one timestamp shared by all threads in trace_call_suffix startup_hook_check
tid= dropped from the exception line startup_debug
old stop regex in triage_run.py startup_triage_run_check
old stop regex in exit_report.py startup_exit_report_check
suffix dropped from the traced-call return line startup_debug_hooks
tid= dropped from the debugger stop line startup_debug
per-thread timestamp not cleared on thread exit startup_debug_hooks (a new thread reusing the exited thread's id gets a numeric gap instead of n/a)

docs/startup-runtime.md describes the tid and gap_ms fields.

**@⁠Leyukaka** on GitHub · 2026-11-29 18:19 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3499) `Leyukaka:tools-trace-thread-ids` → `main` · +319 −36 · 10 files · 8 commits · draft Refs #3479 (item 8, https://git.gtahub.st/github/R0Y00--Xbox2Windows/issues/3479). Stacked on #3465: until it merges, this PR also shows its commit. The change here is the last two commits, 23fa52f8 and 9699aa4f (head). ## Why In a long local run of the application, the trace could not say which thread stopped issuing work before the stop. ## What changes - `tools/startup/debug_launch.py`: return lines of runtime and movie-player calls (`--trace-calls`) in `files.txt` end with `tid=<id> gap_ms=<ms|n/a>`. File-hook lines (`NtCreateFile`, `NtOpenFile`, ...) keep their format. ``` <seconds> <call> -> 0x00000001 tid=<id> gap_ms=<ms|n/a> ``` - `tools/startup/hook_window.py`: new `trace_call_suffix`. The gap is per thread, from `time.monotonic()`, between that thread's logged trace lines, in ms with 3 decimals. The first line of a thread has `gap_ms=n/a`. - Exception and debugger stop lines in `events.txt` end with ` tid=<id>`. - `tools/startup/triage_run.py`, `tools/startup/exit_report.py`: the debugger stop regex accepts the optional `tid=` suffix, with the same captures. The exception regexes are not end-anchored and needed no change. - `live_view.py` and the other consumers of these lines are unaffected. ## Tests - `tests/startup_hook_check.py`, `tests/startup_triage_run_check.py`, `tests/startup_exit_report_check.py`: pass. - `cmake --preset dev -DX2W_WITH_OPUS:BOOL=OFF`, build targets `startup_debug_probe` and `startup_debug_calls`, then `ctest -R '^startup_debug(_log|_hooks)?$'`: 3/3 passed. Mutations, each caught by a failing check: | Mutation | Fails | |---|---| | one timestamp shared by all threads in `trace_call_suffix` | `startup_hook_check` | | ` tid=` dropped from the exception line | `startup_debug` | | old stop regex in `triage_run.py` | `startup_triage_run_check` | | old stop regex in `exit_report.py` | `startup_exit_report_check` | | suffix dropped from the traced-call return line | `startup_debug_hooks` | | ` tid=` dropped from the debugger stop line | `startup_debug` | | per-thread timestamp not cleared on thread exit | `startup_debug_hooks` (a new thread reusing the exited thread's id gets a numeric gap instead of `n/a`) | `docs/startup-runtime.md` describes the `tid` and `gap_ms` fields.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 18:21:53 +00:00
This pull request has changes conflicting with the target branch.
  • tools/startup/debug_launch.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3501/head:github-bot/gh-3499'
git switch 'github-bot/gh-3499'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3499'
git switch 'github-bot/gh-3499'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3499'
git switch 'github-bot/gh-3499'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3499'
git switch 'main'
git merge --squash 'github-bot/gh-3499'
git switch 'main'
git merge --ff-only 'github-bot/gh-3499'
git switch 'main'
git merge 'github-bot/gh-3499'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.