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/>.
10 /** @file crashlog.h Functions to be called to log a crash */
18 * Helper class for creating crash logs.
22 /** Pointer to the error message. */
23 static const char *message
;
27 * Writes OS' version to the buffer.
28 * @param buffer The string where to write.
30 virtual void LogOSVersion (stringb
*buffer
) const = 0;
33 * Writes actually encountered error to the buffer.
34 * @param buffer The string where to write.
35 * @param message Message passed to use for possible errors. Can be NULL.
37 virtual void LogError (stringb
*buffer
, const char *message
) const = 0;
40 * Writes the stack trace to the buffer, if there is information about it
42 * @param buffer The string where to write.
44 virtual void LogStacktrace (stringb
*buffer
) const = 0;
47 * Writes information about the data in the registers, if there is
48 * information about it available.
49 * @param buffer The string where to write.
51 virtual void LogRegisters (stringb
*buffer
) const;
54 * Writes the dynamically linked libraries/modules to the buffer, if there
55 * is information about it available.
56 * @param buffer The string where to write.
58 virtual void LogModules (stringb
*buffer
) const;
61 /** Stub destructor to silence some compilers. */
62 virtual ~CrashLog() {}
64 void FillCrashLog (stringb
*buffer
) const;
65 bool WriteCrashLog (const char *buffer
, stringb
*filename
) const;
68 * Write the (crash) dump to a file.
69 * @note On success the filename will be filled with the full path of the
70 * crash dump file. Make sure filename is at least \c MAX_PATH big.
71 * @param filename Output for the filename of the written file.
72 * @return if less than 0, error. If 0 no dump is made, otherwise the dump
73 * was successful (not all OSes support dumping files).
75 virtual int WriteCrashDump (stringb
*filename
) const;
76 bool WriteSavegame (stringb
*filename
) const;
77 bool WriteScreenshot (stringb
*filename
) const;
79 bool MakeCrashLog() const;
82 * Initialiser for crash logs; do the appropriate things so crashes are
83 * handled by our crash handler instead of returning straight to the OS.
84 * @note must be implemented by all implementers of CrashLog.
86 static void InitialiseCrashLog();
88 static void SetErrorMessage(const char *message
);
89 static void AfterCrashLogCleanup();
92 #endif /* CRASHLOG_H */