Files
AnyPS5/core/libs/tests/EmscriptenModuleUnwind.cpp
T
Dean Galvin e79ea36180 fix(run-report): keep the counted shader failure in HostThreadLocal; check the host CPU as a report
NoteFailureOnce kept the last counted exception in a thread_local
std::exception_ptr. In a prx on Windows its destructor runs after emulated
TLS freed the object, which prx_thread_local_destructors refuses. Keep it in
HostThreadLocal like the recompiler's other per-thread state.

host-probe checked the raw CPU name with SafeText, which rejects '@', so it
failed on CPUs whose name ends in a clock ("... CPU @ 2.10GHz") although the
report keeps the name with the clock cut. Check it through the report.

NotImplemented_nid_no_patch now expands to NotImplementedAt_nid_no_patch, so
emscripten_module_unwind_tests, which does not link libc, also stubs the
located entry point.
2026-11-05 00:14:07 +13:00

46 lines
1.5 KiB
C++

#include "prx/libkernel/include/Api.hpp"
#include "prx/libkernel/KernelErrors.hpp"
#include "prx/libSceSysmodule/include/Api.hpp"
#include <array>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <limits>
namespace {
struct UnsupportedPath {
const char* function;
};
}
extern "C" [[noreturn]] void NotImplemented_nid_no_patch(const char* function) {
throw UnsupportedPath{function};
}
extern "C" [[noreturn]] void NotImplementedAt_nid_no_patch(const char* function, const char*, int) {
throw UnsupportedPath{function};
}
int main() {
for (const auto query : {&sceKernelGetModuleInfoForUnwind, &sceSysmoduleGetModuleInfoForUnwind}) {
for (const auto address : {std::uint64_t{0}, std::uint64_t{0x10000}, std::numeric_limits<std::uint64_t>::max()}) {
for (const int flags : {0, 1, -1}) {
ModuleInfoForUnwind info;
std::memset(&info, 0xa5, sizeof(info));
std::array<unsigned char, sizeof(info)> before;
std::memcpy(before.data(), &info, sizeof(info));
try {
query(address, flags, &info);
std::abort();
} catch (const UnsupportedPath& error) {
if (std::strcmp(error.function, "sceKernelGetModuleInfoForUnwind") != 0 ||
std::memcmp(before.data(), &info, sizeof(info)) != 0) std::abort();
}
}
}
}
if (sceKernelGetModuleInfoForUnwind(0, 0, nullptr) != SCE_KERNEL_ERROR_EFAULT) std::abort();
}