test: wire up the orphaned exception runtime test
- `core/libs/CMakeLists.txt`: registered `ExceptionRuntime.cpp` as `exception_runtime_tests`/`exception_runtime`, following the existing `Guest*.cpp` test pattern, linked against `libc`.
test(agc): fix and re-enable 3 of 8 bitrotted AGC driver tests
- `agc_driver_graphics_tests`: fixed the link failure by adding the three missing source files and linking `shader_recompiler_agc_driver`. Still fails at runtime against stale assertions accumulated over many commits of not being built (an expected "not implemented" message that texture support since removed, and a sampler test fixture value that no longer fits its 12-bit field). Left `EXCLUDE_FROM_ALL`; fixing the assertions is a separate pass across the whole 1150-line test file, not a build fix.
- `agc_driver_recompiler_tests`: root-caused but not fixed. It needs `COMPUTE_NUM_THREAD_X` set, and its pass condition checks for a "not implemented" stub error that no longer exists now that the real recompiler is in. Restoring its original intent needs a shader deliberately built to fail recompilation, which is a design decision, not something this PR should decide unilaterally. Left `EXCLUDE_FROM_ALL`.
- `agc_driver_tests`, `agc_shader_memory_tests`, `agc_driver_flip_tests` and `agc_driver_pm4_tests` already passed; registered them with `add_test` so none of the four can bitrot silently again.
fix: correct sscanf %x signedness and avoid a substr copy
- `core/libs/prx/libSceSysmodule/Export.cpp`: `devMajor`/`devMinor` now `unsigned int`.
- `core/libs/nid/include/nid/NidPatcherUtils.hpp`: two `substr(0, n)` calls replaced with `resize(n)`.
fix(exceptions): interpose libstdc++ ABI on Linux so the project's own unwinder drives it
- `OwnPersonality()` in `Unwind.cpp` now recognises the bare `__gxx_personality_v0` wrapper on Linux too (previously Windows-only).
- `Exports.cpp` exports the real ABI names (`__cxa_throw`, `__cxa_begin_catch`/`end_catch`, `__cxa_rethrow`, `__cxa_allocate`/`free_exception`, `__cxa_call_terminate`, `__cxa_get_exception_ptr`, `__cxa_current_exception_type`, `__cxa_init_primary_exception`, the `std::terminate`/`uncaught_exception(s)` mangled names, and the core `_Unwind_*` entry points) through the existing `GCC_GLOBAL_ALIAS` assembler-alias macro rather than new C++ definitions (a plain redefinition under these names conflicts with `<cxxabi.h>`'s own declarations). This lets ELF symbol interposition make this project's own implementation win process-wide over `libgcc_s.so.1`/`libstdc++.so.6`.
- `__cxa_init_primary_exception_nid_postfix` is new: GCC 13's inline `std::make_exception_ptr` calls `__cxa_init_primary_exception`, and nothing implemented it before.
- Deliberately did not alias `__dynamic_cast`, `__cxa_pure_virtual` or `__cxa_deleted_virtual`. Nothing in `core/libs/prx` needs them rerouted, and doing so would divert every RTTI cast in libstdc++ and third-party code (SDL2, glslang) through this project's slower walker for no benefit.
Kernel error codes were redeclared per file under three prefixes
(SCE_KERNEL_ERROR_, EQUEUE_ERROR_, KERNEL_SEMA_ERROR_), which let wrong
values go unnoticed. Define them once as 0x80020000 | errno for errno
1..94 and use the SCE_KERNEL_ERROR_ names everywhere. Values are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SCE kernel errors are 0x80020000 plus the FreeBSD errno. The equeue and
direct memory constants used an unrelated 0x8001xxxx range with mismatched
errno values (e.g. ETIMEDOUT was 0x80010023), so a guest checking
sceKernelWaitEqueue for SCE_KERNEL_ERROR_ETIMEDOUT saw an unexpected error.
SCE_KERNEL_ERROR_EDEADLK in Mutex.cpp held the EAGAIN value.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SCE kernel errors are 0x80020000 plus the FreeBSD errno. The equeue and
direct memory constants used an unrelated 0x8001xxxx range with mismatched
errno values (e.g. ETIMEDOUT was 0x80010023), so a guest checking
sceKernelWaitEqueue for SCE_KERNEL_ERROR_ETIMEDOUT saw an unexpected error.
SCE_KERNEL_ERROR_EDEADLK in Mutex.cpp held the EAGAIN value.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- scePthreadSelf returned null on Linux and for threads not created by
scePthreadCreate (including the main thread); such threads now get a
lazily adopted, non-joinable handle
- scePthreadExit on Linux skipped FinishThread, losing the join value
- detached threads on Linux were never freed; use the reference count
already used on Windows
- unlocking a recursive mutex from a non-owner was undefined behaviour;
return SCE_KERNEL_ERROR_EPERM
- scePthreadCondTimedwait did not restore the mutex owner after waking,
so another thread locking during the wait made the waiter's unlock
fail with EPERM and left the mutex locked forever
- SCE_KERNEL_ERROR_ETIMEDOUT in Cond.cpp was 0x80020062 instead of 0x8002003C
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Maintainer noted the opt-in-via-documented-flag SPIR-V validation gap
isn't the silent-stub category this doc tracks; the README correction
stands on its own.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Generated executables always used the console subsystem and opened a
console window on launch. The opt-in flag writes IMAGE_SUBSYSTEM_WINDOWS_GUI.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A zero frequency was stored and later used as a divisor when computing
the output block duration. Return SCE_AUDIO_OUT_ERROR_INVALID_SIZE and
SCE_AUDIO_OUT_ERROR_INVALID_SAMPLE_FREQ instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
std::system returns a wait status on POSIX, so returning it from main
truncated a guest exit code of 1 (status 256) to 0. The prompt also
required pressing Enter twice because cin.get followed cin.ignore.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dispatch cache with per-key value variants and data-only hits (flat-SRT leaves the recompiler
proves pure are refreshed into the resource template instead of re-captured), dispatch and draw
recipes replaying a proven prepare, register-keyed draw entries, template data refresh, unit
shadows in device-local slabs, 64 KiB block-unit storage tracking with windowed detile, DCC
clear-key proofs, per-class GPU timing, a CPU copy path with batch read tracking, present slot
ring, rate-limited reaps and lazy completion counting, plan-failure and poisoned source memos,
bindless image tables (runtime-indexed descriptor arrays from a CPU-read table) so the
per-frame compute program that failed its plan now compiles. Worker affinity opt-in, per-draw
logs behind APS5_TRACE_DRAWS, wait-timeout reports include the recorder's view of the label.
Fixes a use-after-free behind BDA-miss dispatch snapshots and the CPU-write stamp of
UnchangedSinceCollected. Intro-video stage: 154 -> ~500 presents per 10 s at 4K.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
EXTRQ, INSERTQ, MOVNTSS and MOVNTSD are rewritten at relink time: same-length in-place forms
where they exist, otherwise a jmp rel32 into an appended executable section holding a
scratch-free SSE body and a jump back, so no code shifts and no RIP-relative or jump-table
operand needs adjusting. Decoder fixes for POPCNT and 0F BB (BTC), codegen and elfpatcher
tests, README and technical-debt notes. The runtime illegal-instruction trap stays as a
fallback.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
libkernel: a TimedWait service for condition variables, semaphores, event flags, rwlocks and
equeues with the scheduler tick; mutex/cond/sem corner cases the title hits; job worker
affinity is opt-in (APS5_JOB_AFFINITY). libc: calloc/realloc heap slot swap, a default
terminate handler with a backtrace, CPU topology helper. libSceRtc export fixes with tests.
libSceVideoOut: APS5_NO_PAD_INPUT ignores host input for unattended measurements,
APS5_FLIP_QUEUE_WAIT keeps a stalled process alive for a debugger. ApplicationHeap and
GuestRtc tests wired into the test build.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
These EXCLUDE_FROM_ALL targets weren't registered with add_test, so
they silently bitrotted with no CI/ctest visibility:
- agc_driver_graphics_tests: fixed a link failure (Draw.cpp, Pipeline.cpp
and GraphicsPipelineCache.cpp were never added to the target's sources
when the test started calling into them). Still fails at runtime against
several stale assertions (a removed "not implemented" error message, a
sampler fixture value that doesn't fit its bitfield) accumulated over
many commits of not being built; left EXCLUDE_FROM_ALL pending an
assertion-maintenance pass.
- agc_driver_recompiler_tests: root-caused (missing COMPUTE_NUM_THREAD_X
register setup, plus a pass condition checking for a stub error message
that no longer exists now that the real recompiler is implemented) but
left unfixed and EXCLUDE_FROM_ALL — restoring its original intent needs
a shader deliberately built to fail recompilation, a design decision.
agc_driver_tests, agc_shader_memory_tests, agc_driver_flip_tests and
agc_driver_pm4_tests already passed; registered them with add_test too
so none of the five can bitrot silently again.
agc_driver_bda_device_tests: dropped from this commit's scope. Upstream
PR #20 already proposes the same one-line BdaContracts.cpp fix (matching
the runtime message's "signature" text), so BdaContracts.cpp is left
untouched here to avoid duplicating that fix. The test target stays
defined (EXCLUDE_FROM_ALL, still buildable by name) but is no longer
registered with add_test until #20 or an equivalent fix lands.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ExceptionRuntime.cpp existed complete and working but was never
registered in CMakeLists.txt, so it never built or ran. Wired it in
following the existing Guest*.cpp test pattern.
The other three orphaned test files (PthreadStart.cpp, FileStreams.cpp,
Formatting.cpp) were left out: each has genuine bitrot against current
code (a moved header, fseek returning errno instead of throwing on an
invalid whence, and vsnprintf's expected va_list mutation) that needs a
source-level decision, not a CMake wiring fix.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
README stated SPIR-V is "successfully produces validated via Spirv-Tools"
unconditionally, but ANYPS5_ENABLE_SPIRV_TOOLS defaults OFF and the only
validation call is gated behind it, so this doesn't happen in a default
build. Caveated the README line and added the gap to TechnicalDebt.md's
silent-stubs list. Also fixed a stale line-number citation there (a prior
refactor moved the SpirvTargetOptions assignment block from row 219 to 212).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
libSceSysmodule/Export.cpp parsed /proc/self/maps device major/minor
numbers into signed int with a %x format, which is undefined behaviour
per the C standard even though it happened to work on this target;
switched to unsigned int to match the format specifier.
NidPatcherUtils.hpp's StripNidPostfix built a truncated copy with
substr(0, n) where the prefix is already the string itself; resize(n)
does the same truncation without the extra allocation and copy.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Exports.cpp aliased the real std::uncaught_exception(s) mangled names
directly to __cxa_uncaught_exception(s)_nid_postfix instead of the
existing _ZSt18uncaught_exceptionv_nid_postfix/_ZSt19uncaught_exceptionsv_nid_postfix
wrappers, leaving the latter as dead code and breaking the file's own
bare-name -> matching-nid_postfix alias pattern (caught by fleet QA
review, no functional impact since it's a raw symbol alias and both
sides return in the same register).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
On native Linux these PRX shared libraries and their test executables
dynamically link real libstdc++/libgcc, so a plain throw went through the
system's __cxa_throw/_Unwind_RaiseException. That still invoked this
project's own __gxx_personality_v0_nid_postfix (the CIE's personality
pointer is a raw function address, agnostic to which unwinder is walking
the stack), but handed it libgcc's incompatible private _Unwind_Context
layout, corrupting every field Personality.cpp reads and aborting with no
exception message.
Fix: OwnPersonality() now recognises the bare __gxx_personality_v0 wrapper
on Linux too (previously Windows-only), and Exports.cpp exports the real
ABI names (__cxa_throw, __cxa_begin_catch/end_catch, __cxa_rethrow,
__cxa_allocate/free_exception, __cxa_call_terminate, __cxa_get_exception_ptr,
__cxa_current_exception_type, __cxa_init_primary_exception, the std::
terminate/uncaught_exception(s) mangled names, and the core _Unwind_*
entry points) via the existing GCC_GLOBAL_ALIAS assembler-alias mechanism,
so ELF symbol interposition makes this project's own implementation win
process-wide over libgcc_s.so.1/libstdc++.so.6. __cxa_init_primary_exception
is newly implemented; GCC 13's inline std::make_exception_ptr needs it and
nothing provided it before.
Fixes 7 previously-aborting tests: guest_rendering_wait, guest_buffer_reuse,
guest_shader_link, guest_system_exit_parameters, guest_once, guest_memory,
guest_search.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
feat(rtc): implement libSceRtc date and tick functions
- Ticks count microseconds since 0001-01-01 00:00:00 in the proleptic Gregorian calendar, up to 9999-12-31 23:59:59.999999. `sceRtcGetTickResolution` returns 1000000.
- Validation (`sceRtcCheckValid`, `sceRtcIsLeapYear`, `sceRtcGetDayOfWeek`) returns the matching `SCE_RTC_ERROR_INVALID_*` code (`0x80B50002`–`0x80B5000E`).
- Conversions: `sceRtcGetTick`/`SetTick`, `GetTime_t`/`SetTime_t`, `GetWin32FileTime`/`SetWin32FileTime`.
- Current time: `sceRtcGetCurrentTick`, `GetCurrentClock`, `GetCurrentClockLocalTime`. `sceRtcGetCurrentNetworkTick` uses the host clock.
- UTC and local time conversion through the host time zone.
- `sceRtcFormatRFC3339` (`YYYY-MM-DDThh:mm:ss.cc` plus `Z` or `±hh:mm`) and `sceRtcParseRFC3339`.
- Tick arithmetic (`sceRtcTickAdd*`) rejects results outside the valid range with `SCE_RTC_ERROR_INVALID_VALUE`.
- New exports: `sceRtcGetDaysInMonth`, `sceRtcTickAddMonths` and `sceRtcTickAddYears`. The last two clamp the day to the end of the target month (2024-01-31 + 1 month = 2024-02-29).
feat(random): implement sceRandomGetRandomNumber
- Fill the buffer from `std::random_device`.
- Return `SCE_RANDOM_ERROR_INVALID` (`0x817C0016`) for a null buffer or a size above `SCE_RANDOM_MAX_SIZE` (64), matching the system library, and leave the buffer untouched in that case.
- Add a `guest_random` test that covers the invalid arguments, a zero size, partial-word sizes (no write past `size`), and two 64-byte draws that differ.
Ticks count microseconds since 0001-01-01 in the proleptic Gregorian
calendar, up to 9999-12-31 23:59:59.999999. Implement validation, tick
and date conversion, time_t and Win32 FILETIME conversion, UTC and
local time conversion through the host time zone, RFC 3339 formatting
and parsing, and tick arithmetic. Add sceRtcGetDaysInMonth,
sceRtcTickAddMonths and sceRtcTickAddYears, which clamp the day to the
end of the target month.
The network clock uses the host clock.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fill the buffer from std::random_device and reject a null buffer or a
size above SCE_RANDOM_MAX_SIZE (64) with SCE_RANDOM_ERROR_INVALID, as
the system library does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests in core/libs link against the prx shared libraries, which the
global -static flag rejects on Linux ("attempted static link of dynamic
object"). Drop -static in that directory on non-Windows hosts while
keeping the static GCC runtime.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The SDK's inline release wrapper passes gdsOffset 0 and gdsSize 1 for
every release, not only GDS ones. The packet ignores the range unless the
GDS data selector is used, so accept that default.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Guest mprotect calls on the executable's own segments failed with
"guest protection or unmap range is not registered" because only the
Windows build registered the main image. Register the PT_LOAD segments of
the main executable page by page, merging the protections of segments that
share a page.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Retail titles pass protections such as 0xC2 (CPU read/write plus the
0x40 and 0x80 device access bits). The device bits do not affect CPU
access and were rejected as unsupported.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SCE_KERNEL_PROT_CPU_RW (0x02) and CPU_EXEC (0x04) include read access,
but were translated to write-only and execute-only host pages. GPU read
and write bits also need host access because the emulated GPU reads and
writes guest memory from the CPU. Write-only mappings made the AGC driver
reject guest data segments as unreadable.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SceLibcMallocReplace lists calloc before realloc (malloc, free, calloc,
realloc, memalign, reallocalign, posix_memalign, ...), as the table in
retail titles shows. realloc therefore called the application's calloc
with the old pointer as the element count, and calloc called realloc.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GCC on Linux rejects the attribute, which breaks the libs build since the
F11 fullscreen change. It has no effect on x86-64 Windows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Distributions without static X11 libraries (such as Arch-based ones) fail
SDL2's X11 feature checks because the global -static linker flag also
applies to its try_compile probes. Restore the flag after SDL2 is added.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>