summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/message.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-18 05:12:24 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-18 05:12:24 +0000
commitddb951a57ed0ac94c749e971f4c0556794110275 (patch)
treeb43fb8c51041edf4f9f846ede3aa0a6c79a0ffb3 /crawl-ref/source/message.cc
parentb8f4f50faab8b771ad053c154e781d129ef55005 (diff)
downloadcrawl-ref-ddb951a57ed0ac94c749e971f4c0556794110275.tar.gz
crawl-ref-ddb951a57ed0ac94c749e971f4c0556794110275.zip
Implemented crash data reporting, though it's only some stubs on Windows and
DOS. On UNIX with USE_UNIX_SIGNALS defined, when any crash causing signal happens it will dump to a file the current crawl_state, anything caught by the items and monsters scans, and level building info if the crash happened during level generation. Also, if crawl is linked against the GNU C library (and the exectuable is in ELF format) it will dump the stack trace. The code attempts to automatically detect the presence of glibc, but that might not work on all systems. This should work on OS X, since there's an OS X man page for the glibc functions that get the stack trace. Don't know if it would work with MinGW. Actually getting function names for the stack trace requires the use of the "-rdynamic" linker option, which increases the size of the stripped executable by 27% (yikes!), but still prints the function names even when stripped. All of the function names in the stack trace are mangled C++ ones, but that shouldn't be too much of a problem. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8532 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/message.cc')
-rw-r--r--crawl-ref/source/message.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc
index aedfa7ba65..7bda843e10 100644
--- a/crawl-ref/source/message.cc
+++ b/crawl-ref/source/message.cc
@@ -61,6 +61,8 @@ int Next_Message = 0; // end of messages
int Message_Line = 0; // line of next (previous?) message
int New_Message_Count = 0;
+static FILE* _msg_dump_file = NULL;
+
static bool suppress_messages = false;
static void base_mpr(const char *inf, msg_channel_type channel, int param,
unsigned char colour);
@@ -417,6 +419,12 @@ void mprf( const char *format, ... )
void mpr(const char *inf, msg_channel_type channel, int param)
{
+ if (_msg_dump_file != NULL)
+ fprintf(_msg_dump_file, "%s\n", inf);
+
+ if (crawl_state.game_crashed)
+ return;
+
if (crawl_state.arena)
{
switch(channel)
@@ -1275,3 +1283,8 @@ void replay_messages(void)
return;
} // end replay_messages()
+
+void set_msg_dump_file(FILE* file)
+{
+ _msg_dump_file = file;
+}