Skip to content

Commit

Permalink
Merge pull request #16844 from hrydgard/crc-on-crash-display
Browse files Browse the repository at this point in the history
Display CRC on crash screen. Thanks sum2012 for the idea.
  • Loading branch information
unknownbrackets committed Jan 25, 2023
2 parents 91cca1c + e03db2e commit dc81712
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
3 changes: 1 addition & 2 deletions Core/Reporting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ namespace Reporting
}

if (crcPending) {
// Already in process.
INFO_LOG(SYSTEM, "CRC already pending");
// Already in process. This is OK - on the crash screen we call this in a polling fashion.
return;
}

Expand Down
26 changes: 20 additions & 6 deletions UI/EmuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ using namespace std::placeholders;
#include "UI/DiscordIntegration.h"
#include "UI/ChatScreen.h"

#include "Core/Reporting.h"

#if PPSSPP_PLATFORM(WINDOWS) && !PPSSPP_PLATFORM(UWP)
#include "Windows/MainWindow.h"
#endif
Expand Down Expand Up @@ -1158,7 +1160,7 @@ static const char *CPUCoreAsString(int core) {
}
}

static void DrawCrashDump(UIContext *ctx) {
static void DrawCrashDump(UIContext *ctx, const Path &gamePath) {
const ExceptionInfo &info = Core_GetExceptionInfo();

auto sy = GetI18NCategory("System");
Expand All @@ -1170,13 +1172,23 @@ static void DrawCrashDump(UIContext *ctx) {
ctx->Flush();
if (ctx->Draw()->GetFontAtlas()->getFont(ubuntu24))
ctx->BindFontTexture();
ctx->Draw()->SetFontScale(1.2f, 1.2f);
ctx->Draw()->SetFontScale(1.1f, 1.1f);
ctx->Draw()->DrawTextShadow(ubuntu24, sy->T("Game crashed"), x, y, 0xFFFFFFFF);

char statbuf[4096];
char versionString[256];
snprintf(versionString, sizeof(versionString), "%s", PPSSPP_GIT_VERSION);

char crcStr[16]{};
if (Reporting::HasCRC(gamePath)) {
u32 crc = Reporting::RetrieveCRC(gamePath);
snprintf(crcStr, sizeof(crcStr), "CRC: %08x\n", crc);
} else {
// Queue it for calculation, we want it!
// It's OK to call this repeatedly until we have it, which is natural here.
Reporting::QueueCRC(gamePath);
}

// TODO: Draw a lot more information. Full register set, and so on.

#ifdef _DEBUG
Expand All @@ -1196,23 +1208,24 @@ static void DrawCrashDump(UIContext *ctx) {

ctx->PushScissor(Bounds(x, y, columnWidth, height));


INFO_LOG(SYSTEM, "DrawCrashDump (%d %d %d %d)", x, y, columnWidth, height);

snprintf(statbuf, sizeof(statbuf), R"(%s
%s (%s)
%s (%s)
%s v%d (%s)
%s
)",
ExceptionTypeAsString(info.type),
g_paramSFO.GetDiscID().c_str(), g_paramSFO.GetValueString("TITLE").c_str(),
versionString, build,
sysName.c_str(), sysVersion, GetCompilerABI()
sysName.c_str(), sysVersion, GetCompilerABI(),
crcStr
);

ctx->Draw()->SetFontScale(.7f, .7f);
ctx->Draw()->DrawTextShadow(ubuntu24, statbuf, x, y, 0xFFFFFFFF);
y += 140;
y += 160;

if (info.type == ExceptionType::MEMORY) {
snprintf(statbuf, sizeof(statbuf), R"(
Expand Down Expand Up @@ -1272,6 +1285,7 @@ Invalid / Unknown (%d)

ctx->Draw()->DrawTextShadow(ubuntu24, statbuf, x, y, 0xFFFFFFFF);
ctx->Flush();
ctx->Draw()->SetFontScale(1.0f, 1.0f);
ctx->RebindTexture();
}

Expand Down Expand Up @@ -1565,7 +1579,7 @@ void EmuScreen::renderUI() {
if (coreState == CORE_RUNTIME_ERROR || coreState == CORE_STEPPING) {
const ExceptionInfo &info = Core_GetExceptionInfo();
if (info.type != ExceptionType::NONE) {
DrawCrashDump(ctx);
DrawCrashDump(ctx, gamePath_);
} else {
// We're somehow in ERROR or STEPPING without a crash dump. This case is what lead
// to the bare "Resume" and "Reset" buttons without a crash dump before, in cases
Expand Down

0 comments on commit dc81712

Please sign in to comment.