Skip to content

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

Draft
Leyukaka wants to merge 8 commits into
R0Y00:mainfrom
Leyukaka:tools-trace-thread-ids
Draft

Leyukaka wants to merge 8 commits into
R0Y00:mainfrom
Leyukaka:tools-trace-thread-ids

Conversation

@Leyukaka

@Leyukaka Leyukaka commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #3477 (item 8, #3477 (comment)).

Stacked on #3463: until it merges, this PR also shows its commit. The change here is the last two commits, 23fa52f and 9699aa4 (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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant