OpenTTD Source 20260208-master-g43af8e94d0
CrashLogOSX Class Reference

OSX implementation for the crash logger. More...

Inheritance diagram for CrashLogOSX:
CrashLog

Public Member Functions

 CrashLogOSX (int signum)
 A crash log is always generated by signal.
void DisplayCrashDialog () const
 Show a dialog with the crash information.
Public Member Functions inherited from CrashLog
virtual ~CrashLog ()=default
 Stub destructor to silence some compilers.
void FillCrashLog ()
 Fill the crash log buffer with all data of a crash log.
void PrintCrashLog () const
bool WriteCrashLog ()
 Write the crash log to a file.
virtual bool WriteCrashDump ()
 Write the (crash) dump to a file.
bool WriteSavegame ()
 Write the (crash) savegame to a file.
bool WriteScreenshot ()
 Write the (crash) screenshot to a file.
void SendSurvey () const
 Send the survey result, noting it was a crash.
void MakeCrashLog ()
 Makes the crash log, writes it to a file and then subsequently tries to make a crash dump and crash savegame.

Data Fields

jmp_buf internal_fault_jmp_buf
 Buffer to track the long jump set setup.
bool try_execute_active = false
 Whether we are in a TryExecute block.
Data Fields inherited from CrashLog
nlohmann::json survey
std::string crashlog_filename
std::string crashdump_filename
std::string savegame_filename
std::string screenshot_filename

Static Public Attributes

static CrashLogOSXcurrent = nullptr
 Points to the current crash log.

Private Member Functions

void SurveyCrash (nlohmann::json &survey) const override
 Convert system crash reason to JSON.
void SurveyStacktrace (nlohmann::json &survey) const override
 Convert stacktrace to JSON.
bool TryExecute (std::string_view section_name, std::function< bool()> &&func) override
 Execute the func() and return its value.

Private Attributes

int signum
 Signal that has been thrown.

Additional Inherited Members

Static Public Member Functions inherited from CrashLog
static void InitialiseCrashLog ()
 Initialiser for crash logs; do the appropriate things so crashes are handled by our crash handler instead of returning straight to the OS.
static void InitThread ()
 Prepare crash log handler for a newly started thread.
static void SetErrorMessage (const std::string &message)
 Sets a message for the error message handler.
static void AfterCrashLogCleanup ()
 Try to close the sound/video stuff so it doesn't keep lingering around incorrect video states or so, e.g.
Protected Member Functions inherited from CrashLog
std::string CreateFileName (std::string_view ext, bool with_dir=true) const
 Create a timestamped filename.

Detailed Description

OSX implementation for the crash logger.

Definition at line 48 of file crashlog_osx.cpp.

Constructor & Destructor Documentation

◆ CrashLogOSX()

CrashLogOSX::CrashLogOSX ( int signum)
inline

A crash log is always generated by signal.

Parameters
signumthe signal that was caused by the crash.

Definition at line 118 of file crashlog_osx.cpp.

References signum.

Member Function Documentation

◆ DisplayCrashDialog()

void CrashLogOSX::DisplayCrashDialog ( ) const
inline

Show a dialog with the crash information.

Definition at line 121 of file crashlog_osx.cpp.

References CrashLog::message, and ShowMacDialog().

Referenced by HandleCrash().

◆ SurveyCrash()

void CrashLogOSX::SurveyCrash ( nlohmann::json & survey) const
inlineoverrideprivatevirtual

Convert system crash reason to JSON.

Parameters
surveyThe JSON object.

Implements CrashLog.

Definition at line 52 of file crashlog_osx.cpp.

References signum.

◆ SurveyStacktrace()

void CrashLogOSX::SurveyStacktrace ( nlohmann::json & survey) const
inlineoverrideprivatevirtual

Convert stacktrace to JSON.

Parameters
surveyThe JSON object.

Implements CrashLog.

Definition at line 58 of file crashlog_osx.cpp.

References lengthof.

◆ TryExecute()

bool CrashLogOSX::TryExecute ( std::string_view section_name,
std::function< bool()> && func )
inlineoverrideprivatevirtual

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.

Parameters
section_nameThe name of the section to be executed. Printed when a crash happens.
funcThe function to call.
Returns
true iff the function returned true.

Implements CrashLog.

Definition at line 88 of file crashlog_osx.cpp.

References _signals_to_handle, internal_fault_jmp_buf, signum, and try_execute_active.

Field Documentation

◆ current

CrashLogOSX * CrashLogOSX::current = nullptr
static

Points to the current crash log.

Definition at line 143 of file crashlog_osx.cpp.

Referenced by HandleCrash(), and HandleInternalCrash().

◆ internal_fault_jmp_buf

jmp_buf CrashLogOSX::internal_fault_jmp_buf

Buffer to track the long jump set setup.

Definition at line 137 of file crashlog_osx.cpp.

Referenced by TryExecute().

◆ signum

int CrashLogOSX::signum
private

Signal that has been thrown.

Definition at line 50 of file crashlog_osx.cpp.

Referenced by CrashLogOSX(), SurveyCrash(), and TryExecute().

◆ try_execute_active

bool CrashLogOSX::try_execute_active = false

Whether we are in a TryExecute block.

Definition at line 140 of file crashlog_osx.cpp.

Referenced by TryExecute().


The documentation for this class was generated from the following file: