be called from the debugger to print the call stacks of the dlua interpreter and the clua interpreter. Code borrowed from ToME 3 (code I originally wrote, so borrowing is definitely okay).
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7651 c06c8d41-db1a-0410-9941-cceddc491573
FAGA7XVY7FB5VEMJZ625GU5CPQMTY4KTX2NCIXQWFPH7ZQYJSAFAC
}
// 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, "\n");
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++;
// Have to use "\r\n" instead of just "\n" here, for some
// reason.
fprintf(stderr, "%s, function %s, line %d\r\n", file,
dbg.name, dbg.currentline);
}
fprintf(stderr, "\n");
}
// 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, "\n");
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++;
// Have to use "\r\n" instead of just "\n" here, for some
// reason.
fprintf(stderr, "%s, function %s, line %d\r\n", file,
dbg.name, dbg.currentline);
}
fprintf(stderr, "\n");