diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-10-21 12:32:59 +0200 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-10-21 12:32:59 +0200 |
commit | d9a9f676d1265f71ab6ebebed582b25e1e7ed8ab (patch) | |
tree | dccdca9d3d48b1e874f4fdb72b7c0f82687fc208 /crawl-ref/source | |
parent | df9d0d88a17ed81f394e76d336657e5a180c0c36 (diff) | |
download | crawl-ref-d9a9f676d1265f71ab6ebebed582b25e1e7ed8ab.tar.gz crawl-ref-d9a9f676d1265f71ab6ebebed582b25e1e7ed8ab.zip |
Move print_?lua_stack into CLua.
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/clua.cc | 51 | ||||
-rw-r--r-- | crawl-ref/source/clua.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/debug.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/dlua.cc | 26 | ||||
-rw-r--r-- | crawl-ref/source/dlua.h | 2 |
5 files changed, 30 insertions, 57 deletions
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index 334b481319..529ca02c1d 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -653,6 +653,32 @@ void CLua::remove_shutdown_listener(lua_shutdown_listener *listener) shutdown_listeners.erase(i); } +// Can be called from within a debugger to look at the current Lua +// call stack. (Borrowed from ToME 3) +void CLua::print_stack() +{ + struct lua_Debug dbg; + int i = 0; + lua_State *L = state(); + + fprintf(stderr, EOL); + while (lua_getstack(L, i++, &dbg) == 1) + { + lua_getinfo(L, "lnuS", &dbg); + + char* file = strrchr(dbg.short_src, '/'); + if (file == NULL) + file = dbg.short_src; + else + file++; + + fprintf(stderr, "%s, function %s, line %d" EOL, file, + dbg.name, dbg.currentline); + } + + fprintf(stderr, EOL); +} + //////////////////////////////////////////////////////////////////////// // lua_text_pattern @@ -1110,28 +1136,3 @@ bool lua_datum::is_udata() const LUA_CHECK_TYPE(lua_isuserdata); } -// Can be called from within a debugger to look at the current Lua -// call stack. (Borrowed from ToME 3) -void print_clua_stack(void) -{ - struct lua_Debug dbg; - int i = 0; - lua_State *L = clua.state(); - - fprintf(stderr, EOL); - while (lua_getstack(L, i++, &dbg) == 1) - { - lua_getinfo(L, "lnuS", &dbg); - - char* file = strrchr(dbg.short_src, '/'); - if (file == NULL) - file = dbg.short_src; - else - file++; - - fprintf(stderr, "%s, function %s, line %d" EOL, file, - dbg.name, dbg.currentline); - } - - fprintf(stderr, EOL); -} diff --git a/crawl-ref/source/clua.h b/crawl-ref/source/clua.h index 092e551384..a72d56159b 100644 --- a/crawl-ref/source/clua.h +++ b/crawl-ref/source/clua.h @@ -142,6 +142,8 @@ public: static bool is_managed_vm(lua_State *ls); + void print_stack(); + public: std::string error; @@ -234,6 +236,4 @@ void lua_set_exclusive_item(const item_def *item = NULL); std::string quote_lua_string(const std::string &s); -void print_clua_stack(); - #endif diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index e4877d06c8..71985b5336 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -6592,10 +6592,10 @@ void do_crash_dump() // If anything has screwed up the Lua runtime stacks then trying to // print those stacks will likely crash, so do this after the others. fprintf(file, "clua stack:" EOL); - print_clua_stack(); + clua.print_stack(); fprintf(file, "dlua stack:" EOL); - print_dlua_stack(); + dlua.print_stack(); // Lastly try to dump the Lua persistent data and the contents of the Lua // markers, since actually running Lua code has the greatest chance of diff --git a/crawl-ref/source/dlua.cc b/crawl-ref/source/dlua.cc index cac5941566..d80c64118c 100644 --- a/crawl-ref/source/dlua.cc +++ b/crawl-ref/source/dlua.cc @@ -300,29 +300,3 @@ void init_dungeon_lua() register_itemlist(dlua); register_monslist(dlua); } - -// Can be called from within a debugger to look at the current Lua -// call stack. (Borrowed from ToME 3) -void print_dlua_stack(void) -{ - struct lua_Debug dbg; - int i = 0; - lua_State *L = dlua.state(); - - fprintf(stderr, EOL); - while (lua_getstack(L, i++, &dbg) == 1) - { - lua_getinfo(L, "lnuS", &dbg); - - char* file = strrchr(dbg.short_src, '/'); - if (file == NULL) - file = dbg.short_src; - else - file++; - - fprintf(stderr, "%s, function %s, line %d" EOL, file, - dbg.name, dbg.currentline); - } - - fprintf(stderr, EOL); -} diff --git a/crawl-ref/source/dlua.h b/crawl-ref/source/dlua.h index 24fe334453..1e04dcd4e8 100644 --- a/crawl-ref/source/dlua.h +++ b/crawl-ref/source/dlua.h @@ -72,8 +72,6 @@ public: void init_dungeon_lua(); -void print_dlua_stack(); - ////////////////////////////////////////////////////////////////////////// #endif |