diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-22 11:00:14 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-22 11:00:14 +0000 |
commit | ec5b5dfca31a3c2ec1a101e38f57f47c3952acb8 (patch) | |
tree | d4161725fc218e93d7cc7042253fc4fa77bf476c /crawl-ref | |
parent | a54e6bb23df5211c2a5b59037f355c43e795fa05 (diff) | |
download | crawl-ref-ec5b5dfca31a3c2ec1a101e38f57f47c3952acb8.tar.gz crawl-ref-ec5b5dfca31a3c2ec1a101e38f57f47c3952acb8.zip |
Include the Lua stack trace and currently acting monsters in the crash report.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8694 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/clua.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/clua.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/crash-u.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/debug.cc | 26 | ||||
-rw-r--r-- | crawl-ref/source/luadgn.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/luadgn.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/state.cc | 15 |
7 files changed, 46 insertions, 17 deletions
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index 2f76087e43..e75261e300 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -3205,7 +3205,7 @@ void print_clua_stack(void) int i = 0; lua_State *L = clua.state(); - fprintf(stderr, "\n"); + fprintf(stderr, EOL); while (lua_getstack(L, i++, &dbg) == 1) { lua_getinfo(L, "lnuS", &dbg); @@ -3216,11 +3216,9 @@ void print_clua_stack(void) else file++; - // Have to use "\r\n" instead of just "\n" here, for some - // reason. - fprintf(stderr, "%s, function %s, line %d\r\n", file, + fprintf(stderr, "%s, function %s, line %d" EOL, file, dbg.name, dbg.currentline); } - fprintf(stderr, "\n"); + fprintf(stderr, EOL); } diff --git a/crawl-ref/source/clua.h b/crawl-ref/source/clua.h index 7880eabcb6..2f8416adf2 100644 --- a/crawl-ref/source/clua.h +++ b/crawl-ref/source/clua.h @@ -319,6 +319,8 @@ void clua_register_metatable(lua_State *ls, const char *tn, const luaL_reg *lr, int (*gcfn)(lua_State *ls) = NULL); +void print_clua_stack(); + #define MAP_METATABLE "dgn.mtmap" #define DEVENT_METATABLE "dgn.devent" #define MAPMARK_METATABLE "dgn.mapmark" diff --git a/crawl-ref/source/crash-u.cc b/crawl-ref/source/crash-u.cc index fba87d64fb..8a1f3d000d 100644 --- a/crawl-ref/source/crash-u.cc +++ b/crawl-ref/source/crash-u.cc @@ -132,7 +132,7 @@ void dump_crash_info(FILE* file) if (name == NULL) name = "INVALID"; - fprintf(file, "Crash caused by signal #%d: %s" EOL, _crash_signal, + fprintf(file, "Crash caused by signal #%d: %s" EOL EOL, _crash_signal, name); } diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index fa1d9b1b0e..45c7d406c0 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -5544,7 +5544,17 @@ void do_crash_dump() file = stderr; } else - fprintf(stderr, EOL "nWriting crash info to %s" EOL, name); + { + fprintf(stderr, EOL "Writing crash info to %s" EOL, name); + + // Merge stderr into file, so that the lua stack dumping functions + // (and anything else that uses stderr) will send everything to + // the output file. + dup2(fileno(file), fileno(stderr)); + + // Unbuffer the output file stream, to match with stderr. + setvbuf(file, NULL, _IONBF, 0); + } set_msg_dump_file(file); @@ -5557,10 +5567,7 @@ void do_crash_dump() // since that's most important and later attempts to get more information // might themselves cause crashes. dump_crash_info(file); - // Ignore the top five stack frames, since the first three involve - // signal handling and the last two are do_crash_dump() and - // write_stack_trace(). - write_stack_trace(file, 5); + write_stack_trace(file, 0); if (Generating_Level) { @@ -5586,7 +5593,14 @@ void do_crash_dump() fprintf(file, EOL); } - // Dumping the crawl state is least likely to cause another crash, + // Dumping the Lua stacks isn't that likely to crash. + fprintf(file, "clua stack:" EOL); + print_clua_stack(); + + fprintf(file, "dlua stack:" EOL); + print_dlua_stack(); + + // Dumping the crawl state is next least likely to cause another crash, // so do that next. crawl_state.dump(file); diff --git a/crawl-ref/source/luadgn.cc b/crawl-ref/source/luadgn.cc index 2539b5a44f..e7627ea5d4 100644 --- a/crawl-ref/source/luadgn.cc +++ b/crawl-ref/source/luadgn.cc @@ -3448,7 +3448,7 @@ void print_dlua_stack(void) int i = 0; lua_State *L = dlua.state(); - fprintf(stderr, "\n"); + fprintf(stderr, EOL); while (lua_getstack(L, i++, &dbg) == 1) { lua_getinfo(L, "lnuS", &dbg); @@ -3459,11 +3459,9 @@ void print_dlua_stack(void) else file++; - // Have to use "\r\n" instead of just "\n" here, for some - // reason. - fprintf(stderr, "%s, function %s, line %d\r\n", file, + fprintf(stderr, "%s, function %s, line %d" EOL, file, dbg.name, dbg.currentline); } - fprintf(stderr, "\n"); + fprintf(stderr, EOL); } diff --git a/crawl-ref/source/luadgn.h b/crawl-ref/source/luadgn.h index 746f80be60..90087ead60 100644 --- a/crawl-ref/source/luadgn.h +++ b/crawl-ref/source/luadgn.h @@ -89,6 +89,8 @@ inline void dlua_push_userdata(lua_State *ls, T udata, const char *meta) *de = udata; } +void print_dlua_stack(); + ////////////////////////////////////////////////////////////////////////// #endif diff --git a/crawl-ref/source/state.cc b/crawl-ref/source/state.cc index 9cf8e30b1a..682119512b 100644 --- a/crawl-ref/source/state.cc +++ b/crawl-ref/source/state.cc @@ -423,6 +423,7 @@ void game_state::mon_gone(monsters* mon) { mon_act_stack.erase(mon_act_stack.begin() + i); i--; + size--; } } @@ -502,4 +503,18 @@ void game_state::dump(FILE* file) god_act_stack[i].depth); fprintf(file, EOL); } + + if (mon_act != NULL) + { + fprintf(file, "Monster '%s' currently acting" EOL EOL, + mon_act->name(DESC_PLAIN, true).c_str()); + } + + if (mon_act_stack.size() != 0) + { + fprintf(file, "Others monsters acting:" EOL); + for (unsigned int i = 0; i < mon_act_stack.size(); i++) + fprintf(file, "Monster '%s'" EOL, + mon_act_stack[i]->name(DESC_PLAIN, true).c_str()); + } } |