Crash log: Write out crash log incrementally on Windows, MacOS

This commit is contained in:
Jonathan G Rennison
2023-06-12 19:31:40 +01:00
parent 76304c1f76
commit b26a3fa41e
4 changed files with 49 additions and 19 deletions

View File

@@ -17,6 +17,7 @@
#include "../../debug.h"
#include "../../video/video_driver.hpp"
#include "../../scope.h"
#include "../../walltime_func.h"
#include "macos.h"
#include <errno.h>
@@ -415,27 +416,35 @@ public:
bool ret = true;
printf("Crash encountered, generating crash log...\n");
this->FillCrashLog(buffer, last);
printf("%s\n", buffer);
printf("Crash log generated.\n\n");
char *name_buffer_date = this->name_buffer + seprintf(this->name_buffer, lastof(this->name_buffer), "crash-");
UTCTime::Format(name_buffer_date, lastof(this->name_buffer), "%Y%m%dT%H%M%SZ");
printf("Writing crash log to disk...\n");
if (!this->WriteCrashLog(buffer, filename_log, lastof(filename_log))) {
filename_log[0] = '\0';
bool bret = this->WriteCrashLog("", this->filename_log, lastof(this->filename_log), this->name_buffer, &(this->crash_file));
if (bret) {
printf("Crash log written to %s. Please add this file to any bug reports.\n\n", this->filename_log);
} else {
printf("Writing crash log failed. Please attach the output above to any bug reports.\n\n");
ret = false;
}
this->crash_buffer_write = buffer;
this->FillCrashLog(buffer, last);
this->CloseCrashLogFile();
printf("Crash log generated.\n\n");
printf("Writing crash savegame...\n");
_savegame_DBGL_data = buffer;
_save_DBGC_data = true;
if (!this->WriteSavegame(filename_save, lastof(filename_save))) {
if (!this->WriteSavegame(filename_save, lastof(filename_save), this->name_buffer)) {
filename_save[0] = '\0';
ret = false;
}
printf("Writing crash screenshot...\n");
SetScreenshotAuxiliaryText("Crash Log", buffer);
if (!this->WriteScreenshot(filename_screenshot, lastof(filename_screenshot))) {
if (!this->WriteScreenshot(filename_screenshot, lastof(filename_screenshot), this->name_buffer)) {
filename_screenshot[0] = '\0';
ret = false;
}