Change: recover when possible from crashes during a crash (#11238)

This commit is contained in:
Patric Stout
2023-08-27 21:54:05 +02:00
committed by GitHub
parent 99e4a14cdf
commit b00e483b0f
5 changed files with 330 additions and 60 deletions

View File

@@ -52,6 +52,17 @@ protected:
std::string CreateFileName(const char *ext, bool with_dir = true) const;
/**
* Execute the func() and return its value. If any exception / signal / crash happens,
* catch it and return false. This function should, in theory, never not return, even
* in the worst conditions.
*
* @param section_name The name of the section to be executed. Printed when a crash happens.
* @param func The function to call.
* @return true iff the function returned true.
*/
virtual bool TryExecute(std::string_view section_name, std::function<bool()> &&func) = 0;
public:
/** Stub destructor to silence some compilers. */
virtual ~CrashLog() = default;
@@ -65,7 +76,7 @@ public:
void FillCrashLog(std::back_insert_iterator<std::string> &output_iterator) const;
bool WriteCrashLog();
virtual int WriteCrashDump();
virtual bool WriteCrashDump();
bool WriteSavegame();
bool WriteScreenshot();