feat(libc): restore macOS guest backtraces #9344

Merged
MarcZX10 merged 1 commit from upstream-pr/9344 into main 2026-10-27 05:20:03 +00:00
MarcZX10 commented 2026-10-21 18:58:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T18:58:20Z.


What

Restore sceLibcBacktraceGetBufferSize and sceLibcBacktraceSelf on macOS. Apple provides the same backtrace, dladdr and Dl_info interfaces used by the Linux path. Enable the existing guest_backtrace regression test on Apple and update the libc debt entry to match the supported host platforms.

Tested

  • Linux host: compiled Backtrace.cpp with GuestBacktrace.cpp using g++ and ran the focused test successfully.
  • Linux host with -U__linux__ -D__APPLE__: compiled and ran the same focused test successfully through the Apple preprocessor path. This is not a native macOS run.
  • python3 tools/check_conventions.py --base upstream/main passed; python3 tools/pr_overlap.py --branch codex/macos-backtrace-support reported no overlap.
  • Full CMake configuration could not complete: this checkout's SDL2 submodule lacks CMakeLists.txt, and the host lacks the XRandR support required by the project configuration.
  • Native macOS test run: not available in this environment.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4956797927 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9344). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T18:58:20Z. --- ### What Restore `sceLibcBacktraceGetBufferSize` and `sceLibcBacktraceSelf` on macOS. Apple provides the same `backtrace`, `dladdr` and `Dl_info` interfaces used by the Linux path. Enable the existing `guest_backtrace` regression test on Apple and update the libc debt entry to match the supported host platforms. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> - Linux host: compiled `Backtrace.cpp` with `GuestBacktrace.cpp` using g++ and ran the focused test successfully. - Linux host with `-U__linux__ -D__APPLE__`: compiled and ran the same focused test successfully through the Apple preprocessor path. This is not a native macOS run. - `python3 tools/check_conventions.py --base upstream/main` passed; `python3 tools/pr_overlap.py --branch codex/macos-backtrace-support` reported no overlap. - Full CMake configuration could not complete: this checkout's SDL2 submodule lacks `CMakeLists.txt`, and the host lacks the XRandR support required by the project configuration. - Native macOS test run: not available in this environment. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
jotitadev commented 2026-10-22 22:49:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T22:49:54Z.

Review: COMMENTED


First native macOS run, since the description only covers Linux and a -D__APPLE__ build on Linux.

Machine: Apple M2 Max, macOS 27.2 (26B5112a), Xcode 27 (Apple clang), x86-64 build under Rosetta 2, Release, BUILD_TESTING=ON, Python 3.9.6.
Base: main alone doesn't link on macOS, so the tree is #8658 (feat/macos-port) @ 04d942dc80 with this PR's diff at 4618ff54ea applied on top (clean apply). Full cmake --build with 0 errors before testing.

  • With the PR: guest_backtrace passes 3/3 (ctest --repeat until-fail:3). That covers the whole test: the first record is the calling module/function (checked through dladdr), the record chain and the 8-byte alignment, the frame limits 0/1/2, and the small-buffer cases with no writes past the end. So Apple's backtrace() + dladdr() give the same frame layout the Linux path expects.
  • Red check: I kept the CMake change (test enabled on Apple), restored Backtrace.cpp to the #8658 version and rebuilt. guest_backtrace aborts with std::runtime_error: sceLibcBacktraceGetBufferSize_nid_postfix not implemented. With the PR's Backtrace.cpp it passes again. The test catches a regression of the change.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5621841438 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9344#pullrequestreview-5621841438). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T22:49:54Z. **Review:** COMMENTED --- First native macOS run, since the description only covers Linux and a `-D__APPLE__` build on Linux. **Machine:** Apple M2 Max, macOS 27.2 (26B5112a), Xcode 27 (Apple clang), x86-64 build under Rosetta 2, Release, `BUILD_TESTING=ON`, Python 3.9.6. **Base:** `main` alone doesn't link on macOS, so the tree is #8658 (`feat/macos-port`) @ `04d942dc80` with this PR's diff at `4618ff54ea` applied on top (clean apply). Full `cmake --build` with 0 errors before testing. - **With the PR:** `guest_backtrace` passes 3/3 (`ctest --repeat until-fail:3`). That covers the whole test: the first record is the calling module/function (checked through `dladdr`), the record chain and the 8-byte alignment, the frame limits 0/1/2, and the small-buffer cases with no writes past the end. So Apple's `backtrace()` + `dladdr()` give the same frame layout the Linux path expects. - **Red check:** I kept the CMake change (test enabled on Apple), restored `Backtrace.cpp` to the #8658 version and rebuilt. `guest_backtrace` aborts with `std::runtime_error: sceLibcBacktraceGetBufferSize_nid_postfix not implemented`. With the PR's `Backtrace.cpp` it passes again. The test catches a regression of the change. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
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
boykopovar/AnyPS5!9344
No description provided.