Files
@ r27813:6b3a5970aa1b
Branch filter:
Location: cpp/openttd-patchpack/source/src/crashlog.h - annotation
r27813:6b3a5970aa1b
3.6 KiB
text/x-c
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.
Normally only the Windows platform could create a crash.dmp, making
analysing crash-reports from MacOS / Linux rather tricky.
r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r27160:192bc991c2e6 r26818:9df12eaf020a r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r27432:005dbba2ae93 r12947:776ad783fe07 r27432:005dbba2ae93 r12947:776ad783fe07 r12947:776ad783fe07 r14293:a7858a5997d3 r27432:005dbba2ae93 r14293:a7858a5997d3 r27432:005dbba2ae93 r14293:a7858a5997d3 r14293:a7858a5997d3 r12947:776ad783fe07 r27432:005dbba2ae93 r26818:9df12eaf020a r12947:776ad783fe07 r27432:005dbba2ae93 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r27432:005dbba2ae93 r12947:776ad783fe07 r27432:005dbba2ae93 r12947:776ad783fe07 r12947:776ad783fe07 r19944:25a78576fb5e r12947:776ad783fe07 r27432:005dbba2ae93 r12947:776ad783fe07 r27432:005dbba2ae93 r12947:776ad783fe07 r12947:776ad783fe07 r27432:005dbba2ae93 r27432:005dbba2ae93 r27432:005dbba2ae93 r27432:005dbba2ae93 r27432:005dbba2ae93 r12947:776ad783fe07 r27433:f785ea80973e r26170:40e0ba47161b r12947:776ad783fe07 r12947:776ad783fe07 r27372:06d384d76bd2 r12947:776ad783fe07 r27433:f785ea80973e r27433:f785ea80973e r27433:f785ea80973e r27433:f785ea80973e r27433:f785ea80973e r27433:f785ea80973e r27432:005dbba2ae93 r27433:f785ea80973e r12947:776ad783fe07 r27433:f785ea80973e r27433:f785ea80973e r27433:f785ea80973e r13622:200502780bca r27402:8e5c6e9c8a2d r27402:8e5c6e9c8a2d r27433:f785ea80973e r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r25047:a8e131d1e25b r25047:a8e131d1e25b r25047:a8e131d1e25b r25047:a8e131d1e25b r25047:a8e131d1e25b r25047:a8e131d1e25b r27160:192bc991c2e6 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 r12947:776ad783fe07 | /*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file crashlog.h Functions to be called to log a crash */
#ifndef CRASHLOG_H
#define CRASHLOG_H
/**
* Helper class for creating crash logs.
*/
class CrashLog {
private:
/** Error message coming from #FatalError(format, ...). */
static std::string message;
protected:
/**
* Writes OS' version to the buffer.
* @param output_iterator Iterator to write the output to.
*/
virtual void LogOSVersion(std::back_insert_iterator<std::string> &output_iterator) const = 0;
/**
* Writes compiler (and its version, if available) to the buffer.
* @param output_iterator Iterator to write the output to.
*/
virtual void LogCompiler(std::back_insert_iterator<std::string> &output_iterator) const;
/**
* Writes actually encountered error to the buffer.
* @param output_iterator Iterator to write the output to.
* @param message Message passed to use for errors.
*/
virtual void LogError(std::back_insert_iterator<std::string> &output_iterator, const std::string_view message) const = 0;
/**
* Writes the stack trace to the buffer, if there is information about it
* available.
* @param output_iterator Iterator to write the output to.
*/
virtual void LogStacktrace(std::back_insert_iterator<std::string> &output_iterator) const = 0;
/**
* Writes the dynamically linked libraries/modules to the buffer, if there
* is information about it available.
* @param output_iterator Iterator to write the output to.
*/
virtual void LogModules(std::back_insert_iterator<std::string> &output_iterator) const;
void LogOpenTTDVersion(std::back_insert_iterator<std::string> &output_iterator) const;
void LogConfiguration(std::back_insert_iterator<std::string> &output_iterator) const;
void LogLibraries(std::back_insert_iterator<std::string> &output_iterator) const;
void LogGamelog(std::back_insert_iterator<std::string> &output_iterator) const;
void LogRecentNews(std::back_insert_iterator<std::string> &output_iterator) const;
std::string CreateFileName(const char *ext, bool with_dir = true) const;
public:
/** Stub destructor to silence some compilers. */
virtual ~CrashLog() = default;
std::string crashlog;
std::string crashlog_filename;
std::string crashdump_filename;
std::string savegame_filename;
std::string screenshot_filename;
void FillCrashLog(std::back_insert_iterator<std::string> &output_iterator) const;
bool WriteCrashLog();
virtual int WriteCrashDump();
bool WriteSavegame();
bool WriteScreenshot();
void SendSurvey() const;
bool MakeCrashLog();
/**
* Initialiser for crash logs; do the appropriate things so crashes are
* handled by our crash handler instead of returning straight to the OS.
* @note must be implemented by all implementers of CrashLog.
*/
static void InitialiseCrashLog();
/**
* Prepare crash log handler for a newly started thread.
* @note must be implemented by all implementers of CrashLog.
*/
static void InitThread();
static void SetErrorMessage(const std::string &message);
static void AfterCrashLogCleanup();
};
#endif /* CRASHLOG_H */
|