feat(libkernel): log guest exception context #7655

Merged
farosch merged 2 commits from upstream-pr/7655 into main 2026-10-20 00:28:17 +00:00
farosch commented 2026-10-18 20:28:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by farosch on 2026-10-18T20:28:39Z.


What

Log the saved guest signal context before invoking a guest exception handler: signal number, RIP/RSP, flags, trap/error/fault fields, and general-purpose registers. Format into a fixed buffer and write directly to stderr, avoiding the normal logger in the POSIX signal-handler path. Debug-raise APIs now print exception codes in hex and include the caller address. These diagnostics do not change handler or termination behavior.

Tested

Linux x86-64: cmake --build build --target libs --parallel passed; no source errors reported. Manual runtime check produced:
[src/Exception.cpp:576 sceKernelDebugRaiseExceptionOnReleaseMode] ... c1=0xa0020004 c2=0x00000000 caller=...
The process still terminates on its existing SIGILL. The guest-register dump path was not exercised by that run because the unhandled host SIGILL bypasses guest exception dispatch. Windows not tested.

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:4912548206 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7655). Originally posted by [farosch](https://github.com/farosch) on 2026-10-18T20:28:39Z. --- ### What Log the saved guest signal context before invoking a guest exception handler: signal number, RIP/RSP, flags, trap/error/fault fields, and general-purpose registers. Format into a fixed buffer and write directly to stderr, avoiding the normal logger in the POSIX signal-handler path. Debug-raise APIs now print exception codes in hex and include the caller address. These diagnostics do not change handler or termination behavior. ### Tested Linux x86-64: `cmake --build build --target libs --parallel` passed; no source errors reported. Manual runtime check produced: `[src/Exception.cpp:576 sceKernelDebugRaiseExceptionOnReleaseMode] ... c1=0xa0020004 c2=0x00000000 caller=...` The process still terminates on its existing SIGILL. The guest-register dump path was not exercised by that run because the unhandled host SIGILL bypasses guest exception dispatch. Windows not tested. ### 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 - Depends on: none - Fixes: none - Unblocks: none - GPUs tested: n/a - AI-assisted: yes
github-actions[bot] commented 2026-10-18 20:48:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T20:48:15Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 7192 core/libs/prx/libkernel/System/src/Exception.cpp L125-128

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 core/libs/prx/libkernel/System/src/Exception.cpp
PR 6879 core/libs/prx/libkernel/System/src/Exception.cpp
PR 7201 core/libs/prx/libkernel/System/src/Exception.cpp
PR 7332 core/libs/prx/libkernel/System/src/Exception.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6254966497 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7655#issuecomment-6254966497). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-18T20:48:15Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 7192](https://www.github.com/boykopovar/AnyPS5/pull/7192) | `core/libs/prx/libkernel/System/src/Exception.cpp` [L125-128](https://github.com/boykopovar/AnyPS5/blob/95d901b9371f2c623b8894b2ace401132d36256a/core/libs/prx/libkernel/System/src/Exception.cpp#L125-L128) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libkernel/System/src/Exception.cpp` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `core/libs/prx/libkernel/System/src/Exception.cpp` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libkernel/System/src/Exception.cpp` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `core/libs/prx/libkernel/System/src/Exception.cpp` |
LeandroLP23 commented 2026-10-18 20:52:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-18T20:52:12Z.


Windows run, since the description covers Linux only. Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. Build: main e8ad642fe with #7651, #7650, #7647, #7655 and #7648 merged together (each merge clean, built once).

The build is clean. The existing guest exception tests pass 3 runs of 3: guest_raise_exception, guest_mutex_raise_exception, guest_raise_nested_sleep and windows_exceptions. I didn't check whether any of them reaches the new log line, so this covers the build and no regression in those paths.

AI-assisted

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6255005820 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7655#issuecomment-6255005820). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-18T20:52:12Z. --- Windows run, since the description covers Linux only. Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`. Build: `main` `e8ad642fe` with #7651, #7650, #7647, #7655 and #7648 merged together (each merge clean, built once). The build is clean. The existing guest exception tests pass 3 runs of 3: `guest_raise_exception`, `guest_mutex_raise_exception`, `guest_raise_nested_sleep` and `windows_exceptions`. I didn't check whether any of them reaches the new log line, so this covers the build and no regression in those paths. AI-assisted
adriadam10 commented 2026-10-20 00:30:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T00:30:07Z.


Checked the context dump: the fixed 768-byte buffer holds the longest line (~520 bytes), it only uses write/WriteFile (no allocation or logger in the signal path), the GuestMcontext fields exist, and handler behaviour is unchanged. Windows build confirmed by @LeandroLP23; merged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6280433325 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7655#issuecomment-6280433325). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-20T00:30:07Z. --- Checked the context dump: the fixed 768-byte buffer holds the longest line (~520 bytes), it only uses `write`/`WriteFile` (no allocation or logger in the signal path), the `GuestMcontext` fields exist, and handler behaviour is unchanged. Windows build confirmed by @LeandroLP23; merged.
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!7655
No description provided.