OpenTTD Source: src/crashlog.h Source File

OpenTTD Source 12.0-beta1

crashlog.h
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
7
10 #ifndef CRASHLOG_H
11 #define CRASHLOG_H
12
16 class CrashLog {
17 private:
19 static const char *message;
20
22 static char *gamelog_buffer;
23
25 static const char *gamelog_last;
26
27 static void GamelogFillCrashLog(const char *s);
28 protected:
35 virtual char *LogOSVersion(char *buffer, const char *last) const = 0;
36
43 virtual char *LogCompiler(char *buffer, const char *last) const;
44
52 virtual char *LogError(char *buffer, const char *last, const char *message) const = 0;
53
61 virtual char *LogStacktrace(char *buffer, const char *last) const = 0;
62
70 virtual char *LogRegisters(char *buffer, const char *last) const;
71
79 virtual char *LogModules(char *buffer, const char *last) const;
80
81
82 char *LogOpenTTDVersion(char *buffer, const char *last) const;
83 char *LogConfiguration(char *buffer, const char *last) const;
84 char *LogLibraries(char *buffer, const char *last) const;
85 char *LogGamelog(char *buffer, const char *last) const;
86 char *LogRecentNews(char *buffer, const char *list) const;
87
88 public:
90 virtual ~CrashLog() {}
91
92 char *FillCrashLog(char *buffer, const char *last) const;
93 bool WriteCrashLog(const char *buffer, char *filename, const char *filename_last) const;
94
104 virtual int WriteCrashDump(char *filename, const char *filename_last) const;
105 bool WriteSavegame(char *filename, const char *filename_last) const;
106 bool WriteScreenshot(char *filename, const char *filename_last) const;
107
108 bool MakeCrashLog() const;
109
115 static void InitialiseCrashLog();
116
121 static void InitThread();
122
123 static void SetErrorMessage(const char *message);
124 static void AfterCrashLogCleanup();
125 };
126
127 #endif /* CRASHLOG_H */
CrashLog::LogLibraries
char * LogLibraries(char *buffer, const char *last) const
Writes information (versions) of the used libraries.
Definition: crashlog.cpp:217
CrashLog::MakeCrashLog
bool MakeCrashLog() const
Makes the crash log, writes it to a file and then subsequently tries to make a crash dump and crash s...
Definition: crashlog.cpp:437
CrashLog::AfterCrashLogCleanup
static void AfterCrashLogCleanup()
Try to close the sound/video stuff so it doesn't keep lingering around incorrect video states or so,...
Definition: crashlog.cpp:505
CrashLog::WriteScreenshot
bool WriteScreenshot(char *filename, const char *filename_last) const
Write the (crash) screenshot to a file.
Definition: crashlog.cpp:421
CrashLog::LogConfiguration
char * LogConfiguration(char *buffer, const char *last) const
Writes the (important) configuration settings to the buffer.
Definition: crashlog.cpp:155
CrashLog::LogOpenTTDVersion
char * LogOpenTTDVersion(char *buffer, const char *last) const
Writes OpenTTD's version to the buffer.
Definition: crashlog.cpp:116
CrashLog::LogOSVersion
virtual char * LogOSVersion(char *buffer, const char *last) const =0
Writes OS' version to the buffer.
CrashLog::gamelog_buffer
static char * gamelog_buffer
Temporary 'local' location of the buffer.
Definition: crashlog.h:22
CrashLog::LogGamelog
char * LogGamelog(char *buffer, const char *last) const
Writes the gamelog data to the buffer.
Definition: crashlog.cpp:297
CrashLog::LogModules
virtual char * LogModules(char *buffer, const char *last) const
Writes the dynamically linked libraries/modules to the buffer, if there is information about it avail...
Definition: crashlog.cpp:104
CrashLog::LogRecentNews
char * LogRecentNews(char *buffer, const char *list) const
Writes up to 32 recent news messages to the buffer, with the most recent first.
Definition: crashlog.cpp:311
CrashLog::InitThread
static void InitThread()
Prepare crash log handler for a newly started thread.
Definition: crashlog_osx.cpp:261
CrashLog::SetErrorMessage
static void SetErrorMessage(const char *message)
Sets a message for the error message handler.
Definition: crashlog.cpp:496
CrashLog::~CrashLog
virtual ~CrashLog()
Stub destructor to silence some compilers.
Definition: crashlog.h:90
CrashLog::message
static const char * message
Pointer to the error message.
Definition: crashlog.h:19
CrashLog
Helper class for creating crash logs.
Definition: crashlog.h:16
CrashLog::LogRegisters
virtual char * LogRegisters(char *buffer, const char *last) const
Writes information about the data in the registers, if there is information about it available.
Definition: crashlog.cpp:98
CrashLog::WriteCrashDump
virtual int WriteCrashDump(char *filename, const char *filename_last) const
Write the (crash) dump to a file.
Definition: crashlog.cpp:381
CrashLog::LogError
virtual char * LogError(char *buffer, const char *last, const char *message) const =0
Writes actually encountered error to the buffer.
CrashLog::LogCompiler
virtual char * LogCompiler(char *buffer, const char *last) const
Writes compiler (and its version, if available) to the buffer.
Definition: crashlog.cpp:74
CrashLog::InitialiseCrashLog
static void InitialiseCrashLog()
Initialiser for crash logs; do the appropriate things so crashes are handled by our crash handler ins...
Definition: crashlog_osx.cpp:254
CrashLog::GamelogFillCrashLog
static void GamelogFillCrashLog(const char *s)
Helper function for printing the gamelog.
Definition: crashlog.cpp:286
CrashLog::WriteSavegame
bool WriteSavegame(char *filename, const char *filename_last) const
Write the (crash) savegame to a file.
Definition: crashlog.cpp:395
CrashLog::gamelog_last
static const char * gamelog_last
Temporary 'local' location of the end of the buffer.
Definition: crashlog.h:25
CrashLog::FillCrashLog
char * FillCrashLog(char *buffer, const char *last) const
Fill the crash log buffer with all data of a crash log.
Definition: crashlog.cpp:333
CrashLog::WriteCrashLog
bool WriteCrashLog(const char *buffer, char *filename, const char *filename_last) const
Write the crash log to a file.
Definition: crashlog.cpp:367
CrashLog::LogStacktrace
virtual char * LogStacktrace(char *buffer, const char *last) const =0
Writes the stack trace to the buffer, if there is information about it available.