OpenTTD
|
Helper class for creating crash logs. More...
#include <crashlog.h>
Public Member Functions | |
virtual | ~CrashLog () |
Stub destructor to silence some compilers. More... | |
char * | FillCrashLog (char *buffer, const char *last) const |
Fill the crash log buffer with all data of a crash log. More... | |
bool | WriteCrashLog (const char *buffer, char *filename, const char *filename_last) const |
Write the crash log to a file. More... | |
virtual int | WriteCrashDump (char *filename, const char *filename_last) const |
Write the (crash) dump to a file. More... | |
bool | WriteSavegame (char *filename, const char *filename_last) const |
Write the (crash) savegame to a file. More... | |
bool | WriteScreenshot (char *filename, const char *filename_last) const |
Write the (crash) screenshot to a file. More... | |
bool | MakeCrashLog () const |
Makes the crash log, writes it to a file and then subsequently tries to make a crash dump and crash savegame. More... | |
Static Public Member Functions | |
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 | SetErrorMessage (const char *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 | |
virtual char * | LogOSVersion (char *buffer, const char *last) const =0 |
Writes OS' version to the buffer. More... | |
virtual char * | LogCompiler (char *buffer, const char *last) const |
Writes compiler (and its version, if available) to the buffer. More... | |
virtual char * | LogError (char *buffer, const char *last, const char *message) const =0 |
Writes actually encountered error to the buffer. More... | |
virtual char * | LogStacktrace (char *buffer, const char *last) const =0 |
Writes the stack trace to the buffer, if there is information about it available. More... | |
virtual char * | LogRegisters (char *buffer, const char *last) const |
Writes information about the data in the registers, if there is information about it available. More... | |
virtual char * | LogModules (char *buffer, const char *last) const |
Writes the dynamically linked libraries/modules to the buffer, if there is information about it available. More... | |
char * | LogOpenTTDVersion (char *buffer, const char *last) const |
Writes OpenTTD's version to the buffer. More... | |
char * | LogConfiguration (char *buffer, const char *last) const |
Writes the (important) configuration settings to the buffer. More... | |
char * | LogLibraries (char *buffer, const char *last) const |
Writes information (versions) of the used libraries. More... | |
char * | LogGamelog (char *buffer, const char *last) const |
Writes the gamelog data to the buffer. More... | |
Static Private Member Functions | |
static void | GamelogFillCrashLog (const char *s) |
Helper function for printing the gamelog. More... | |
Static Private Attributes | |
static const char * | message = NULL |
Pointer to the error message. More... | |
static char * | gamelog_buffer = NULL |
Temporary 'local' location of the buffer. More... | |
static const char * | gamelog_last = NULL |
Temporary 'local' location of the end of the buffer. More... | |
Helper class for creating crash logs.
Definition at line 18 of file crashlog.h.
|
inlinevirtual |
Stub destructor to silence some compilers.
Definition at line 91 of file crashlog.h.
References AfterCrashLogCleanup(), FillCrashLog(), InitialiseCrashLog(), MakeCrashLog(), SetErrorMessage(), WriteCrashDump(), WriteCrashLog(), WriteSavegame(), and WriteScreenshot().
|
static |
Try to close the sound/video stuff so it doesn't keep lingering around incorrect video states or so, e.g.
keeping dpmi disabled.
Definition at line 489 of file crashlog.cpp.
References SoundDriver::GetInstance(), MusicDriver::GetInstance(), VideoDriver::GetInstance(), and Driver::Stop().
Referenced by HandleCrash(), and ~CrashLog().
char * CrashLog::FillCrashLog | ( | char * | buffer, |
const char * | last | ||
) | const |
Fill the crash log buffer with all data of a crash log.
buffer | The begin where to write at. |
last | The last position in the buffer to write to. |
'\0'
character after the buffer. Definition at line 317 of file crashlog.cpp.
References _date, _date_fract, ConvertDateToYMD(), YearMonthDay::day, LogCompiler(), LogConfiguration(), LogError(), LogGamelog(), LogLibraries(), LogModules(), LogOpenTTDVersion(), LogOSVersion(), LogRegisters(), LogStacktrace(), message, YearMonthDay::month, seprintf(), and YearMonthDay::year.
Referenced by CrashLogOSX::MakeCrashLog(), and ~CrashLog().
|
staticprivate |
Helper function for printing the gamelog.
s | the string to print. |
Definition at line 292 of file crashlog.cpp.
References gamelog_buffer, gamelog_last, and seprintf().
Referenced by LogGamelog().
|
static |
Initialiser for crash logs; do the appropriate things so crashes are handled by our crash handler instead of returning straight to the OS.
Definition at line 251 of file crashlog_osx.cpp.
References _signals_to_handle, endof, and HandleCrash().
Referenced by HandleCrash(), and ~CrashLog().
|
protectedvirtual |
Writes compiler (and its version, if available) to the buffer.
buffer | The begin where to write at. |
last | The last position in the buffer to write to. |
'\0'
character after the buffer. Definition at line 77 of file crashlog.cpp.
References seprintf().
Referenced by FillCrashLog().
|
protected |
Writes the (important) configuration settings to the buffer.
E.g. graphics set, sound set, blitter and AIs.
buffer | The begin where to write at. |
last | The last position in the buffer to write to. |
'\0'
character after the buffer. Definition at line 158 of file crashlog.cpp.
References BlitterFactory::GetCurrentBlitter(), BaseMedia< GraphicsSet >::GetUsedSet(), and seprintf().
Referenced by FillCrashLog().
|
protectedpure virtual |
Writes actually encountered error to the buffer.
buffer | The begin where to write at. |
last | The last position in the buffer to write to. |
message | Message passed to use for possible errors. Can be NULL. |
'\0'
character after the buffer. Implemented in CrashLogOSX, CrashLogUnix, and CrashLogWindows.
Referenced by FillCrashLog().
|
protected |
Writes the gamelog data to the buffer.
buffer | The begin where to write at. |
last | The last position in the buffer to write to. |
'\0'
character after the buffer. Definition at line 303 of file crashlog.cpp.
References gamelog_buffer, gamelog_last, GamelogFillCrashLog(), GamelogPrint(), and seprintf().
Referenced by FillCrashLog().
|
protected |
Writes information (versions) of the used libraries.
buffer | The begin where to write at. |
last | The last position in the buffer to write to. |
'\0'
character after the buffer. Definition at line 221 of file crashlog.cpp.
References seprintf().
Referenced by FillCrashLog().
|
protectedvirtual |
Writes the dynamically linked libraries/modules to the buffer, if there is information about it available.
buffer | The begin where to write at. |
last | The last position in the buffer to write to. |
'\0'
character after the buffer. Reimplemented in CrashLogWindows.
Definition at line 107 of file crashlog.cpp.
Referenced by FillCrashLog().
|
protected |
Writes OpenTTD's version to the buffer.
buffer | The begin where to write at. |
last | The last position in the buffer to write to. |
'\0'
character after the buffer. Definition at line 119 of file crashlog.cpp.
References seprintf().
Referenced by FillCrashLog().
|
protectedpure virtual |
Writes OS' version to the buffer.
buffer | The begin where to write at. |
last | The last position in the buffer to write to. |
'\0'
character after the buffer. Implemented in CrashLogOSX, CrashLogWindows, and CrashLogUnix.
Referenced by FillCrashLog().
|
protectedvirtual |
Writes information about the data in the registers, if there is information about it available.
buffer | The begin where to write at. |
last | The last position in the buffer to write to. |
'\0'
character after the buffer. Reimplemented in CrashLogWindows.
Definition at line 101 of file crashlog.cpp.
Referenced by FillCrashLog().
|
protectedpure virtual |
Writes the stack trace to the buffer, if there is information about it available.
buffer | The begin where to write at. |
last | The last position in the buffer to write to. |
'\0'
character after the buffer. Implemented in CrashLogUnix, CrashLogOSX, and CrashLogWindows.
Referenced by FillCrashLog().
bool CrashLog::MakeCrashLog | ( | ) | const |
Makes the crash log, writes it to a file and then subsequently tries to make a crash dump and crash savegame.
It uses DEBUG to write information like paths to the console.
Definition at line 421 of file crashlog.cpp.
Referenced by HandleCrash(), and ~CrashLog().
|
static |
Sets a message for the error message handler.
message | The error message of the error. |
Definition at line 480 of file crashlog.cpp.
References message.
Referenced by ~CrashLog().
|
virtual |
Write the (crash) dump to a file.
MAX_PATH
big. filename | Output for the filename of the written file. |
filename_last | The last position in the filename buffer. |
Definition at line 365 of file crashlog.cpp.
Referenced by ~CrashLog().
bool CrashLog::WriteCrashLog | ( | const char * | buffer, |
char * | filename, | ||
const char * | filename_last | ||
) | const |
Write the crash log to a file.
MAX_PATH
big. buffer | The begin of the buffer to write to the disk. |
filename | Output for the filename of the written file. |
filename_last | The last position in the filename buffer. |
Definition at line 351 of file crashlog.cpp.
References _personal_dir, FioFCloseFile(), FioFOpenFile(), NO_DIRECTORY, and seprintf().
Referenced by CrashLogOSX::MakeCrashLog(), and ~CrashLog().
bool CrashLog::WriteSavegame | ( | char * | filename, |
const char * | filename_last | ||
) | const |
Write the (crash) savegame to a file.
MAX_PATH
big. filename | Output for the filename of the written file. |
filename_last | The last position in the filename buffer. |
Definition at line 379 of file crashlog.cpp.
References _m, _personal_dir, DFT_GAME_FILE, GamelogEmergency(), NO_DIRECTORY, SaveOrLoad(), seprintf(), SL_OK, and SLO_SAVE.
Referenced by CrashLogOSX::MakeCrashLog(), and ~CrashLog().
bool CrashLog::WriteScreenshot | ( | char * | filename, |
const char * | filename_last | ||
) | const |
Write the (crash) screenshot to a file.
MAX_PATH
big. filename | Output for the filename of the written file. |
filename_last | The last position in the filename buffer. |
Definition at line 405 of file crashlog.cpp.
Referenced by CrashLogOSX::MakeCrashLog(), and ~CrashLog().
|
staticprivate |
Temporary 'local' location of the buffer.
Definition at line 24 of file crashlog.h.
Referenced by GamelogFillCrashLog(), and LogGamelog().
|
staticprivate |
Temporary 'local' location of the end of the buffer.
Definition at line 27 of file crashlog.h.
Referenced by GamelogFillCrashLog(), and LogGamelog().
|
staticprivate |
Pointer to the error message.
Definition at line 21 of file crashlog.h.
Referenced by CrashLogOSX::DisplayCrashDialog(), FillCrashLog(), and SetErrorMessage().