Add GFX Stack to crash handler ext (#6130)

This commit is contained in:
Garrett Cox
2026-01-11 23:11:42 -06:00
committed by GitHub
parent 45fb38e309
commit e149e09e08

View File

@@ -5,6 +5,8 @@
#include <string.h>
#include <stdio.h>
#include <array>
#include "soh/ActorDB.h"
#include <fast/interpreter.h>
#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());
}
}
}
}