Debug tracing: XCL_D3D12_TRACE shows the arguments, XCL_TRACE_IMPORTS logs every HLE import call with its result #187

Merged
gbuyssens merged 3 commits from upstream-pr/190 into main 2026-11-23 21:08:36 +00:00
gbuyssens commented 2026-11-23 20:00:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gbuyssens on 2026-11-23T20:00:58Z.


Tooling only, off by default; no change to a title's run without the variables.

XCL_D3D12_TRACE=1 lines carry the arguments: the three register arguments after this, two stack arguments, and what a pointer argument points at (the first words – a descriptor, the hidden return slot of a struct-returning method; a string when it reads like one). The thunk passes its stack frame to the logger (mov r8, rsp); still a tail jump, so the slot splits keep classifying by the caller's return address.
XCL_TRACE_IMPORTS=1 (guard::make_call_tracer, resolver::trace_filter): every import of the title that resolves to an HLE function is wrapped in a call-through thunk → trace: dll!Function ← module+offset: (args) → result. The thunk keeps the register arguments, forwards eight stack arguments, calls the original and logs when it returns; it registers unwind info (RtlAddFunctionTable) so an exception raised inside unwinds through it. all wraps system imports too (short runs – a data export would be wrapped as well); kernelx!Create,-kernelx!GetTickCount are include / exclude prefixes of dll!Function. Stubs are left alone (they log themselves).
Refused interfaces are logged: QueryInterface on an XGameRuntime object and on the DirectStorage factory / queue / file names the IID (how the newer DirectStorage factory IID was found).
Why: during a bring-up the question is usually "which call returned 0 just before the assert" – the D3D12 trace showed the device calls but nothing of kernelx / XGameRuntime / GameInput.

Test: call_tracer_forwards_arguments_and_results (integer, stack and floating-point arguments; integer and floating-point results) next to the existing guard tests. cargo test -p xcl guard on Windows.

<!-- greyfinch-sync:ivall/xcl:issue:6567698042 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/190). Originally posted by [gbuyssens](https://github.com/gbuyssens) on 2026-11-23T20:00:58Z. --- Tooling only, off by default; no change to a title's run without the variables. XCL_D3D12_TRACE=1 lines carry the arguments: the three register arguments after this, two stack arguments, and what a pointer argument points at (the first words – a descriptor, the hidden return slot of a struct-returning method; a string when it reads like one). The thunk passes its stack frame to the logger (mov r8, rsp); still a tail jump, so the slot splits keep classifying by the caller's return address. XCL_TRACE_IMPORTS=1 (guard::make_call_tracer, resolver::trace_filter): every import of the title that resolves to an HLE function is wrapped in a call-through thunk → trace: dll!Function ← module+offset: (args) → result. The thunk keeps the register arguments, forwards eight stack arguments, calls the original and logs when it returns; it registers unwind info (RtlAddFunctionTable) so an exception raised inside unwinds through it. all wraps system imports too (short runs – a data export would be wrapped as well); kernelx!Create,-kernelx!GetTickCount are include / exclude prefixes of dll!Function. Stubs are left alone (they log themselves). Refused interfaces are logged: QueryInterface on an XGameRuntime object and on the DirectStorage factory / queue / file names the IID (how the newer DirectStorage factory IID was found). Why: during a bring-up the question is usually "which call returned 0 just before the assert" – the D3D12 trace showed the device calls but nothing of kernelx / XGameRuntime / GameInput. Test: call_tracer_forwards_arguments_and_results (integer, stack and floating-point arguments; integer and floating-point results) next to the existing guard tests. cargo test -p xcl guard on Windows.
upstream-sync closed this pull request 2026-11-24 06:57:34 +00:00
ivall commented 2026-11-24 07:04:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T21:09:19Z.


Merged (main 6da33fa). Checked on an RX 9070 (RDNA4) with the 22 PRs merged together on main eaa36b6: cargo build --workspace && cargo test --workspace -- --test-threads=4 - 582 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed too; and the retail game still reaches its first menu (646 frames in 30 s, no device removal).

<!-- greyfinch-sync:ivall/xcl:comment:7114079048 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/190#issuecomment-7114079048). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T21:09:19Z. --- Merged (main 6da33fa). Checked on an RX 9070 (RDNA4) with the 22 PRs merged together on main eaa36b6: `cargo build --workspace && cargo test --workspace -- --test-threads=4` - 582 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed too; and the retail game still reaches its first menu (646 frames in 30 s, no device removal).
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
xcl-dev/xcl!187
No description provided.