OpenTTD Source  20241121-master-g67a0fccfad
CrashLogWindows Class Reference

Windows implementation for the crash logger. More...

Inheritance diagram for CrashLogWindows:
CrashLog

Public Member Functions

bool TryExecute (std::string_view section_name, std::function< bool()> &&func) override
 Execute the func() and return its value. More...
 
 CrashLogWindows (EXCEPTION_POINTERS *ep=nullptr)
 A crash log is always generated when it's generated. More...
 
- 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. More...
 
virtual bool WriteCrashDump ()
 Write the (crash) dump to a file. More...
 
bool WriteSavegame ()
 Write the (crash) savegame to a file. More...
 
bool WriteScreenshot ()
 Write the (crash) screenshot to a file. More...
 
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. More...
 

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 CrashLogWindowscurrent = nullptr
 Points to the current crash log.
 

Private Member Functions

void SurveyCrash (nlohmann::json &survey) const override
 Convert system crash reason to JSON. More...
 
void SurveyStacktrace (nlohmann::json &survey) const override
 Convert stacktrace to JSON. More...
 

Private Attributes

EXCEPTION_POINTERS * ep
 Information about the encountered exception.
 

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. More...
 
static void InitThread ()
 Prepare crash log handler for a newly started thread. More...
 
static void SetErrorMessage (const std::string &message)
 Sets a message for the error message handler. More...
 
static void AfterCrashLogCleanup ()
 Try to close the sound/video stuff so it doesn't keep lingering around incorrect video states or so, e.g. More...
 
- Protected Member Functions inherited from CrashLog
std::string CreateFileName (const char *ext, bool with_dir=true) const
 Create a timestamped filename. More...
 

Detailed Description

Windows implementation for the crash logger.

Definition at line 84 of file crashlog_win.cpp.

Constructor & Destructor Documentation

◆ CrashLogWindows()

CrashLogWindows::CrashLogWindows ( EXCEPTION_POINTERS *  ep = nullptr)
inline

A crash log is always generated when it's generated.

Parameters
epthe data related to the exception.

Definition at line 156 of file crashlog_win.cpp.

Member Function Documentation

◆ SurveyCrash()

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

Convert system crash reason to JSON.

Parameters
surveyThe JSON object.

Implements CrashLog.

Definition at line 88 of file crashlog_win.cpp.

References ep, and exception_code_to_name.

◆ SurveyStacktrace()

void CrashLogWindows::SurveyStacktrace ( nlohmann::json &  survey) const
overrideprivatevirtual

Convert stacktrace to JSON.

Parameters
surveyThe JSON object.

Implements CrashLog.

Definition at line 294 of file crashlog_win.cpp.

◆ TryExecute()

bool CrashLogWindows::TryExecute ( std::string_view  section_name,
std::function< bool()> &&  func 
)
inlineoverridevirtual

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 134 of file crashlog_win.cpp.

References internal_fault_jmp_buf, and try_execute_active.


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