OpenTTD
crashlog.h
Go to the documentation of this file.
1 /* $Id: crashlog.h 24900 2013-01-08 22:46:42Z planetmaker $ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * 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.
6  * 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.
7  * 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/>.
8  */
9 
12 #ifndef CRASHLOG_H
13 #define CRASHLOG_H
14 
18 class CrashLog {
19 private:
21  static const char *message;
22 
24  static char *gamelog_buffer;
25 
27  static const char *gamelog_last;
28 
29  static void GamelogFillCrashLog(const char *s);
30 protected:
37  virtual char *LogOSVersion(char *buffer, const char *last) const = 0;
38 
45  virtual char *LogCompiler(char *buffer, const char *last) const;
46 
54  virtual char *LogError(char *buffer, const char *last, const char *message) const = 0;
55 
63  virtual char *LogStacktrace(char *buffer, const char *last) const = 0;
64 
72  virtual char *LogRegisters(char *buffer, const char *last) const;
73 
81  virtual char *LogModules(char *buffer, const char *last) const;
82 
83 
84  char *LogOpenTTDVersion(char *buffer, const char *last) const;
85  char *LogConfiguration(char *buffer, const char *last) const;
86  char *LogLibraries(char *buffer, const char *last) const;
87  char *LogGamelog(char *buffer, const char *last) const;
88 
89 public:
91  virtual ~CrashLog() {}
92 
93  char *FillCrashLog(char *buffer, const char *last) const;
94  bool WriteCrashLog(const char *buffer, char *filename, const char *filename_last) const;
95 
105  virtual int WriteCrashDump(char *filename, const char *filename_last) const;
106  bool WriteSavegame(char *filename, const char *filename_last) const;
107  bool WriteScreenshot(char *filename, const char *filename_last) const;
108 
109  bool MakeCrashLog() const;
110 
116  static void InitialiseCrashLog();
117 
118  static void SetErrorMessage(const char *message);
119  static void AfterCrashLogCleanup();
120 };
121 
122 #endif /* CRASHLOG_H */
Helper class for creating crash logs.
Definition: crashlog.h:18
bool WriteCrashLog(const char *buffer, char *filename, const char *filename_last) const
Write the crash log to a file.
Definition: crashlog.cpp:351
static const char * gamelog_last
Temporary &#39;local&#39; location of the end of the buffer.
Definition: crashlog.h:27
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:365
char * LogGamelog(char *buffer, const char *last) const
Writes the gamelog data to the buffer.
Definition: crashlog.cpp:303
char * LogOpenTTDVersion(char *buffer, const char *last) const
Writes OpenTTD&#39;s version to the buffer.
Definition: crashlog.cpp:119
static const char * message
Pointer to the error message.
Definition: crashlog.h:21
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:489
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:421
static char * gamelog_buffer
Temporary &#39;local&#39; location of the buffer.
Definition: crashlog.h:24
bool WriteScreenshot(char *filename, const char *filename_last) const
Write the (crash) screenshot to a file.
Definition: crashlog.cpp:405
virtual char * LogCompiler(char *buffer, const char *last) const
Writes compiler (and its version, if available) to the buffer.
Definition: crashlog.cpp:77
bool WriteSavegame(char *filename, const char *filename_last) const
Write the (crash) savegame to a file.
Definition: crashlog.cpp:379
virtual ~CrashLog()
Stub destructor to silence some compilers.
Definition: crashlog.h:91
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:221
char * LogConfiguration(char *buffer, const char *last) const
Writes the (important) configuration settings to the buffer.
Definition: crashlog.cpp:158
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:101
static void GamelogFillCrashLog(const char *s)
Helper function for printing the gamelog.
Definition: crashlog.cpp:292
char * FillCrashLog(char *buffer, const char *last) const
Fill the crash log buffer with all data of a crash log.
Definition: crashlog.cpp:317
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:107
static void SetErrorMessage(const char *message)
Sets a message for the error message handler.
Definition: crashlog.cpp:480