mirror of https://github.com/rusefi/lua.git
traceback stops at first protected call
This commit is contained in:
parent
1dbe708aa8
commit
6ee2dbdfe9
19
ldblib.c
19
ldblib.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: ldblib.c,v 1.57 2002/06/13 13:44:50 roberto Exp roberto $
|
** $Id: ldblib.c,v 1.58 2002/06/18 15:17:58 roberto Exp roberto $
|
||||||
** Interface from Lua to its debug API
|
** Interface from Lua to its debug API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -184,26 +184,30 @@ static int debug (lua_State *L) {
|
||||||
static int errorfb (lua_State *L) {
|
static int errorfb (lua_State *L) {
|
||||||
int level = 1; /* skip level 0 (it's this function) */
|
int level = 1; /* skip level 0 (it's this function) */
|
||||||
int firstpart = 1; /* still before eventual `...' */
|
int firstpart = 1; /* still before eventual `...' */
|
||||||
|
int alllevels = 1;
|
||||||
|
const char *msg = lua_tostring(L, 1);
|
||||||
lua_Debug ar;
|
lua_Debug ar;
|
||||||
lua_settop(L, 0);
|
lua_settop(L, 0);
|
||||||
lua_pushliteral(L, "stack traceback:\n");
|
if (msg) {
|
||||||
|
alllevels = 0;
|
||||||
|
if (!strstr(msg, "stack traceback:\n"))
|
||||||
|
lua_pushliteral(L, "stack traceback:\n");
|
||||||
|
}
|
||||||
while (lua_getstack(L, level++, &ar)) {
|
while (lua_getstack(L, level++, &ar)) {
|
||||||
char buff[10];
|
|
||||||
if (level > LEVELS1 && firstpart) {
|
if (level > LEVELS1 && firstpart) {
|
||||||
/* no more than `LEVELS2' more levels? */
|
/* no more than `LEVELS2' more levels? */
|
||||||
if (!lua_getstack(L, level+LEVELS2, &ar))
|
if (!lua_getstack(L, level+LEVELS2, &ar))
|
||||||
level--; /* keep going */
|
level--; /* keep going */
|
||||||
else {
|
else {
|
||||||
lua_pushliteral(L, " ...\n"); /* too many levels */
|
lua_pushliteral(L, "\t...\n"); /* too many levels */
|
||||||
while (lua_getstack(L, level+LEVELS2, &ar)) /* find last levels */
|
while (lua_getstack(L, level+LEVELS2, &ar)) /* find last levels */
|
||||||
level++;
|
level++;
|
||||||
}
|
}
|
||||||
firstpart = 0;
|
firstpart = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
sprintf(buff, "%4d- ", level-1);
|
lua_pushliteral(L, "\t");
|
||||||
lua_pushstring(L, buff);
|
lua_getinfo(L, "Snlc", &ar);
|
||||||
lua_getinfo(L, "Snl", &ar);
|
|
||||||
lua_pushfstring(L, "%s:", ar.short_src);
|
lua_pushfstring(L, "%s:", ar.short_src);
|
||||||
if (ar.currentline > 0)
|
if (ar.currentline > 0)
|
||||||
lua_pushfstring(L, "%d:", ar.currentline);
|
lua_pushfstring(L, "%d:", ar.currentline);
|
||||||
|
@ -226,6 +230,7 @@ static int errorfb (lua_State *L) {
|
||||||
}
|
}
|
||||||
lua_pushliteral(L, "\n");
|
lua_pushliteral(L, "\n");
|
||||||
lua_concat(L, lua_gettop(L));
|
lua_concat(L, lua_gettop(L));
|
||||||
|
if (!alllevels && ar.isprotected) break;
|
||||||
}
|
}
|
||||||
lua_concat(L, lua_gettop(L));
|
lua_concat(L, lua_gettop(L));
|
||||||
return 1;
|
return 1;
|
||||||
|
|
7
ldebug.c
7
ldebug.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: ldebug.c,v 1.119 2002/06/13 13:39:55 roberto Exp roberto $
|
** $Id: ldebug.c,v 1.120 2002/06/18 15:19:27 roberto Exp roberto $
|
||||||
** Debug Interface
|
** Debug Interface
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -181,6 +181,7 @@ static void getname (lua_State *L, const TObject *f, lua_Debug *ar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
|
LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
|
||||||
StkId f;
|
StkId f;
|
||||||
CallInfo *ci;
|
CallInfo *ci;
|
||||||
|
@ -220,6 +221,10 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
|
||||||
status = 2;
|
status = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'c': {
|
||||||
|
ar->isprotected = (ci && luaD_isprotected(L, ci));
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: status = 0; /* invalid option */
|
default: status = 0; /* invalid option */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
ldo.c
10
ldo.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: ldo.c,v 1.179 2002/06/03 20:12:50 roberto Exp roberto $
|
** $Id: ldo.c,v 1.180 2002/06/18 15:19:27 roberto Exp roberto $
|
||||||
** Stack and Call structure of Lua
|
** Stack and Call structure of Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -501,5 +501,13 @@ int luaD_runprotected (lua_State *L, Pfunc f, TObject *ud) {
|
||||||
return lj.status;
|
return lj.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int luaD_isprotected (lua_State *L, CallInfo *ci) {
|
||||||
|
struct lua_longjmp *l;
|
||||||
|
for (l = L->errorJmp; l; l = l->previous)
|
||||||
|
if (l->ci+1 == ci) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* }====================================================== */
|
/* }====================================================== */
|
||||||
|
|
||||||
|
|
3
ldo.h
3
ldo.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: ldo.h,v 1.45 2002/05/15 18:57:44 roberto Exp roberto $
|
** $Id: ldo.h,v 1.46 2002/06/18 15:19:27 roberto Exp roberto $
|
||||||
** Stack and Call structure of Lua
|
** Stack and Call structure of Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -43,6 +43,7 @@ void luaD_growstack (lua_State *L, int n);
|
||||||
|
|
||||||
void luaD_throw (lua_State *L, int errcode);
|
void luaD_throw (lua_State *L, int errcode);
|
||||||
int luaD_runprotected (lua_State *L, Pfunc f, TObject *ud);
|
int luaD_runprotected (lua_State *L, Pfunc f, TObject *ud);
|
||||||
|
int luaD_isprotected (lua_State *L, CallInfo *ci);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
19
luadebug.h
19
luadebug.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: luadebug.h,v 1.26 2002/03/14 16:50:06 roberto Exp roberto $
|
** $Id: luadebug.h,v 1.27 2002/04/04 17:21:31 roberto Exp roberto $
|
||||||
** Debugging API
|
** Debugging API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -28,14 +28,15 @@ LUA_API lua_Hook lua_setlinehook (lua_State *L, lua_Hook func);
|
||||||
#define LUA_IDSIZE 60
|
#define LUA_IDSIZE 60
|
||||||
|
|
||||||
struct lua_Debug {
|
struct lua_Debug {
|
||||||
const char *event; /* `call', `return', `line' */
|
const char *event; /* `call', `return', `line' */
|
||||||
const char *name; /* (n) */
|
const char *name; /* (n) */
|
||||||
const char *namewhat; /* (n) `global', `local', `field', `method' */
|
const char *namewhat; /* (n) `global', `local', `field', `method' */
|
||||||
const char *what; /* (S) `Lua' function, `C' function, Lua `main' */
|
const char *what; /* (S) `Lua' function, `C' function, Lua `main' */
|
||||||
const char *source; /* (S) */
|
const char *source; /* (S) */
|
||||||
int currentline; /* (l) */
|
int currentline; /* (l) */
|
||||||
int nups; /* (u) number of upvalues */
|
int isprotected; /* (c) function was called in protected mode */
|
||||||
int linedefined; /* (S) */
|
int nups; /* (u) number of upvalues */
|
||||||
|
int linedefined; /* (S) */
|
||||||
char short_src[LUA_IDSIZE]; /* (S) */
|
char short_src[LUA_IDSIZE]; /* (S) */
|
||||||
/* private part */
|
/* private part */
|
||||||
int i_ci; /* active function */
|
int i_ci; /* active function */
|
||||||
|
|
Loading…
Reference in New Issue