From e149e09e08547c88cb26fdb21dc86d2655016184 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Sun, 11 Jan 2026 23:11:42 -0600 Subject: [PATCH] Add GFX Stack to crash handler ext (#6130) --- soh/soh/CrashHandlerExt.cpp | 43 ++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/soh/soh/CrashHandlerExt.cpp b/soh/soh/CrashHandlerExt.cpp index ded4bfc9e..68e589359 100644 --- a/soh/soh/CrashHandlerExt.cpp +++ b/soh/soh/CrashHandlerExt.cpp @@ -5,6 +5,8 @@ #include #include #include +#include "soh/ActorDB.h" +#include #define WRITE_VAR_LINE(buff, len, varName, varValue) \ append_str(buff, len, varName); \ @@ -40,7 +42,6 @@ static void append_line(char* buf, size_t* len, const char* str) { static void CrashHandler_WriteActorData(char* buffer, size_t* pos) { char intCharBuffer[16]; - append_line(buffer, pos, "Actor Id Params"); for (unsigned int i = 0; i < ACTORCAT_MAX; i++) { ActorListEntry* entry = &gPlayState->actorCtx.actorLists[i]; @@ -49,16 +50,15 @@ static void CrashHandler_WriteActorData(char* buffer, size_t* pos) { if (entry->length == 0) { continue; } - WRITE_VAR_LINE(buffer, pos, "Actor Cat: ", sCatToStrArray[i]); + WRITE_VAR_LINE(buffer, pos, " Category: ", sCatToStrArray[i]); cur = entry->head; while (cur != nullptr) { - // Actor ID - snprintf(intCharBuffer, sizeof(intCharBuffer), "0x%03X ", cur->id); - append_str(buffer, pos, intCharBuffer); - - // Actor Params - snprintf(intCharBuffer, sizeof(intCharBuffer), "0x%04X", cur->params); - append_line(buffer, pos, intCharBuffer); + std::string actorLine = " "; + actorLine += ActorDB::Instance->RetrieveEntry(cur->id).entry.valid + ? ActorDB::Instance->RetrieveEntry(cur->id).entry.desc + : "???"; + actorLine += " (" + std::to_string(cur->params) + ")"; + append_line(buffer, pos, actorLine.c_str()); cur = cur->next; } @@ -68,18 +68,27 @@ static void CrashHandler_WriteActorData(char* buffer, size_t* pos) { extern "C" void CrashHandler_PrintSohData(char* buffer, size_t* pos) { char intCharBuffer[16]; append_line(buffer, pos, "Build Information:"); - WRITE_VAR_LINE(buffer, pos, "Game Version: ", (const char*)gBuildVersion); - WRITE_VAR_LINE(buffer, pos, "Git Branch: ", (const char*)gGitBranch); - WRITE_VAR_LINE(buffer, pos, "Git Commit: ", (const char*)gGitCommitHash); - WRITE_VAR_LINE(buffer, pos, "Build Date: ", (const char*)gBuildDate); + WRITE_VAR_LINE(buffer, pos, " Game Version: ", (const char*)gBuildVersion); + WRITE_VAR_LINE(buffer, pos, " Git Branch: ", (const char*)gGitBranch); + WRITE_VAR_LINE(buffer, pos, " Git Commit: ", (const char*)gGitCommitHash); + WRITE_VAR_LINE(buffer, pos, " Build Date: ", (const char*)gBuildDate); if (gPlayState != nullptr) { - append_line(buffer, pos, "Actors:"); - CrashHandler_WriteActorData(buffer, pos); - WRITE_VAR_LINE(buffer, pos, "Scene: ", sSceneIdToStrArray[gPlayState->sceneNum]); snprintf(intCharBuffer, sizeof(intCharBuffer), "%i", gPlayState->roomCtx.curRoom.num); WRITE_VAR_LINE(buffer, pos, "Room: ", intCharBuffer); + + append_line(buffer, pos, "Actors:"); + CrashHandler_WriteActorData(buffer, pos); + + append_line(buffer, pos, "GFX Stack:"); + for (auto& disp : Fast::g_exec_stack.disp_stack) { + std::string line = " "; + line += disp.file; + line += ":"; + line += std::to_string(disp.line); + append_line(buffer, pos, line.c_str()); + } } -} \ No newline at end of file +}