From 4768f790a5502378b884cf6e3f7993e14e94b0cd Mon Sep 17 00:00:00 2001 From: Sinan KARAKAYA Date: Tue, 18 Aug 2026 11:22:05 +0200 Subject: [PATCH] Make the DECI2 text log limit configurable logDeci2Text stops after 256 lines and then silently drops everything else. That is a sensible default against a game that spams kputs, but it makes the runtime unusable as the candidate side of a boot-trace diff: real captures run to many thousands of lines, and a silent truncation partway through looks exactly like the guest stopping. Adds PS2X_DECI2_LOG_LIMIT, with 0 meaning unlimited. Unset or unparseable keeps the existing 256. (cherry picked from commit 50dc8681cedc62852604b29a04134c4c3126aec1) --- ps2xRuntime/src/lib/Kernel/Syscalls/Deci2.cpp | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/ps2xRuntime/src/lib/Kernel/Syscalls/Deci2.cpp b/ps2xRuntime/src/lib/Kernel/Syscalls/Deci2.cpp index 039da2fb0..347242881 100644 --- a/ps2xRuntime/src/lib/Kernel/Syscalls/Deci2.cpp +++ b/ps2xRuntime/src/lib/Kernel/Syscalls/Deci2.cpp @@ -2,6 +2,8 @@ #include "Common.h" #include "ps2_runtime.h" +#include + namespace { struct Deci2Session @@ -62,11 +64,37 @@ namespace return text; } + // Line cap for DECI2 text output. PS2X_DECI2_LOG_LIMIT overrides it; + // 0 means unlimited, for diffing a full boot trace against a reference. + static uint32_t deci2TextLogLimit() + { + static const uint32_t limit = []() -> uint32_t + { + constexpr uint32_t kDefaultMaxDeci2TextLogs = 256u; + const char *env = std::getenv("PS2X_DECI2_LOG_LIMIT"); + if (!env || *env == '\0') + { + return kDefaultMaxDeci2TextLogs; + } + + char *parseEnd = nullptr; + const unsigned long parsed = std::strtoul(env, &parseEnd, 10); + if (parseEnd == env || *parseEnd != '\0' || parsed > 0xFFFFFFFFul) + { + return kDefaultMaxDeci2TextLogs; + } + + return static_cast(parsed); + }(); + + return limit; + } + static void logDeci2Text(const char *prefix, const std::string &text) { - constexpr uint32_t kMaxDeci2TextLogs = 256u; + const uint32_t maxDeci2TextLogs = deci2TextLogLimit(); const uint32_t logIndex = g_deci2LogCount.fetch_add(1u, std::memory_order_relaxed); - if (logIndex >= kMaxDeci2TextLogs) + if (maxDeci2TextLogs != 0u && logIndex >= maxDeci2TextLogs) { return; }