Repository navigation
feat(libc): record traced import calls on Windows - #4546
Merged
adriadam10 merged 1 commit intoOct 13, 2026
Merged
Conversation
This was referenced Oct 12, 2026
9 tasks done
codingreapermaps
force-pushed
the
feat/libc-call-trace-runtime
branch
from
October 12, 2026 22:23
5bddaa0 to
885276d
Compare
9 tasks done
codingreapermaps
force-pushed
the
feat/libc-call-trace-runtime
branch
from
October 12, 2026 22:31
885276d to
0991921
Compare
11 tasks done
codingreapermaps
force-pushed
the
feat/libc-call-trace-runtime
branch
from
October 13, 2026 09:17
0991921 to
121221c
Compare
This was referenced Oct 13, 2026
TraceImport_nid_no_patch wraps a function of a library named in APS5_TRACE_CALLS in a thunk that records the import, the thread and the caller in a ring and counts the call, then jumps to the function. One target keeps one thunk, so function pointers compare equal. The crash and abort reports print the last 64 calls and the 32 most called imports. Nothing calls TraceImport_nid_no_patch yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
Reviewed the thunk (register save/restore, 16-byte stack alignment, return address read at the right offset, stack arguments and |
adriadam10
force-pushed
the
feat/libc-call-trace-runtime
branch
from
October 13, 2026 14:19
121221c to
3953a8d
Compare
11 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the runtime half of an opt-in call trace on Windows. It covers part of #3815: the entry of a call, not its arguments or its result.
TraceImport_nid_no_patch(target, name, library)returnstargetunchanged unlesslibraryis named inAPS5_TRACE_CALLS(a comma-separated list, orall). For a selected library it returns a thunk that records the import, the thread and the caller's address in a ring of the last 65536 calls, counts the call, and jumps to the function. The thunk saves the integer argument registers andxmm0toxmm7, so stack arguments, varargs and struct returns pass through. One target keeps one thunk, so function pointers compare equal.The crash and abort reports end with the last 64 calls and the 32 most called imports:
Nothing calls
TraceImport_nid_no_patchin this PR, so no title is affected. The relinker option that binds imports through it is a separate PR that depends on this one. Limits (Windows only, entry only, one process-wide ring, wider vector registers untested) are indocs/dev/debt/libc.md.Tested
Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), on main 43e3a70.
guest_call_trace(new): integer, floating-point, mixed, variadic and struct-return calls through a thunk return the same result as the direct call; the ring holds the calls in order with the right thread, names and a caller address inside the test image; 4 threads of 20000 calls leave the last 65536 calls with consecutive sequence numbers; the counters match.rax,r9orxmm3before the jump.guest_call_trace_abort(new): the abort report lists the two traced calls.windows_backtrace_reportstill passes.tools/check_conventions.pyandtools/check_test_registration.pypass.With the relinker option from the follow-up PR, DOOM Shareware (PPSA99666, lowbit/ps5-doom v1.1.1, Intel i7-1165G7, before the rebase onto current main) ran with every library traced to the same point as untraced: 901,307,599 calls recorded, normal process exit. Not built on Linux or macOS; the source file is compiled only on Windows.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code