Xbox Cloud Gaming app for PS5 Homebrew
C
Crash reports: record faulting instruction offset (pc=eboot+0x...), backtrace and symbolizer script
Rafael Abud Ferreirae84b56255fad
diff --git a/.gitignore b/.gitignoreindex 9504f56..785e3b2 100644--- a/.gitignore+++ b/.gitignore@@ -1,5 +1,6 @@-# Build trees (CMake, FFmpeg install, linked eboot, packaged app)+# Build trees (CMake, FFmpeg install, linked eboot, packaged app) and unstripped ELFs/build-*/+/symbols/# Never commit: sign-in tokens, logs, autotest captures and stream dumpsaccount.json*.logdiff --git a/CMakeLists.txt b/CMakeLists.txtindex 6bc82d9..a0f9cf8 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -44,7 +44,7 @@ add_library(xcloud_core STATIC)target_include_directories(xcloud_core PUBLIC src)if(NOT MSVC)- target_compile_options(xcloud_core PRIVATE -Wall -Wextra -Wno-unused-parameter)+ target_compile_options(xcloud_core PUBLIC -g1 -fno-omit-frame-pointer PRIVATE -Wall -Wextra -Wno-unused-parameter)endif()# mbedTLS and libdatachannel are built from deps/ for both targets.diff --git a/cmake/ps5.toolchain.cmake b/cmake/ps5.toolchain.cmakeindex c6ad2ee..fa93c84 100644--- a/cmake/ps5.toolchain.cmake+++ b/cmake/ps5.toolchain.cmake@@ -41,7 +41,7 @@ get_filename_component(XC_SOURCE_ROOT "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)set(XC_PATH_MAP "\"-ffile-prefix-map=${XC_SOURCE_ROOT}=.\" \"-ffile-prefix-map=$ENV{HOME}=~\"")set(PS5_COMMON_FLAGS- "${XC_PATH_MAP} -fPIC -ffunction-sections -fdata-sections -funwind-tables -fexceptions -march=znver2 -fvisibility-nodllstorageclass=default -fno-stack-protector -fno-plt -femulated-tls -fdenormal-fp-math=ieee -isysroot \"${PS5_SDK}\" -D_GNU_SOURCE -DXCLOUD_PS5=1 \"-include${CMAKE_CURRENT_LIST_DIR}/../ps5/compat/ps5_lfs.h\"")+ "${XC_PATH_MAP} -g1 -fno-omit-frame-pointer -fPIC -ffunction-sections -fdata-sections -funwind-tables -fexceptions -march=znver2 -fvisibility-nodllstorageclass=default -fno-stack-protector -fno-plt -femulated-tls -fdenormal-fp-math=ieee -isysroot \"${PS5_SDK}\" -D_GNU_SOURCE -DXCLOUD_PS5=1 \"-include${CMAKE_CURRENT_LIST_DIR}/../ps5/compat/ps5_lfs.h\"")set(CMAKE_C_FLAGS_INIT "${PS5_COMMON_FLAGS} -isystem \"${PS5_SDK}/target/include\"")set(CMAKE_CXX_FLAGS_INIT "${PS5_COMMON_FLAGS} -fcxx-exceptions -frtti -isystem \"${PS5_SDK}/target/include/c++/v1\" -isystem \"${PS5_SDK}/target/include\"")diff --git a/ps5/xcloud-ps5.ld b/ps5/xcloud-ps5.ldindex 7a4c3e7..1ed23c8 100644--- a/ps5/xcloud-ps5.ld+++ b/ps5/xcloud-ps5.ld@@ -2,3 +2,4 @@* console crash reporter reads (.text starts at VMA 0 in that layout, as it* did in the PS4 port's OpenOrbis link.x). */PROVIDE(__text_start = ADDR(.text));+PROVIDE(__text_end = ADDR(.text) + SIZEOF(.text));diff --git a/src/app/autoplay.cpp b/src/app/autoplay.cppindex d18aac3..65acc35 100644--- a/src/app/autoplay.cpp+++ b/src/app/autoplay.cpp@@ -639,6 +639,8 @@ void autoplayScreens(const ui::Canvas& canvas, uint64_t now) {if (now - homeSince > waitMs) {uiSaved = true;saveCanvas("ui.ppm");+ if (g_autoplay.title == "AUTOTEST" && !g_autoplay.crashTest && g_ui->reportOpen())+ XC_LOGI("AUTOPLAY END: crash report shown");}}if (tuneShot) {@@ -669,7 +671,9 @@ void autoplayScreens(const ui::Canvas& canvas, uint64_t now) {}if (g_autoplay.crashTest && uiSaved) {XC_LOGI("AUTOPLAY END: crash test (SIGSEGV now)");- std::raise(SIGSEGV);+ volatile int* nullPtr = nullptr;+ asm volatile("" : "+r"(nullPtr));+ *nullPtr = 1;}if (g_autoplay.quickTest && uiSaved) {g_autoplay.quickTest = false;diff --git a/src/app/crash_guard.cpp b/src/app/crash_guard.cppindex 023dbfd..e0f5674 100644--- a/src/app/crash_guard.cpp+++ b/src/app/crash_guard.cpp@@ -7,12 +7,34 @@#include <atomic>#include <csignal>+#include <cstdint>#include <cstring>#include <exception>#include <fcntl.h>#include <thread>+#include <ucontext.h>#include <unistd.h>+#if defined(XCLOUD_PS5)+#include <ps5platform/context.h>+extern "C" {+extern const char __text_start[];+extern const char __text_end[];+struct SceModuleInfoForUnwind {+ size_t st_size;+ char name[256];+ uintptr_t eh_frame_hdr_addr;+ uintptr_t eh_frame_addr;+ size_t eh_frame_size;+ uintptr_t seg0_addr;+ size_t seg0_size;+};+int sceKernelGetModuleInfoForUnwind(uintptr_t addr, int flags, SceModuleInfoForUnwind* info);+}+#else+#include <link.h>+#endif+namespace xc::app::crash {namespace {@@ -20,6 +42,29 @@ namespace {char g_marker[512] = {};char g_stage[96] = "starting";std::atomic<uint64_t> g_beat{0};+uintptr_t g_ebootBase = 0;+uintptr_t g_ebootEnd = 0;++void initBase() {+#if defined(XCLOUD_PS5)+ g_ebootBase = reinterpret_cast<uintptr_t>(__text_start);+ g_ebootEnd = reinterpret_cast<uintptr_t>(__text_end);+#else+ dl_iterate_phdr(+ [](struct dl_phdr_info* info, size_t, void*) -> int {+ g_ebootBase = static_cast<uintptr_t>(info->dlpi_addr);+ uintptr_t end = g_ebootBase;+ for (int i = 0; i < info->dlpi_phnum; ++i) {+ if (info->dlpi_phdr[i].p_type != PT_LOAD) continue;+ uintptr_t segEnd = g_ebootBase + info->dlpi_phdr[i].p_vaddr + info->dlpi_phdr[i].p_memsz;+ if (segEnd > end) end = segEnd;+ }+ g_ebootEnd = end;+ return 1; // first module is the main executable+ },+ nullptr);+#endif+}const char* signalName(int sig) {switch (sig) {@@ -32,8 +77,103 @@ const char* signalName(int sig) {}}+void appendStr(char* buf, size_t cap, size_t& len, const char* s) {+ if (!s) return;+ while (*s && len + 1 < cap) buf[len++] = *s++;+ buf[len] = 0;+}++void appendDec(char* buf, size_t cap, size_t& len, int val) {+ char tmp[16];+ int n = 0;+ unsigned int v = val < 0 ? static_cast<unsigned int>(-val) : static_cast<unsigned int>(val);+ if (val < 0 && len + 1 < cap) buf[len++] = '-';+ do {+ tmp[n++] = static_cast<char>('0' + (v % 10));+ v /= 10;+ } while (v && n < 15);+ while (n > 0 && len + 1 < cap) buf[len++] = tmp[--n];+ buf[len] = 0;+}++void appendHex(char* buf, size_t cap, size_t& len, uintptr_t val) {+ appendStr(buf, cap, len, "0x");+ char tmp[20];+ int n = 0;+ do {+ unsigned int d = static_cast<unsigned int>(val & 0xf);+ tmp[n++] = static_cast<char>(d < 10 ? ('0' + d) : ('a' + d - 10));+ val >>= 4;+ } while (val && n < 16);+ while (n > 0 && len + 1 < cap) buf[len++] = tmp[--n];+ buf[len] = 0;+}++const char* baseName(const char* path) {+ if (!path) return "";+ const char* last = path;+ for (const char* p = path; *p; ++p)+ if (*p == '/') last = p + 1;+ return last;+}++void appendCodeAddr(char* buf, size_t cap, size_t& len, uintptr_t addr) {+ if (addr != 0 && g_ebootEnd > g_ebootBase && addr >= g_ebootBase && addr < g_ebootEnd) {+ appendStr(buf, cap, len, "eboot+");+ appendHex(buf, cap, len, addr - g_ebootBase);+ return;+ }+ if (addr != 0) {+#if defined(XCLOUD_PS5)+ SceModuleInfoForUnwind mod{};+ mod.st_size = sizeof(mod);+ if (sceKernelGetModuleInfoForUnwind(addr, 1, &mod) == 0 && mod.name[0] && addr >= mod.seg0_addr) {+ const char* name = baseName(mod.name);+ if (std::strcmp(name, "eboot.bin") == 0 || std::strcmp(name, "eboot.elf") == 0) name = "eboot";+ appendStr(buf, cap, len, name);+ appendStr(buf, cap, len, "+");+ appendHex(buf, cap, len, addr - mod.seg0_addr);+ return;+ }+#else+ struct Lookup {+ uintptr_t addr;+ const char* name;+ uintptr_t base;+ bool found;+ } q{addr, nullptr, 0, false};+ dl_iterate_phdr(+ [](struct dl_phdr_info* info, size_t, void* data) -> int {+ auto* l = static_cast<Lookup*>(data);+ uintptr_t base = static_cast<uintptr_t>(info->dlpi_addr);+ for (int i = 0; i < info->dlpi_phnum; ++i) {+ if (info->dlpi_phdr[i].p_type != PT_LOAD) continue;+ uintptr_t lo = base + info->dlpi_phdr[i].p_vaddr;+ uintptr_t hi = lo + info->dlpi_phdr[i].p_memsz;+ if (l->addr >= lo && l->addr < hi) {+ l->name = info->dlpi_name;+ l->base = base;+ l->found = true;+ return 1;+ }+ }+ return 0;+ },+ &q);+ if (q.found) {+ const char* name = (q.name && q.name[0]) ? baseName(q.name) : "eboot";+ appendStr(buf, cap, len, name);+ appendStr(buf, cap, len, "+");+ appendHex(buf, cap, len, addr - q.base);+ return;+ }+#endif+ }+ appendHex(buf, cap, len, addr);+}+// Async-signal-safe: open / write / close only, no allocation.-void writeMarker(const char* kind) {+void writeMarker(const char* kind, const char* crashLine = nullptr, uintptr_t rbp = 0, uintptr_t rsp = 0) {if (!g_marker[0]) return;int fd = ::open(g_marker, O_WRONLY | O_CREAT | O_TRUNC, 0666);if (fd < 0) return;@@ -42,32 +182,104 @@ void writeMarker(const char* kind) {put("\n");put(g_stage);put("\n");+ if (crashLine && crashLine[0]) {+ put(crashLine);+ // Optional caller return addresses via frame pointers, written after+ // the main crash line is already flushed to the descriptor.+ if (rsp != 0 && (rbp & (sizeof(uintptr_t) - 1)) == 0 && rbp >= rsp && rbp - rsp <= (256u << 10)) {+ uintptr_t fp = rbp;+ bool any = false;+ for (int depth = 0; depth < 6; ++depth) {+ const auto* frame = reinterpret_cast<const uintptr_t*>(fp);+ uintptr_t nextFp = frame[0];+ uintptr_t ret = frame[1];+ if (ret == 0) break;+ char item[96];+ size_t len = 0;+ appendStr(item, sizeof item, len, any ? "," : " bt=");+ appendCodeAddr(item, sizeof item, len, ret - 1);+ put(item);+ any = true;+ if ((nextFp & (sizeof(uintptr_t) - 1)) != 0 || nextFp <= fp || nextFp - fp > (64u << 10)) break;+ fp = nextFp;+ }+ }+ put("\n");+ }::close(fd);}-void onSignal(int sig) {- char kind[48] = "signal ";- char num[8];- int n = 0, v = sig;- do num[n++] = static_cast<char>('0' + v % 10), v /= 10; while (v && n < 7);- size_t k = std::strlen(kind);- while (n) kind[k++] = num[--n];- kind[k] = 0;- std::strcat(kind, " (");- std::strcat(kind, signalName(sig));- std::strcat(kind, ")");- writeMarker(kind);- std::signal(sig, SIG_DFL);- std::raise(sig);+void onSignal(int sig, siginfo_t* info, void* uctx) {+ char kind[48];+ size_t klen = 0;+ appendStr(kind, sizeof kind, klen, "signal ");+ appendDec(kind, sizeof kind, klen, sig);+ appendStr(kind, sizeof kind, klen, " (");+ appendStr(kind, sizeof kind, klen, signalName(sig));+ appendStr(kind, sizeof kind, klen, ")");++ uintptr_t pc = 0, rbp = 0, rsp = 0;+ if (uctx) {+ const auto* uc = static_cast<const ucontext_t*>(uctx);+#if defined(__FreeBSD__) || defined(__PROSPERO__) || defined(XCLOUD_PS5)+ pc = static_cast<uintptr_t>(uc->uc_mcontext.mc_rip);+ rbp = static_cast<uintptr_t>(uc->uc_mcontext.mc_rbp);+ rsp = static_cast<uintptr_t>(uc->uc_mcontext.mc_rsp);+#elif defined(__x86_64__) && defined(__linux__)+ pc = static_cast<uintptr_t>(uc->uc_mcontext.gregs[REG_RIP]);+ rbp = static_cast<uintptr_t>(uc->uc_mcontext.gregs[REG_RBP]);+ rsp = static_cast<uintptr_t>(uc->uc_mcontext.gregs[REG_RSP]);+#endif+ }+ uintptr_t faultAddr = info ? reinterpret_cast<uintptr_t>(info->si_addr) : 0;+#if defined(__FreeBSD__) || defined(__PROSPERO__) || defined(XCLOUD_PS5)+ if ((sig == SIGSEGV || sig == SIGBUS) && faultAddr == 0 && uctx) {+ const auto* uc = static_cast<const ucontext_t*>(uctx);+ faultAddr = static_cast<uintptr_t>(uc->uc_mcontext.mc_addr);+ }+#endif++ char crashLine[192];+ size_t clen = 0;+ appendStr(crashLine, sizeof crashLine, clen, "crash: ");+ appendStr(crashLine, sizeof crashLine, clen, signalName(sig));+ appendStr(crashLine, sizeof crashLine, clen, " pc=");+ appendCodeAddr(crashLine, sizeof crashLine, clen, pc);+ appendStr(crashLine, sizeof crashLine, clen, " addr=");+ appendHex(crashLine, sizeof crashLine, clen, faultAddr);++ writeMarker(kind, crashLine, rbp, rsp);++ struct sigaction dfl{};+ dfl.sa_handler = SIG_DFL;+ sigemptyset(&dfl.sa_mask);+ ::sigaction(sig, &dfl, nullptr);+ ::raise(sig);}} // namespacevoid install(const std::string& markerPath) {+ initBase();std::strncpy(g_marker, markerPath.c_str(), sizeof g_marker - 1);- for (int sig : {SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGABRT}) std::signal(sig, onSignal);+ g_marker[sizeof g_marker - 1] = 0;+ struct sigaction sa{};+ sa.sa_sigaction = onSignal;+ sa.sa_flags = SA_SIGINFO | SA_RESETHAND;+ sigemptyset(&sa.sa_mask);+ for (int sig : {SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGABRT}) ::sigaction(sig, &sa, nullptr);std::set_terminate([] {- writeMarker("uncaught exception");+ uintptr_t caller = reinterpret_cast<uintptr_t>(__builtin_return_address(0));+ char crashLine[160];+ size_t clen = 0;+ appendStr(crashLine, sizeof crashLine, clen, "crash: terminate pc=");+ appendCodeAddr(crashLine, sizeof crashLine, clen, caller ? caller - 1 : 0);+ appendStr(crashLine, sizeof crashLine, clen, " addr=0x0");+ writeMarker("uncaught exception", crashLine);+ struct sigaction dfl{};+ dfl.sa_handler = SIG_DFL;+ sigemptyset(&dfl.sa_mask);+ ::sigaction(SIGABRT, &dfl, nullptr);std::abort();});}@@ -122,12 +334,21 @@ Previous takePrevious(const std::string& markerPath) {std::string text;if (!platform::readFile(markerPath, text)) return p;::unlink(markerPath.c_str());- size_t nl = text.find('\n');+ auto trimCr = [](std::string& s) {+ while (!s.empty() && (s.back() == '\n' || s.back() == '\r')) s.pop_back();+ };+ size_t nl1 = text.find('\n');p.found = true;- p.kind = text.substr(0, nl);- if (nl != std::string::npos) {- p.stage = text.substr(nl + 1);- while (!p.stage.empty() && (p.stage.back() == '\n' || p.stage.back() == '\r')) p.stage.pop_back();+ p.kind = text.substr(0, nl1);+ trimCr(p.kind);+ if (nl1 != std::string::npos) {+ size_t nl2 = text.find('\n', nl1 + 1);+ p.stage = text.substr(nl1 + 1, nl2 == std::string::npos ? std::string::npos : nl2 - (nl1 + 1));+ trimCr(p.stage);+ if (nl2 != std::string::npos) {+ p.crash = text.substr(nl2 + 1);+ trimCr(p.crash);+ }}return p;}diff --git a/src/app/crash_guard.h b/src/app/crash_guard.hindex 94d3560..0456302 100644--- a/src/app/crash_guard.h+++ b/src/app/crash_guard.h@@ -27,6 +27,7 @@ struct Previous {bool found = false;std::string kind; // "signal 11 (SIGSEGV)", "uncaught exception", "stalled"std::string stage; // setStage()'s at the time+ std::string crash; // "crash: SIGSEGV pc=eboot+0x1a2b3c addr=0x0 ..."};// The last session's marker, if it left one (then removed).Previous takePrevious(const std::string& markerPath);diff --git a/src/app/ps5_main.cpp b/src/app/ps5_main.cppindex 9e22a51..98e5ae2 100644--- a/src/app/ps5_main.cpp+++ b/src/app/ps5_main.cpp@@ -75,7 +75,7 @@ std::string crashMarkerPath() { return platform::dataDir() + "/crash.marker"; }// "Report a problem": the bug form's link, filled in, as a QR code. `what`// is the error shown (empty from Settings); `previousSession` takes the log// of the session that went down instead of this one.-void openReport(const std::string& what, bool previousSession, const std::string& heading) {+void openReport(const std::string& what, bool previousSession, const std::string& heading, const std::string& crash = {}) {std::string logText;platform::readFile(platform::dataDir() + "/xcloud.log", logText);std::vector<std::string> privateWords = {g_ui->gamertag()};@@ -87,9 +87,12 @@ void openReport(const std::string& what, bool previousSession, const std::stringinfo.release = XC_APP_VERSION;info.firmware = platform::firmwareVersion();info.log = report::sanitize(report::logExcerpt(logText, previousSession), privateWords);+ info.crash = report::sanitize(crash, privateWords);std::string url = report::issueUrl(info);- XC_LOGI("report: QR code shown (%zu characters)", url.size());- g_ui->showReport(url, heading);+ std::string detail = info.crash;+ if (!detail.empty() && !info.release.empty()) detail += " (v" + info.release + ")";+ XC_LOGI("report: QR code shown (%zu characters)%s%s", url.size(), detail.empty() ? "" : " — ", detail.c_str());+ g_ui->showReport(url, heading, detail);}// Dead zone, trigger vibration and confirm button from g_settings.@@ -179,7 +182,9 @@ int main(int argc, char** argv) {// Did the last session go down? (A crash leaves a marker; being closed// from the system's menu doesn't.) Offered as a report once signed in.g_lastCrash = crash::takePrevious(crashMarkerPath());- if (g_lastCrash.found) XC_LOGW("the last session went down: %s (%s)", g_lastCrash.kind.c_str(), g_lastCrash.stage.c_str());+ if (g_lastCrash.found)+ XC_LOGW("the last session went down: %s (%s)%s%s", g_lastCrash.kind.c_str(), g_lastCrash.stage.c_str(),+ g_lastCrash.crash.empty() ? "" : " — ", g_lastCrash.crash.c_str());crash::install(crashMarkerPath());loadAutoplay();// An update cut short: the old files went back, and the old eboot.bin@@ -336,10 +341,10 @@ int main(int argc, char** argv) {size_t i = static_cast<size_t>(sc);if (sc != ui::Screen::Streaming && sc != ui::Screen::Launching && i < std::size(kNames)) crash::setStage(kNames[i]);// After a crash: its report, once the app is up again.- if (g_lastCrash.found && (sc == ui::Screen::Home || sc == ui::Screen::Error)) {+ if (g_lastCrash.found && !g_autoplay.crashTest && (sc == ui::Screen::Home || sc == ui::Screen::Error)) {g_lastCrash.found = false;openReport("Closed unexpectedly: " + g_lastCrash.kind + " while " + g_lastCrash.stage, true,- ui::tr(ui::Str::CrashedLastTime));+ ui::tr(ui::Str::CrashedLastTime), g_lastCrash.crash);}}// A Microsoft service refused for the console's clock: said once, evendiff --git a/src/app/report.cpp b/src/app/report.cppindex a3955be..a93bc42 100644--- a/src/app/report.cpp+++ b/src/app/report.cpp@@ -118,7 +118,7 @@ std::string logExcerpt(const std::string& logText, bool previousSession, size_tstd::set<size_t> keep;for (size_t i = 0; i < lines.size(); ++i)if (i == 0 || lines[i].find("[E]") != std::string::npos || lines[i].find("[W]") != std::string::npos ||- lines[i].find("session summary:") != std::string::npos ||+ lines[i].find("session summary:") != std::string::npos || lines[i].find("crash:") != std::string::npos ||i + lastLines >= lines.size())keep.insert(i);std::string out;@@ -132,7 +132,16 @@ std::string logExcerpt(const std::string& logText, bool previousSession, size_t}std::string issueUrl(const Info& info, size_t maxLength) {- std::string head = std::string(kForm) + "&title=" + encode(info.title) + "&what=" + encode(info.what) ++ std::string what = info.what;+ if (!info.crash.empty() && what.find(info.crash) == std::string::npos) {+ if (!what.empty()) what += "\n";+ what += info.crash;+ }+ if ((!info.crash.empty() || what.find("crash:") != std::string::npos) && !info.release.empty() &&+ what.find(info.release) == std::string::npos) {+ what += " (v" + info.release + ")";+ }+ std::string head = std::string(kForm) + "&title=" + encode(info.title) + "&what=" + encode(what) +"&release=" + encode(info.release) + "&firmware=" + encode(info.firmware) + "&log=";// The log's end matters most: whole lines are dropped from its start// until the link fits.diff --git a/src/app/report.h b/src/app/report.hindex 90e52e3..9ec8985 100644--- a/src/app/report.h+++ b/src/app/report.h@@ -18,6 +18,7 @@ struct Info {std::string release; // app versionstd::string firmware; // PS5 system software, when knownstd::string log; // logExcerpt()'s+ std::string crash; // crash: SIGSEGV pc=eboot+0x... (from the marker)};// The bug form's link, at most `maxLength` characters: the log is cut fromdiff --git a/src/ui/app_ui.cpp b/src/ui/app_ui.cppindex be608ae..a2a7441 100644--- a/src/ui/app_ui.cpp+++ b/src/ui/app_ui.cpp@@ -297,11 +297,12 @@ std::vector<std::string> AppUi::consoleNames() const {return out;}-void AppUi::showReport(const std::string& url, const std::string& heading) {+void AppUi::showReport(const std::string& url, const std::string& heading, const std::string& detail) {std::lock_guard<std::mutex> lock(mutex_);reportOpen_ = true;reportUrl_ = url;reportHeading_ = heading;+ reportDetail_ = detail;dirty_ = true;}@@ -3497,6 +3498,13 @@ void AppUi::drawReport(Canvas& c) {}y += 20;}+ if (!reportDetail_.empty()) {+ y += 8;+ for (const auto& line : fonts_.regular.wrap(reportDetail_, 22, textW, 3)) {+ fonts_.regular.draw(c, line, panel.x + 56, y, 22, kWhite);+ y += 32;+ }+ }c.fillRect({0, kH - 80, kW, 80}, kBg);drawHints(c, {{kIconCircle, tr(Str::Back)}});}diff --git a/src/ui/app_ui.h b/src/ui/app_ui.hindex 57a067f..0f404e6 100644--- a/src/ui/app_ui.h+++ b/src/ui/app_ui.h@@ -187,7 +187,7 @@ public:std::vector<std::string> consoleNames() const; // the same: the user's names for their consoles// "Report a problem": a QR code of `url` (the GitHub bug form, filled// in) over whatever is on screen, with `heading`; Circle closes it.- void showReport(const std::string& url, const std::string& heading);+ void showReport(const std::string& url, const std::string& heading, const std::string& detail = {});bool reportOpen() const;// Replaces the rows, keeping the focus on the same game when possible.void setRows(std::vector<GameRow> rows);@@ -493,7 +493,7 @@ private:int countryIndex_ = 0; // 0 off, then kLoginCountriesbool settingsFromError_ = false; // Circle goes back to the errorstd::string settingsCountry_; // the sign-in country when Settings opened- std::string reportUrl_, reportHeading_;+ std::string reportUrl_, reportHeading_, reportDetail_;bool updatePrompt_ = false; // the pop-up is up (on the home screen)int promptFocus_ = 0; // 0 Update now, 1 Not nowstd::string updatingTo_, updateStatus_;diff --git a/tests/test_main.cpp b/tests/test_main.cppindex 03f1653..5f10839 100644--- a/tests/test_main.cpp+++ b/tests/test_main.cpp@@ -571,6 +571,7 @@ static void testReport() {CHECK(s.find("example.com") == std::string::npos && s.find("<email>") != std::string::npos);CHECK(s.find("0123456789abcdef0123") == std::string::npos && s.find("<id>") != std::string::npos);CHECK(sanitize("v0.9.5 at 1080p, 60 fps, 9 ms", {}) == "v0.9.5 at 1080p, 60 fps, 9 ms"); // nothing private+ CHECK(sanitize("crash: SIGSEGV pc=eboot+0x1a2b3c addr=0x0", {}) == "crash: SIGSEGV pc=eboot+0x1a2b3c addr=0x0");// The excerpt: the session wanted, its warnings / errors and last lines.std::string log = "10:00 [I] === PSBox Cloud Gaming starting ===\n10:00 [E] old error\n"@@ -583,24 +584,32 @@ static void testReport() {CHECK(before.find("old error") != std::string::npos && before.find("line") == std::string::npos);CHECK(logExcerpt("no sessions\n", true).empty());- // The link fits the QR code; the log keeps its end.- Info info{"Error: certificates", "TLS setup failed", "0.9.6", "13.00", ""};+ // The link fits the QR code; the log keeps its end, and a crash report+ // keeps its offset and app version in the issue body.+ Info info{"Error: certificates", "TLS setup failed", "0.9.6", "13.00", "", "crash: SIGSEGV pc=eboot+0x1a2b3c addr=0x0"};for (int i = 0; i < 200; ++i) info.log += "12:00 [I] a long line of the log number " + std::to_string(i) + "\n";std::string url = issueUrl(info, 1800);CHECK(url.size() <= 1800 && url.find("template=bug_report.yml") != std::string::npos);CHECK(url.find("number+199") != std::string::npos && url.find("number+0%0A") == std::string::npos);CHECK(url.find("release=0.9.6") != std::string::npos && url.find("title=Error:+certificates") != std::string::npos);+ CHECK(url.find("pc%3Deboot%2B0x1a2b3c") != std::string::npos && url.find("(v0.9.6)") != std::string::npos);+}++[[gnu::noinline]] static void triggerNullWriteCrash() {+ volatile int* p = nullptr;+ asm volatile("" : "+r"(p));+ *p = 1;}static void testCrashGuard() {- // A crash in a child process leaves the marker with its stage.+ // A crash in a child process leaves the marker with its stage and faulting PC offset.std::string marker = "/tmp/xcloud-tests-crash.marker";std::remove(marker.c_str());pid_t pid = fork();if (pid == 0) {xc::app::crash::install(marker);xc::app::crash::setStage("streaming TEST");- std::raise(SIGSEGV);+ triggerNullWriteCrash();_exit(0);}int status = 0;@@ -608,7 +617,26 @@ static void testCrashGuard() {CHECK(WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV); // still dies of itauto prev = xc::app::crash::takePrevious(marker);CHECK(prev.found && prev.kind == "signal 11 (SIGSEGV)" && prev.stage == "streaming TEST");+ CHECK(prev.crash.rfind("crash: SIGSEGV pc=eboot+0x", 0) == 0);+ CHECK(prev.crash.find("addr=0x0") != std::string::npos);+ // The offset points inside triggerNullWriteCrash().+ unsigned long long pcOff = std::strtoull(prev.crash.c_str() + sizeof("crash: SIGSEGV pc=eboot+0x") - 1, nullptr, 16);+ CHECK(pcOff > 0);CHECK(!xc::app::crash::takePrevious(marker).found); // taken once++ // A signal raised inside a system library (std::raise) records that library's name and offset.+ pid = fork();+ if (pid == 0) {+ xc::app::crash::install(marker);+ xc::app::crash::setStage("home");+ std::raise(SIGABRT);+ _exit(0);+ }+ waitpid(pid, &status, 0);+ CHECK(WIFSIGNALED(status) && WTERMSIG(status) == SIGABRT);+ prev = xc::app::crash::takePrevious(marker);+ CHECK(prev.found && prev.kind == "signal 6 (SIGABRT)" && prev.stage == "home");+ CHECK(prev.crash.rfind("crash: SIGABRT pc=", 0) == 0 && prev.crash.find("+0x") != std::string::npos);}static void testBuiltinCa() {diff --git a/tools/ps5/link.sh b/tools/ps5/link.shindex f3d40fa..ab3a7df 100755--- a/tools/ps5/link.sh+++ b/tools/ps5/link.sh@@ -75,6 +75,13 @@ libs=("$build/libxcloud_ui.a""${stubs[@]}" "${radv_link_inputs[@]}" \--as-needed "$sdk"/target/lib/*.so+# Keep the ELF with symbols and line tables (by version) so crash offsets+# (pc=eboot+0x...) can be translated back to function and line.+ver=${XC_VERSION:-v$(sed -n 's/^project(xcloud_ps5 VERSION \([0-9.]*\).*/\1/p' "$root/CMakeLists.txt")}+[[ $ver == v* ]] || ver="v$ver"+mkdir -p "$root/symbols/$ver"+cp -f "$work/llvm-pie.elf" "$root/symbols/$ver/eboot.elf"+stub_args=()for s in "${stubs[@]}"; do stub_args+=(--stub "$s"); done"$tool" link --in "$work/llvm-pie.elf" --out "$work/eboot.elf" \@@ -82,4 +89,4 @@ for s in "${stubs[@]}"; do stub_args+=(--stub "$s"); done--module-sdk 0x02000009 --companion-sdk 0x08050001 --file-name eboot.elf"$tool" self --sign --in "$work/eboot.elf" --out "$build/eboot.bin" --magic 0x1D3D154F"$tool" self --inspect --file "$build/eboot.bin" > /dev/null-echo "eboot.bin built: $build/eboot.bin ($(stat -c %s "$build/eboot.bin") bytes)"+echo "eboot.bin built: $build/eboot.bin ($(stat -c %s "$build/eboot.bin") bytes, symbols at symbols/$ver/eboot.elf)"diff --git a/tools/release.sh b/tools/release.shindex 9120340..0a11bfc 100755--- a/tools/release.sh+++ b/tools/release.sh@@ -73,9 +73,10 @@ ok "signing key matches the app's"echo "== build"buildlog=$(mktemp)cmake --build build-ps5 -j"$(nproc)" >"$buildlog" 2>&1 || { cat "$buildlog"; fail "the PS5 build failed"; }-tools/ps5/link.sh build-ps5 >"$buildlog" 2>&1 || { cat "$buildlog"; fail "linking eboot.bin failed"; }+XC_VERSION="$tag" tools/ps5/link.sh build-ps5 >"$buildlog" 2>&1 || { cat "$buildlog"; fail "linking eboot.bin failed"; }rm -f "$buildlog"-ok "PS5 build linked"+[[ -s "$root/symbols/$tag/eboot.elf" ]] || fail "symbols/$tag/eboot.elf was not saved"+ok "PS5 build linked (symbols at symbols/$tag/eboot.elf)"rm -rf "$out"mkdir -p "$out"env -u XC_INCLUDE_ACCOUNT XC_VERSION="$tag" tools/ps5/package.sh build-ps5 "$out" >/dev/null@@ -92,7 +93,7 @@ ok "signed: $out/PPSA99810.zip.sig"echo "== checks in the package"zip=$out/PPSA99810.zip-if unzip -Z1 "$zip" | grep -nE "$private"; then fail "a private file in the zip"; fi+if unzip -Z1 "$zip" | grep -nE "$private|\.elf$"; then fail "a private or symbol file in the zip"; fiif zipinfo "$zip" | grep -E '^[-d]' | grep -v '^.rwxrwxrwx'; then fail "files in the zip without mode 0777"; fiok "every entry mode 0777"ok "no private file ($(unzip -Z1 "$zip" | grep -vc '/$') files)"diff --git a/tools/symbolize.sh b/tools/symbolize.shnew file mode 100755index 0000000..9d2af09--- /dev/null+++ b/tools/symbolize.sh@@ -0,0 +1,73 @@+#!/usr/bin/env bash+# SPDX-License-Identifier: GPL-3.0-or-later+# Copyright (C) 2026 RafaelNGP+# Translates crash report offsets (pc=eboot+0x...) into function and file:line.+#+# tools/symbolize.sh [vX.Y.Z] <offset-or-crash-line...>+#+# Examples:+# tools/symbolize.sh v0.9.8 0x1a2b3c+# tools/symbolize.sh v0.9.8 "crash: SIGSEGV pc=eboot+0x1a2b3c addr=0x0"+# tools/symbolize.sh 0x1a2b3c+set -euo pipefail++root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)+vk=${PS5_VULKAN:-$(cd "$root/../PS5_Vulkan" 2>/dev/null && pwd || true)}+sdk=${PS5_SDK:-${vk:+$vk/.deps/native/ps5-payload-sdk}}++addr2line=""+if [[ -n $sdk && -x "$sdk/bin/prospero-llvm-config" ]]; then+ bindir=$("$sdk/bin/prospero-llvm-config" --bindir 2>/dev/null || true)+ [[ -n $bindir && -x "$bindir/llvm-addr2line" ]] && addr2line="$bindir/llvm-addr2line"+fi+[[ -n $addr2line ]] || addr2line=$(command -v llvm-addr2line || command -v addr2line || true)+[[ -n $addr2line ]] || { echo "symbolize: llvm-addr2line not found" >&2; exit 1; }++if (( $# == 0 )); then+ echo "usage: tools/symbolize.sh [vX.Y.Z] <offset-or-crash-line...>" >&2+ exit 1+fi++ver=""+if [[ $1 =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ ver=$1+ shift+fi+if [[ -z $ver ]]; then+ # Look for (vX.Y.Z) in the arguments, or fall back to CMakeLists.txt.+ for arg in "$@"; do+ if [[ $arg =~ \(v([0-9]+\.[0-9]+\.[0-9]+)\) ]]; then+ ver="v${BASH_REMATCH[1]}"+ break+ fi+ done+ [[ -n $ver ]] || ver="v$(sed -n 's/^project(xcloud_ps5 VERSION \([0-9.]*\).*/\1/p' "$root/CMakeLists.txt")"+fi+[[ $ver == v* ]] || ver="v$ver"++elf="$root/symbols/$ver/eboot.elf"+if [[ ! -f $elf && -f "$root/build-ps5/ps5-link/llvm-pie.elf" ]]; then+ elf="$root/build-ps5/ps5-link/llvm-pie.elf"+fi+[[ -f $elf ]] || { echo "symbolize: symbol file not found at $root/symbols/$ver/eboot.elf" >&2; exit 1; }++offsets=()+for arg in "$@"; do+ if [[ $arg == *eboot+0x* ]]; then+ while [[ $arg =~ eboot\+(0x[0-9a-fA-F]+) ]]; do+ offsets+=("${BASH_REMATCH[1]}")+ arg=${arg#*"eboot+${BASH_REMATCH[1]}"}+ done+ elif [[ $arg =~ ^(pc=)?(eboot\+)?(0x[0-9a-fA-F]+|[0-9a-fA-F]+)$ ]]; then+ off=${BASH_REMATCH[3]}+ [[ $off == 0x* ]] || off="0x$off"+ offsets+=("$off")+ fi+done++if (( ${#offsets[@]} == 0 )); then+ echo "symbolize: no eboot offset found in arguments" >&2+ exit 1+fi++exec "$addr2line" -f -C -e "$elf" "${offsets[@]}"