feat(libc): answer every libunwind cursor slot of an unwind context #6819

Merged
GitamarT045T3R merged 7 commits from upstream-pr/6819 into main 2026-11-08 09:11:11 +00:00
GitamarT045T3R commented 2026-10-16 13:13:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by GitamarT045T3R on 2026-10-16T13:13:27Z.


What

The _Unwind_Context that _Unwind_Backtrace passes to its callback starts with a table laid out like LLVM libunwind's AbstractUnwindCursor virtual table (db3ec02c5), because homebrew built with the ps5-payload-dev SDK links libunwind statically and calls through that table from its own _Unwind_GetIP. Only the register slots and isSignalFrame were answered; the other nine slots threw. A title that asks its own libunwind for a frame's procedure info or name (_Unwind_GetRegionStart, _Unwind_GetLanguageSpecificData and unw_get_proc_info call getInfo; _Unwind_SetIP calls getInfo and setInfoBasedOnIPRegister; unw_get_proc_name calls getFunctionName), steps a frame (unw_step) or resumes one (unw_resume) stopped there.

Every slot now answers as UnwindCursor<LocalAddressSpace, Registers_x86_64> of LLVM 18.1.8 does with DWARF unwind information:

Slot Behaviour
~AbstractUnwindCursor (complete and deleting) nothing; libunwind's class-specific operator delete is empty
getReg, setReg as before for -2 (UNW_REG_SP) to 16 (rip); any other number prints libunwind: getRegister - unsupported x86_64 register (or setRegister) and aborts, as Registers_x86_64 does through _LIBUNWIND_ABORT
getFloatReg, setFloatReg print libunwind: getFloatRegister - no x86_64 float registers (or setFloatRegister) and abort
step UNW_STEP_END without unwind info, UNW_EBADFRAME when the rules cannot be applied, otherwise moves to the caller with the same rules as _Unwind_Backtrace and looks the new IP up, returning UNW_STEP_END when nothing covers it (IP 0 included)
getInfo start, end, LSDA and personality from the FDE, DW_CFA_GNU_args_size as gp, UNWIND_X86_64_MODE_DWARF as format, the FDE and its size as unwind_info, the start of the ELF segment or PE section holding the IP as extra; all zero without unwind info
jumpto restores the registers and jumps, as _Unwind_RaiseException installs a landing pad
getFunctionName dladdr of the IP (Linux, macOS); on Windows the nearest export at or below the IP in the image holding it
setInfoBasedOnIPRegister looks the IP up as it is, or minus one for a return address
getRegisterName Registers_x86_64::getRegisterName's names, unknown register otherwise

To share the walk with _Unwind_Backtrace, Step is split into Caller (the registers of the caller) and the end-of-stack checks, and GetRules records the FDE, the function's end, the arguments size and the segment in the context, and clears them when no FDE covers the IP. DW_CFA_GNU_args_size was parsed and dropped before.

Differences from libunwind are listed in the libc technical debt entry: Windows host frames without an FDE are stepped with RtlVirtualUnwind and report no range; a frame whose rules leave rsp and rip unchanged ends the walk instead of being returned again; a signal frame is looked up at its IP; jumpto does not restore r10 and r11.

Tested

Windows 10 Pro 22H2 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Ninja, Release, BUILD_TESTING=ON, on main eb901bcf4:

  • New unwind_cursor (registered on every platform): captures a context in an exported probe and calls every slot through the table: setInfoBasedOnIPRegister and getInfo against the probe's own address, its FDE and _Unwind_GetRegionStart/_Unwind_GetLanguageSpecificData, getFunctionName (full and truncated), IP 0, step to the exported caller and on to the end of the stack, register names, the destructors, jumpto back to a captured point, and the context _Unwind_Backtrace passes to its callback. Passes, 25 of 25 repeated runs.
  • unwind_cursor_get_register, _set_register, _get_float_register and _set_float_register match libunwind's libunwind: getRegister - unsupported x86_64 register and libunwind: getFloatRegister - no x86_64 float registers lines: pass.
  • Before: the same test binary run against the libc.prx of main stops at the first setInfoBasedOnIPRegister with libunwind cursor: operation other than register access or isSignalFrame not implemented.
  • The 35 exception, unwind, backtrace and signal tests (windows_exceptions, windows_backtrace_*, guest_exception_*, guest_raise_exception, guest_unwind_module_info, agc_stack_walk, linux_eh_frame_header, ...) pass.
  • Full ctest -j 12: 1324 of 1325 pass. agc_shader_disk_cache fails with Access is denied as it does on main on Windows 10 (#6415). agc_driver_gpu_indirect_arguments_misaligned_writer_ahead_tests does not build with MinGW on main (alignment 65536 above the object file maximum of 8192, #6452), so it was excluded.
  • python tools/check_conventions.py --base origin/main passes.
  • Not built or run on Linux or macOS. There getFunctionName uses dladdr and extra the PT_LOAD segment from dl_iterate_phdr; the test exports its probe with ENABLE_EXPORTS.

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
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4888886995 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6819). Originally posted by [GitamarT045T3R](https://github.com/GitamarT045T3R) on 2026-10-16T13:13:27Z. --- ### What The `_Unwind_Context` that `_Unwind_Backtrace` passes to its callback starts with a table laid out like LLVM libunwind's `AbstractUnwindCursor` virtual table (db3ec02c5), because homebrew built with the ps5-payload-dev SDK links libunwind statically and calls through that table from its own `_Unwind_GetIP`. Only the register slots and `isSignalFrame` were answered; the other nine slots threw. A title that asks its own libunwind for a frame's procedure info or name (`_Unwind_GetRegionStart`, `_Unwind_GetLanguageSpecificData` and `unw_get_proc_info` call `getInfo`; `_Unwind_SetIP` calls `getInfo` and `setInfoBasedOnIPRegister`; `unw_get_proc_name` calls `getFunctionName`), steps a frame (`unw_step`) or resumes one (`unw_resume`) stopped there. Every slot now answers as `UnwindCursor<LocalAddressSpace, Registers_x86_64>` of [LLVM 18.1.8](https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/libunwind/src/UnwindCursor.hpp) does with DWARF unwind information: | Slot | Behaviour | | --- | --- | | `~AbstractUnwindCursor` (complete and deleting) | nothing; libunwind's class-specific `operator delete` is empty | | `getReg`, `setReg` | as before for -2 (`UNW_REG_SP`) to 16 (`rip`); any other number prints `libunwind: getRegister - unsupported x86_64 register` (or `setRegister`) and aborts, as `Registers_x86_64` does through `_LIBUNWIND_ABORT` | | `getFloatReg`, `setFloatReg` | print `libunwind: getFloatRegister - no x86_64 float registers` (or `setFloatRegister`) and abort | | `step` | `UNW_STEP_END` without unwind info, `UNW_EBADFRAME` when the rules cannot be applied, otherwise moves to the caller with the same rules as `_Unwind_Backtrace` and looks the new IP up, returning `UNW_STEP_END` when nothing covers it (IP 0 included) | | `getInfo` | start, end, LSDA and personality from the FDE, `DW_CFA_GNU_args_size` as `gp`, `UNWIND_X86_64_MODE_DWARF` as `format`, the FDE and its size as `unwind_info`, the start of the ELF segment or PE section holding the IP as `extra`; all zero without unwind info | | `jumpto` | restores the registers and jumps, as `_Unwind_RaiseException` installs a landing pad | | `getFunctionName` | `dladdr` of the IP (Linux, macOS); on Windows the nearest export at or below the IP in the image holding it | | `setInfoBasedOnIPRegister` | looks the IP up as it is, or minus one for a return address | | `getRegisterName` | `Registers_x86_64::getRegisterName`'s names, `unknown register` otherwise | To share the walk with `_Unwind_Backtrace`, `Step` is split into `Caller` (the registers of the caller) and the end-of-stack checks, and `GetRules` records the FDE, the function's end, the arguments size and the segment in the context, and clears them when no FDE covers the IP. `DW_CFA_GNU_args_size` was parsed and dropped before. Differences from libunwind are listed in the libc technical debt entry: Windows host frames without an FDE are stepped with `RtlVirtualUnwind` and report no range; a frame whose rules leave `rsp` and `rip` unchanged ends the walk instead of being returned again; a signal frame is looked up at its IP; `jumpto` does not restore `r10` and `r11`. ### Tested Windows 10 Pro 22H2 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Ninja, Release, `BUILD_TESTING=ON`, on `main` `eb901bcf4`: - New `unwind_cursor` (registered on every platform): captures a context in an exported probe and calls every slot through the table: `setInfoBasedOnIPRegister` and `getInfo` against the probe's own address, its FDE and `_Unwind_GetRegionStart`/`_Unwind_GetLanguageSpecificData`, `getFunctionName` (full and truncated), IP 0, `step` to the exported caller and on to the end of the stack, register names, the destructors, `jumpto` back to a captured point, and the context `_Unwind_Backtrace` passes to its callback. Passes, 25 of 25 repeated runs. - `unwind_cursor_get_register`, `_set_register`, `_get_float_register` and `_set_float_register` match libunwind's `libunwind: getRegister - unsupported x86_64 register` and `libunwind: getFloatRegister - no x86_64 float registers` lines: pass. - Before: the same test binary run against the `libc.prx` of `main` stops at the first `setInfoBasedOnIPRegister` with `libunwind cursor: operation other than register access or isSignalFrame not implemented`. - The 35 exception, unwind, backtrace and signal tests (`windows_exceptions`, `windows_backtrace_*`, `guest_exception_*`, `guest_raise_exception`, `guest_unwind_module_info`, `agc_stack_walk`, `linux_eh_frame_header`, ...) pass. - Full `ctest -j 12`: 1324 of 1325 pass. `agc_shader_disk_cache` fails with `Access is denied` as it does on `main` on Windows 10 (#6415). `agc_driver_gpu_indirect_arguments_misaligned_writer_ahead_tests` does not build with MinGW on `main` (alignment 65536 above the object file maximum of 8192, #6452), so it was excluded. - `python tools/check_conventions.py --base origin/main` passes. - Not built or run on Linux or macOS. There `getFunctionName` uses `dladdr` and `extra` the `PT_LOAD` segment from `dl_iterate_phdr`; the test exports its probe with `ENABLE_EXPORTS`. ### Checklist - [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] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
jotitadev commented 2026-10-16 13:45:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T13:45:41Z.

Review: COMMENTED


Native Linux run on exact head 3bf85ad5c71a2feb54df83cbd5eb5673ed539bff, merged on main 82ddae75b.

Machine: Intel i7-8700 (6C/12T), Ubuntu 26.04, GCC 15.2, CMake 4.2.3, Ninja, Release, BUILD_TESTING=ON, full build.

The four abort tests fail on Linux. unwind_cursor_get_register, _set_register, _get_float_register and _set_float_register print the expected line (libunwind: getRegister - unsupported x86_64 register, ...), but std::abort() ends the process with SIGABRT here, and CTest reports a signal as Subprocess aborted***Exception and fails the test even though PASS_REGULAR_EXPRESSION matches. On Windows _set_abort_behavior turns abort() into exit code 3, which is why they pass there. The other abort-plus-regex tests in the tree (guest_call_trace_abort, windows_backtrace_*) are registered only under if(WIN32); these four are registered on every platform.

With a SIGABRT handler that exits normally on non-Windows, all four pass. I tested only this change:

#ifdef _WIN32
    _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
#else
    std::signal(SIGABRT, [](int) { std::_Exit(3); });
#endif

(plus #include <csignal>). Registering the four tests under if(WIN32) would also work, but then the abort paths would go untested on Linux.

Other results:

  • unwind_cursor passes, 25 of 25 repeated runs. This covers the Linux paths you could not run: getFunctionName through dladdr, extra from the PT_LOAD segment, step to the end of the stack, and jumpto.
  • The same unwind_cursor_tests binary run against main's libc.prx aborts with libunwind cursor: operation other than register access or isSignalFrame not implemented, so the test does cover the change.
  • Non-GPU suite (ctest -E "^agc|gpu|vulkan|video_out"): 649/655. The six failures are the four above plus file_writer_binary/file_writer_text, which also fail on main on this machine (648/650). All the other exception, unwind and backtrace tests pass.

Not checked: macOS.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5548631639 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6819#pullrequestreview-5548631639). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-16T13:45:41Z. **Review:** COMMENTED --- Native Linux run on exact head `3bf85ad5c71a2feb54df83cbd5eb5673ed539bff`, merged on `main` `82ddae75b`. Machine: Intel i7-8700 (6C/12T), Ubuntu 26.04, GCC 15.2, CMake 4.2.3, Ninja, Release, `BUILD_TESTING=ON`, full build. **The four abort tests fail on Linux.** `unwind_cursor_get_register`, `_set_register`, `_get_float_register` and `_set_float_register` print the expected line (`libunwind: getRegister - unsupported x86_64 register`, ...), but `std::abort()` ends the process with `SIGABRT` here, and CTest reports a signal as `Subprocess aborted***Exception` and fails the test even though `PASS_REGULAR_EXPRESSION` matches. On Windows `_set_abort_behavior` turns `abort()` into exit code 3, which is why they pass there. The other abort-plus-regex tests in the tree (`guest_call_trace_abort`, `windows_backtrace_*`) are registered only under `if(WIN32)`; these four are registered on every platform. With a SIGABRT handler that exits normally on non-Windows, all four pass. I tested only this change: ```cpp #ifdef _WIN32 _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); #else std::signal(SIGABRT, [](int) { std::_Exit(3); }); #endif ``` (plus `#include <csignal>`). Registering the four tests under `if(WIN32)` would also work, but then the abort paths would go untested on Linux. Other results: - `unwind_cursor` passes, 25 of 25 repeated runs. This covers the Linux paths you could not run: `getFunctionName` through `dladdr`, `extra` from the `PT_LOAD` segment, `step` to the end of the stack, and `jumpto`. - The same `unwind_cursor_tests` binary run against `main`'s `libc.prx` aborts with `libunwind cursor: operation other than register access or isSignalFrame not implemented`, so the test does cover the change. - Non-GPU suite (`ctest -E "^agc|gpu|vulkan|video_out"`): 649/655. The six failures are the four above plus `file_writer_binary`/`file_writer_text`, which also fail on `main` on this machine (648/650). All the other exception, unwind and backtrace tests pass. Not checked: macOS. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
GitamarT045T3R commented 2026-10-16 14:11:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by GitamarT045T3R on 2026-10-16T14:11:56Z.


@jotitadev thank you for the Linux run, and for pinning down why the four abort tests failed there.

5514a8579 adds the SIGABRT handler you tested (std::_Exit(3) outside Windows, <csignal>), so the abort paths stay covered on Linux instead of moving the tests under if(WIN32). On Windows unwind_cursor and the four abort tests still pass. The same commit moves the test registration before guest_strings, which removes the overlap with #6079; the remaining overlap with #6541 is the adjacent debt entry in docs/dev/debt/libc.md and resolves either way.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6217363789 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6819#issuecomment-6217363789). Originally posted by [GitamarT045T3R](https://github.com/GitamarT045T3R) on 2026-10-16T14:11:56Z. --- @jotitadev thank you for the Linux run, and for pinning down why the four abort tests failed there. 5514a8579 adds the SIGABRT handler you tested (`std::_Exit(3)` outside Windows, `<csignal>`), so the abort paths stay covered on Linux instead of moving the tests under `if(WIN32)`. On Windows `unwind_cursor` and the four abort tests still pass. The same commit moves the test registration before `guest_strings`, which removes the overlap with #6079; the remaining overlap with #6541 is the adjacent debt entry in `docs/dev/debt/libc.md` and resolves either way.
jotitadev commented 2026-10-16 14:44:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T14:44:59Z.

Review: COMMENTED


Re-ran on exact head 5514a8579ed9a27b2d903d9e9c4d34f5d6548b3a, merged on main 82ddae75b. Same machine as before: Intel i7-8700, Ubuntu 26.04, GCC 15.2, CMake 4.2.3, Ninja, Release, BUILD_TESTING=ON, full build.

  • unwind_cursor and the four abort tests (unwind_cursor_get_register, _set_register, _get_float_register, _set_float_register) now pass on Linux, 25 of 25 repeated runs each (ctest -R unwind_cursor --repeat until-fail:25). The abort tests print the expected libunwind: ... unsupported x86_64 register line and exit normally through the new handler.
  • Non-GPU suite (ctest -E "^agc|gpu|vulkan|video_out" -j6): 653/655 with this PR; main 647/650 on the same machine. The two failures are file_writer_binary/file_writer_text, which also fail on main here. The third main failure was a guest_pthread_start timeout under load; it passes 5 of 5 when run alone.

Not checked: macOS, Windows.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5549399353 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6819#pullrequestreview-5549399353). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-16T14:44:59Z. **Review:** COMMENTED --- Re-ran on exact head `5514a8579ed9a27b2d903d9e9c4d34f5d6548b3a`, merged on `main` `82ddae75b`. Same machine as before: Intel i7-8700, Ubuntu 26.04, GCC 15.2, CMake 4.2.3, Ninja, Release, `BUILD_TESTING=ON`, full build. - `unwind_cursor` and the four abort tests (`unwind_cursor_get_register`, `_set_register`, `_get_float_register`, `_set_float_register`) now pass on Linux, 25 of 25 repeated runs each (`ctest -R unwind_cursor --repeat until-fail:25`). The abort tests print the expected `libunwind: ... unsupported x86_64 register` line and exit normally through the new handler. - Non-GPU suite (`ctest -E "^agc|gpu|vulkan|video_out" -j6`): 653/655 with this PR; `main` 647/650 on the same machine. The two failures are `file_writer_binary`/`file_writer_text`, which also fail on `main` here. The third `main` failure was a `guest_pthread_start` timeout under load; it passes 5 of 5 when run alone. Not checked: macOS, Windows. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
jotitadev commented 2026-10-19 11:10:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-19T11:10:03Z.

Review: COMMENTED


Re-ran on the new head, since b178ec5de changes the Linux-only path and the PR says it wasn't run on Linux.

Exact head b178ec5dedd774153631e0504684b8e1e1a58505, merged on main 674c25388. Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, CMake 4.2.3, Ninja, Release, BUILD_TESTING=ON, full build.

  • unwind_cursor and the four abort tests pass, 10 of 10 repeated runs. The 15 unwind|exception|backtrace tests pass.
  • Full non-GPU suite: 781/781.
  • With b178ec5de reverted on the same merge, unwind_cursor fails with unwind cursor check failed: getInfo gives the start of the segment holding the function. So the commit is needed on glibc now that main takes the _dl_find_object path (2a12dbd40, which landed after my run on 5514a8579), and the test covers it.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5570663260 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6819#pullrequestreview-5570663260). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-19T11:10:03Z. **Review:** COMMENTED --- Re-ran on the new head, since b178ec5de changes the Linux-only path and the PR says it wasn't run on Linux. Exact head `b178ec5dedd774153631e0504684b8e1e1a58505`, merged on `main` `674c25388`. Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, CMake 4.2.3, Ninja, Release, `BUILD_TESTING=ON`, full build. - `unwind_cursor` and the four abort tests pass, 10 of 10 repeated runs. The 15 `unwind|exception|backtrace` tests pass. - Full non-GPU suite: 781/781. - With b178ec5de reverted on the same merge, `unwind_cursor` fails with `unwind cursor check failed: getInfo gives the start of the segment holding the function`. So the commit is needed on glibc now that `main` takes the `_dl_find_object` path (2a12dbd40, which landed after my run on 5514a8579), and the test covers it. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
nikowolf123 commented 2026-10-20 22:04:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-20T22:04:12Z.


docs/dev/debt/libc.md line 87: this PR closes the gap "the other slots throw", but the entry is rewritten to describe the new slots: the aborts in getReg/setReg/getFloatReg/setFloatReg, the destructors and every getInfo field, all of which match libunwind. What is still open comes only after that: the differences, and that the console's libSceLibcInternal is not checked. CONTRIBUTING.md line 73 asks for the gap first and says a pull request that closes a gap "removes its entry, or cuts it to what is still open, instead of rewriting it to describe the corrected behaviour".

The branch needs a rebase for the conflict in this file anyway (main added the RemoveTree entry just above it). After the rebase, the debt-length check that main gained in #6757 flags the entry. I merged this head into main d97361bd0, kept both entries and ran python3 tools/check_conventions.py --base d97361bd0:

docs/dev/debt/libc.md:99: warning: [debt-length] Technical debt entry over 1000 characters: state the gap first (what differs from the console, what is unverified, what throws) and keep only the behaviour it needs: 1938 characters

Cutting the current text down to its open parts gives 875 characters, and the check passes with it:

- The [slots](../../../core/libs/prx/libc/src/exception/Unwind.cpp) of the libunwind `AbstractUnwindCursor` table at the start of the [`_Unwind_Context`](../../../core/libs/prx/libc/include/exceptions/Unwind.hpp) that `_Unwind_Backtrace` passes to its callback follow `UnwindCursor<LocalAddressSpace, Registers_x86_64>` of [LLVM 18.1.8](https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/libunwind/src/UnwindCursor.hpp); the console's own `libSceLibcInternal` is not checked. Differences from LLVM 18.1.8: `step` walks Windows host frames without an FDE with `RtlVirtualUnwind` and `getInfo` reports them with no range; `step` looks a signal frame up at its IP instead of the IP minus one and ends at a frame whose rules leave `rsp` and `rip` unchanged; `getFunctionName` on Windows takes the nearest export at or below the IP; `jumpto` does not restore `r10` and `r11`

Why the table exists is already recorded in db3ec02c5 and in the PR description, so the entry does not need to repeat it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6302774360 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6819#issuecomment-6302774360). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-20T22:04:12Z. --- [`docs/dev/debt/libc.md` line 87](https://github.com/boykopovar/AnyPS5/blob/b178ec5dedd774153631e0504684b8e1e1a58505/docs/dev/debt/libc.md#L87): this PR closes the gap "the other slots throw", but the entry is rewritten to describe the new slots: the aborts in `getReg`/`setReg`/`getFloatReg`/`setFloatReg`, the destructors and every `getInfo` field, all of which match libunwind. What is still open comes only after that: the differences, and that the console's `libSceLibcInternal` is not checked. [CONTRIBUTING.md line 73](https://github.com/boykopovar/AnyPS5/blob/b178ec5dedd774153631e0504684b8e1e1a58505/CONTRIBUTING.md#L73) asks for the gap first and says a pull request that closes a gap "removes its entry, or cuts it to what is still open, instead of rewriting it to describe the corrected behaviour". The branch needs a rebase for the conflict in this file anyway (main added the `RemoveTree` entry just above it). After the rebase, the `debt-length` check that main gained in #6757 flags the entry. I merged this head into main `d97361bd0`, kept both entries and ran `python3 tools/check_conventions.py --base d97361bd0`: ``` docs/dev/debt/libc.md:99: warning: [debt-length] Technical debt entry over 1000 characters: state the gap first (what differs from the console, what is unverified, what throws) and keep only the behaviour it needs: 1938 characters ``` Cutting the current text down to its open parts gives 875 characters, and the check passes with it: ```markdown - The [slots](../../../core/libs/prx/libc/src/exception/Unwind.cpp) of the libunwind `AbstractUnwindCursor` table at the start of the [`_Unwind_Context`](../../../core/libs/prx/libc/include/exceptions/Unwind.hpp) that `_Unwind_Backtrace` passes to its callback follow `UnwindCursor<LocalAddressSpace, Registers_x86_64>` of [LLVM 18.1.8](https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/libunwind/src/UnwindCursor.hpp); the console's own `libSceLibcInternal` is not checked. Differences from LLVM 18.1.8: `step` walks Windows host frames without an FDE with `RtlVirtualUnwind` and `getInfo` reports them with no range; `step` looks a signal frame up at its IP instead of the IP minus one and ends at a frame whose rules leave `rsp` and `rip` unchanged; `getFunctionName` on Windows takes the nearest export at or below the IP; `jumpto` does not restore `r10` and `r11` ``` Why the table exists is already recorded in db3ec02c5 and in the PR description, so the entry does not need to repeat it.
GitamarT045T3R commented 2026-10-21 16:00:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by GitamarT045T3R on 2026-10-21T16:00:57Z.


Rebased onto main cecb540a6 on top of @adriadam10's b178ec5de, which is kept as 13232cbe7. Two commits are added:

  • b083c2b6e cuts the debt entry to its open gaps with @nikowolf123's text (875 characters; check_conventions passes with no debt-length finding).
  • 0aab5071c marks the test's TraceFirstFrame APS5_VABI: since #6851 _Unwind_Trace_Fn has the guest calling convention, and without it unwind_cursor_tests no longer compiles on Windows.

On Windows unwind_cursor, the four abort tests, the five unwind_callback_abi tests and the Windows exception and backtrace tests pass, 3 of 3. Thank you @jotitadev for the glibc run that shows b178ec5de is needed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6320428518 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6819#issuecomment-6320428518). Originally posted by [GitamarT045T3R](https://github.com/GitamarT045T3R) on 2026-10-21T16:00:57Z. --- Rebased onto `main` `cecb540a6` on top of @adriadam10's b178ec5de, which is kept as 13232cbe7. Two commits are added: - b083c2b6e cuts the debt entry to its open gaps with @nikowolf123's text (875 characters; `check_conventions` passes with no `debt-length` finding). - 0aab5071c marks the test's `TraceFirstFrame` `APS5_VABI`: since #6851 `_Unwind_Trace_Fn` has the guest calling convention, and without it `unwind_cursor_tests` no longer compiles on Windows. On Windows `unwind_cursor`, the four abort tests, the five `unwind_callback_abi` tests and the Windows exception and backtrace tests pass, 3 of 3. Thank you @jotitadev for the glibc run that shows b178ec5de is needed.
GitamarT045T3R commented 2026-10-22 08:03:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by GitamarT045T3R on 2026-10-22T08:03:31Z.


Rebased onto main d6eafa54d (3551ba114). The conflict was with 726edc503 (MSYS2 GCC runtime builds), which changed VirtualUnwind to take the Frame and record the start, language data and personality of a Windows host frame. This PR keeps that version: NearestExport stays in front of it, and FrameRules no longer sets context.cfa itself, since VirtualUnwind now does. The debt entry keeps main's new Windows unwinder line. One added commit, 3551ba114, says getInfo gives host frames no end address instead of "no range", because they now have a start.

On Windows, the 16 unwind_*, windows_backtrace_* and windows_exceptions tests pass and check_conventions passes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6335859488 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6819#issuecomment-6335859488). Originally posted by [GitamarT045T3R](https://github.com/GitamarT045T3R) on 2026-10-22T08:03:31Z. --- Rebased onto `main` `d6eafa54d` (3551ba114). The conflict was with 726edc503 (MSYS2 GCC runtime builds), which changed `VirtualUnwind` to take the `Frame` and record the start, language data and personality of a Windows host frame. This PR keeps that version: `NearestExport` stays in front of it, and `FrameRules` no longer sets `context.cfa` itself, since `VirtualUnwind` now does. The debt entry keeps `main`'s new Windows unwinder line. One added commit, 3551ba114, says `getInfo` gives host frames no end address instead of "no range", because they now have a start. On Windows, the 16 `unwind_*`, `windows_backtrace_*` and `windows_exceptions` tests pass and `check_conventions` passes.
MarcZX10 commented 2026-10-24 01:20:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T01:20:37Z.

Review: APPROVED


Reviewed current head 3551ba114cf3000200e39d574fc2f774f5e4f99f against LLVM libunwind 18.1.8 and the changed call paths. The 15-entry cursor slot order and x86_64 register mapping align with the reference; carries the FDE range, LSDA/personality, DWARF format, FDE pointer/size, segment base and parsed ; , end-of-stack handling, IP re-lookup, and the Windows host-frame fallback are consistent with the documented scope. The added cursor test exercises slot behavior, frame traversal, info/name queries, , and abort cases. Current hosted checks pass for conventions, eligibility, labels, macOS and Linux register-context/relinker matrices, ASan, and write-watch. The repository's full Linux and Windows product jobs are skipped by policy. The PR also documents remaining Windows/IP/jumpto gaps and lack of console-side verification.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5636108274 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6819#pullrequestreview-5636108274). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T01:20:37Z. **Review:** APPROVED --- Reviewed current head 3551ba114cf3000200e39d574fc2f774f5e4f99f against LLVM libunwind 18.1.8 and the changed call paths. The 15-entry cursor slot order and x86_64 register mapping align with the reference; carries the FDE range, LSDA/personality, DWARF format, FDE pointer/size, segment base and parsed ; , end-of-stack handling, IP re-lookup, and the Windows host-frame fallback are consistent with the documented scope. The added cursor test exercises slot behavior, frame traversal, info/name queries, , and abort cases. Current hosted checks pass for conventions, eligibility, labels, macOS and Linux register-context/relinker matrices, ASan, and write-watch. The repository's full Linux and Windows product jobs are skipped by policy. The PR also documents remaining Windows/IP/jumpto gaps and lack of console-side verification.
jotitadev commented 2026-10-27 05:32:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T05:32:08Z.

Review: COMMENTED


Merge-skew check: head 3551ba114 merged onto current main abed03546 (clean merge, git merge --no-commit). This head's CI ran on the October 22 base, before #10706 landed. Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release, BUILD_TESTING=ON, full build, then the full non-GPU suite (ctest -E "^agc|gpu|vulkan|video_out" -j6).

  • main alone: 1363/1363 pass.
  • With this PR: unwind_cursor and the four unwind_cursor_* tests pass, but public_headers fails 3/3, and its 64 public_headers_compile_* dependents don't run:
    _Unwind_Backtrace_nid_postfix: expected exactly one header declaration; found 2: core/libs/prx/libc/include/Api.hpp:1326, core/libs/tests/UnwindCursor.cpp:17
    _Unwind_GetLanguageSpecificData_nid_postfix: expected exactly one header declaration; found 2: core/libs/prx/libc/include/Api.hpp:1321, core/libs/tests/UnwindCursor.cpp:19
    _Unwind_GetRegionStart_nid_postfix: expected exactly one header declaration; found 2: core/libs/prx/libc/include/Api.hpp:1322, core/libs/tests/UnwindCursor.cpp:18
    
  • Cause: #10706 (35cf8d56c / f38d29fd0, merged 2026-10-24) added the public_headers audit and canonical declarations of these three exports in libc/include/Api.hpp. The new UnwindCursor.cpp declares them a second time.

Minimal fix I checked: include the canonical header and drop the three local declarations:

--- a/core/libs/tests/UnwindCursor.cpp
+++ b/core/libs/tests/UnwindCursor.cpp
@@ -1,3 +1,4 @@
+#include "prx/libc/include/Api.hpp"
 #include "prx/libc/include/exceptions/Unwind.hpp"
@@
-extern "C" _Unwind_Reason_Code APS5_VABI _Unwind_Backtrace_nid_postfix(_Unwind_Trace_Fn trace, void* argument);
-extern "C" std::uintptr_t APS5_VABI _Unwind_GetRegionStart_nid_postfix(_Unwind_Context* context);
-extern "C" std::uintptr_t APS5_VABI _Unwind_GetLanguageSpecificData_nid_postfix(_Unwind_Context* context);

The rest of the test compiles unchanged. With it, the full non-GPU suite passes 1368/1368, including public_headers, all public_headers_compile_* and the five unwind_cursor* tests.

The head still merges cleanly onto the newer main 92bfca720. Since abed03546, nothing there has touched the audit script, libc/include/Api.hpp or the tab bit.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5662649155 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6819#pullrequestreview-5662649155). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-27T05:32:08Z. **Review:** COMMENTED --- Merge-skew check: head `3551ba114` merged onto current `main` `abed03546` (clean merge, `git merge --no-commit`). This head's CI ran on the October 22 base, before #10706 landed. Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release, `BUILD_TESTING=ON`, full build, then the full non-GPU suite (`ctest -E "^agc|gpu|vulkan|video_out" -j6`). - `main` alone: 1363/1363 pass. - With this PR: `unwind_cursor` and the four `unwind_cursor_*` tests pass, but `public_headers` fails 3/3, and its 64 `public_headers_compile_*` dependents don't run: ``` _Unwind_Backtrace_nid_postfix: expected exactly one header declaration; found 2: core/libs/prx/libc/include/Api.hpp:1326, core/libs/tests/UnwindCursor.cpp:17 _Unwind_GetLanguageSpecificData_nid_postfix: expected exactly one header declaration; found 2: core/libs/prx/libc/include/Api.hpp:1321, core/libs/tests/UnwindCursor.cpp:19 _Unwind_GetRegionStart_nid_postfix: expected exactly one header declaration; found 2: core/libs/prx/libc/include/Api.hpp:1322, core/libs/tests/UnwindCursor.cpp:18 ``` - Cause: #10706 (35cf8d56c / f38d29fd0, merged 2026-10-24) added the `public_headers` audit and canonical declarations of these three exports in `libc/include/Api.hpp`. The new `UnwindCursor.cpp` declares them a second time. Minimal fix I checked: include the canonical header and drop the three local declarations: ```diff --- a/core/libs/tests/UnwindCursor.cpp +++ b/core/libs/tests/UnwindCursor.cpp @@ -1,3 +1,4 @@ +#include "prx/libc/include/Api.hpp" #include "prx/libc/include/exceptions/Unwind.hpp" @@ -extern "C" _Unwind_Reason_Code APS5_VABI _Unwind_Backtrace_nid_postfix(_Unwind_Trace_Fn trace, void* argument); -extern "C" std::uintptr_t APS5_VABI _Unwind_GetRegionStart_nid_postfix(_Unwind_Context* context); -extern "C" std::uintptr_t APS5_VABI _Unwind_GetLanguageSpecificData_nid_postfix(_Unwind_Context* context); ``` The rest of the test compiles unchanged. With it, the full non-GPU suite passes 1368/1368, including `public_headers`, all `public_headers_compile_*` and the five `unwind_cursor*` tests. The head still merges cleanly onto the newer `main` `92bfca720`. Since `abed03546`, nothing there has touched the audit script, `libc/include/Api.hpp` or the tab bit. 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!6819
No description provided.