feat(libc): write the called imports to APS5_TRACE_CALLS_FILE every 10 seconds #9439
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9439"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T22:07:10Z.
What
An executable converted with
--trace-importscounts its calls to the libraries inAPS5_TRACE_CALLS, but only a crash or an abort report prints them, and then only the 32 most called imports. A run that ends normally, or is killed at a timeout, leaves no record of what it called.With
APS5_TRACE_CALLS_FILEset to a path, the first traced import starts a thread that rewrites that file every 10 seconds. It holds one line per import called so far, most called first: the number of calls, the library and the import name. A run that is killed keeps its last rewrite.I used it to list what the 10 retail games on my test host actually call (200 to 476 different imports in 2 to 5 minutes each) and to check which of them reach a function that still has a
NotImplemented_nid_no_patchpath. The crash report couldn't answer that, because none of those runs crashed in a library.How
CallTrace.cpp:WriteCallCountstakes every import record with a nonzero count, sorts the records by count (stable, so equal counts keep their order), and writes the lines through astd::ofstreamon astd::filesystem::path.StartCallCountWriterruns once, when the first traced import sets up the trace. It readsAPS5_TRACE_CALLS_FILE, through_wgetenvon Windows as the other path variables do, and starts a detached thread that rewrites the file every 10 seconds.WriteCallCounts_nid_no_patch(const char* utf8Path)writes the same file on demand. It returns false for a null or empty path, or when the file can't be written. The test uses it.ENVIRONMENT.md,TRACING.mdand the tracing section ofUSAGE.mddescribe the variable.Tested
main17f5335562, with no conflicts, as headba73390965.guest_call_traceandguest_call_trace_abortpass 3 of 3 on Linux (Ubuntu 26.04.1, GCC 15.2, Release), and 3 of 3 on the Windows 11 VM (WinLibs GCC 15.2.0, Release) on this head and on its merge base. Conventions are clean, and the overlap scan shows no line-level overlap. The Windows runs cover the direct path-writing call; the 10-second writer thread is still exercised only by the Linux title runs below. The other results are from pre-rebase heads.Linux (Ubuntu 26.04.1, GCC 15.2, Release), on
main0c6a5bd593, then rebased ontoa6dcea9279. That merge doesn't touch these files.guest_call_trace,guest_call_trace_abortandguest_call_trace_abort_racepass 3 of 3.The new checks in
guest_call_tracerun after the existing calls and compare the written file exactly:80001 Integers,3 Blocks,2 Doubles,1 Mixed,1 Variadic, in that order, each with the library name it was traced under. They also check that a path under a regular file, a null path and an empty path return false.On
mainthe test doesn't build, becauseWriteCallCounts_nid_no_patchis new.Titles: Steins;Gate, Ghost of Tsushima, Forspoken, MGS4, Astro Bot, Crimson Desert, MXGP 26, Super Meat Boy 3D, CoD Black Ops II and Borderlands 4, converted with
--trace-imports,APS5_TRACE_CALLS=allandAPS5_TRACE_CALLS_FILE=calls.txt, for 120 to 300 s each. Every run left its file (204 to 476 lines), including the two that were killed (Ghost of Tsushima at 54 s, Astro Bot at 75 s). These runs used an earlier local version of this change that wrote the same lines unsorted.Windows 11 VM, WinLibs GCC 15.2.0, Release, head f1a1c05784 and its merge base
a6dcea9279:guest_call_traceandguest_call_trace_abort(the two that run on Windows) pass 3 of 3 on both. So the new checks, the exact file contents included, pass there.Not tested: macOS, and the 10-second writer thread on Windows (the test calls
WriteCallCounts_nid_no_patchdirectly; the titles above ran on Linux).main1a745ae38eand this branch,APS5_TRACE_CALLS=all, about 2 minutes each. It showed which census stubs and absent imports titles actually call, not just link:sceSystemServiceParamGetIntin all 13 titles that boot far enough, andtimespec_get19,588 times in one title (#9388's case).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:40:44Z.
Review: DISMISSED
The fixed-capacity import records remain stable while counts are sampled atomically, the output sorts every nonzero record with deterministic tie ordering, and the Linux report covers both the on-demand API and periodic file snapshots during real title runs (including runs later killed). Windows validates the direct path-writing API, while the periodic thread itself is explicitly untested there.
The branch was rebased onto
6ef5a1c4c9, but current upstream main has since advanced to17f5335562. Please update to current main and rerun the focusedguest_call_tracetests plus conventions and overlap. Since the file-path/environment handling has a Windows-specific_wgetenvbranch, please also run the updated Windows focused test or state why that environment is unavailable. Hosted product jobs remain skipped. I did not run local tests.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T04:53:15Z.
@MarcZX10 rebased onto
main17f5335562asba73390965, with no conflicts.guest_call_traceandguest_call_trace_abortpass 3 of 3 on Linux, and 3 of 3 on the Windows 11 VM on this head and on its merge base. Conventions are clean, and the overlap scan has no line-level entry.On Windows the tests cover
WriteCallCounts_nid_no_patch, the direct path-writing call that the writer thread repeats. The thread itself only starts when a traced title sets up its imports, and writes after 10 s. No test runs that long, and my traced title runs are on Linux, so the Windows thread remains untested, as the Tested section says.AI-assisted: yes (Claude Code)