Add: use breakpad to create crash.dmp on MacOS / Linux too (#11202)

Normally only the Windows platform could create a crash.dmp, making
analysing crash-reports from MacOS / Linux rather tricky.
This commit is contained in:
Patric Stout
2023-08-20 17:16:08 +02:00
committed by GitHub
parent 8f6df242c4
commit f120d2beb8
13 changed files with 107 additions and 59 deletions

View File

@@ -9,6 +9,7 @@
#include "../../stdafx.h"
#include "../../crashlog.h"
#include "../../fileio_func.h"
#include "../../string_func.h"
#include "../../gamelog.h"
#include "../../saveload/saveload.h"
@@ -25,6 +26,10 @@
#include <unistd.h>
#endif
#ifdef WITH_UNOFFICIAL_BREAKPAD
# include <client/linux/handler/exception_handler.h>
#endif
#include "../../safeguards.h"
/**
@@ -84,6 +89,23 @@ class CrashLogUnix : public CrashLog {
#endif
fmt::format_to(output_iterator, "\n");
}
#ifdef WITH_UNOFFICIAL_BREAKPAD
static bool MinidumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void* context, bool succeeded)
{
CrashLogUnix *crashlog = reinterpret_cast<CrashLogUnix *>(context);
crashlog->crashdump_filename = crashlog->CreateFileName(".dmp");
std::rename(descriptor.path(), crashlog->crashdump_filename.c_str());
return succeeded;
}
int WriteCrashDump() override
{
return google_breakpad::ExceptionHandler::WriteMinidump(_personal_dir, MinidumpCallback, this) ? 1 : -1;
}
#endif
public:
/**
* A crash log is always generated by signal.