diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-10 02:01:09 -0800 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-10 02:13:09 -0800 |
commit | 2ebed5e396b655383be577ec55cfb756fcf328d4 (patch) | |
tree | 537412a06f2c32ee61ce99eef56a839dfcba8367 /crawl-ref/source/dbg-asrt.cc | |
parent | 4bd335dab6488ac58d412f8b640801350207c398 (diff) | |
download | crawl-ref-2ebed5e396b655383be577ec55cfb756fcf328d4.tar.gz crawl-ref-2ebed5e396b655383be577ec55cfb756fcf328d4.zip |
Brief crash output for exit() crashes
If a crash happens while exit() callbacks are being processed then just
output a bare minimum of info to stderr, since anything we might want to
reference would likely have been free'd, and we don't want to reference
free'd memory (plus information about the player, level and monsters
probably won't be of any help in tracking down a crash of that kind).
Diffstat (limited to 'crawl-ref/source/dbg-asrt.cc')
-rw-r--r-- | crawl-ref/source/dbg-asrt.cc | 75 |
1 files changed, 51 insertions, 24 deletions
diff --git a/crawl-ref/source/dbg-asrt.cc b/crawl-ref/source/dbg-asrt.cc index 24a5a6c4e9..53338f52c8 100644 --- a/crawl-ref/source/dbg-asrt.cc +++ b/crawl-ref/source/dbg-asrt.cc @@ -458,8 +458,58 @@ static void _debug_dump_lua_persist(FILE* file) fprintf(file, "%s", result.c_str()); } +static void _dump_ver_stuff(FILE* file) +{ + fprintf(file, "Version: %s %s" EOL, CRAWL, Version::Long().c_str()); +#if defined(UNIX) + fprintf(file, "Platform: unix"); +# if defined(TARGET_OS_MACOSX) + fprintf(file, " (OS X)"); +# endif + fprintf(file, EOL); +#elif defined(TARGET_OS_WINDOWS) + fprintf(file, "Platform: Windows" EOL); +#elif defined(TARGET_OS_DOS) + fprintf(file, "Platform: DOS" EOL); +#endif // UNIX + +#if TARGET_CPU_BITS == 64 + fprintf(file, "Bits: 64" EOL); +#else + fprintf(file, "Bits: 32" EOL); +#endif + +#ifdef USE_TILE + fprintf(file, "Tiles: yes" EOL EOL); +#else + fprintf(file, "Tiles: no" EOL EOL); +#endif +} + +// Defined in stuff.cc. Not a part of crawl_state, since that's a +// global C++ instance which is free'd by exit() hooks when exit() +// is called, and we don't want to reference free'd memory. +extern bool CrawlIsExiting; + void do_crash_dump() { + if (CrawlIsExiting) + { + // We crashed during exit() callbacks, so it's likely that + // any global C++ instances we could reference would be + // free'd and invalid, plus their content likely wouldn't help + // tracking it down anyways. Thus, just do the bare bones + // info to stderr and quit. + fprintf(stderr, "Crashed while calling exit()!!!!" EOL); + + _dump_ver_stuff(stderr); + + dump_crash_info(stderr); + write_stack_trace(stderr, 0); + + return; + } + std::string dir = (!Options.morgue_dir.empty() ? Options.morgue_dir : !SysEnv.crawl_dir.empty() ? SysEnv.crawl_dir : ""); @@ -494,30 +544,7 @@ void do_crash_dump() fprintf(file, "%s" EOL EOL, _assert_msg.c_str()); #endif - fprintf(file, "Version: %s %s" EOL, CRAWL, Version::Long().c_str()); -#if defined(UNIX) - fprintf(file, "Platform: unix"); -# if defined(TARGET_OS_MACOSX) - fprintf(file, " (OS X)"); -# endif - fprintf(file, EOL); -#elif defined(TARGET_OS_WINDOWS) - fprintf(file, "Platform: Windows" EOL); -#elif defined(TARGET_OS_DOS) - fprintf(file, "Platform: DOS" EOL); -#endif // UNIX - -#if TARGET_CPU_BITS == 64 - fprintf(file, "Bits: 64" EOL); -#else - fprintf(file, "Bits: 32" EOL); -#endif - -#ifdef USE_TILE - fprintf(file, "Tiles: yes" EOL EOL); -#else - fprintf(file, "Tiles: no" EOL EOL); -#endif + _dump_ver_stuff(file); // First get the immediate cause of the crash and the stack trace, // since that's most important and later attempts to get more information |