OpenTTD
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 
117  static void SetErrorMessage(const char *message);
118  static void AfterCrashLogCleanup();
119 };
120 
121 #endif /* CRASHLOG_H */
Helper class for creating crash logs.
Definition: crashlog.h:16
bool WriteCrashLog(const char *buffer, char *filename, const char *filename_last) const
Write the crash log to a file.
Definition: crashlog.cpp:369
static const char * gamelog_last
Temporary &#39;local&#39; location of the end of the buffer.
Definition: crashlog.h:25
virtual char * LogError(char *buffer, const char *last, const char *message) const =0
Writes actually encountered error to the buffer.
static void InitialiseCrashLog()
Initialiser for crash logs; do the appropriate things so crashes are handled by our crash handler ins...
virtual int WriteCrashDump(char *filename, const char *filename_last) const
Write the (crash) dump to a file.
Definition: crashlog.cpp:383
char * LogGamelog(char *buffer, const char *last) const
Writes the gamelog data to the buffer.
Definition: crashlog.cpp:298
char * LogOpenTTDVersion(char *buffer, const char *last) const
Writes OpenTTD&#39;s version to the buffer.
Definition: crashlog.cpp:117
static const char * message
Pointer to the error message.
Definition: crashlog.h:19
static void AfterCrashLogCleanup()
Try to close the sound/video stuff so it doesn&#39;t keep lingering around incorrect video states or so...
Definition: crashlog.cpp:507
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:439
static char * gamelog_buffer
Temporary &#39;local&#39; location of the buffer.
Definition: crashlog.h:22
bool WriteScreenshot(char *filename, const char *filename_last) const
Write the (crash) screenshot to a file.
Definition: crashlog.cpp:423
virtual char * LogCompiler(char *buffer, const char *last) const
Writes compiler (and its version, if available) to the buffer.
Definition: crashlog.cpp:75
bool WriteSavegame(char *filename, const char *filename_last) const
Write the (crash) savegame to a file.
Definition: crashlog.cpp:397
virtual ~CrashLog()
Stub destructor to silence some compilers.
Definition: crashlog.h:90
virtual char * LogStacktrace(char *buffer, const char *last) const =0
Writes the stack trace to the buffer, if there is information about it available. ...
virtual char * LogOSVersion(char *buffer, const char *last) const =0
Writes OS&#39; version to the buffer.
char * LogLibraries(char *buffer, const char *last) const
Writes information (versions) of the used libraries.
Definition: crashlog.cpp:218
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:312
char * LogConfiguration(char *buffer, const char *last) const
Writes the (important) configuration settings to the buffer.
Definition: crashlog.cpp:156
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:99
static void GamelogFillCrashLog(const char *s)
Helper function for printing the gamelog.
Definition: crashlog.cpp:287
char * FillCrashLog(char *buffer, const char *last) const
Fill the crash log buffer with all data of a crash log.
Definition: crashlog.cpp:334
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:105
static void SetErrorMessage(const char *message)
Sets a message for the error message handler.
Definition: crashlog.cpp:498