diff options
Diffstat (limited to 'ldebug.c')
-rw-r--r-- | ldebug.c | 22 |
1 files changed, 9 insertions, 13 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.123 2002/06/24 15:07:21 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.124 2002/07/08 18:21:33 roberto Exp roberto $ |
3 | ** Debug Interface | 3 | ** Debug Interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -30,15 +30,11 @@ static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); | |||
30 | 30 | ||
31 | 31 | ||
32 | 32 | ||
33 | static int isLmark (CallInfo *ci) { | ||
34 | return (ttype(ci->base - 1) == LUA_TFUNCTION && !ci_func(ci)->c.isC); | ||
35 | } | ||
36 | |||
37 | |||
38 | static int currentpc (lua_State *L, CallInfo *ci) { | 33 | static int currentpc (lua_State *L, CallInfo *ci) { |
39 | if (ci->pc == NULL) return -1; /* function is not an active Lua function */ | 34 | if (!isLua(ci)) return -1; /* function is not a Lua function? */ |
40 | if (ci == L->ci || ci->pc != (ci+1)->pc) /* no other function using `pc'? */ | 35 | /* next function is not using the same `pc'? (not a Lua->Lua call?) */ |
41 | ci->savedpc = *ci->pc; /* may not be saved; save it */ | 36 | if (ci == L->ci || !isLua(ci+1) || ci->u.l.pc != (ci+1)->u.l.pc) |
37 | ci->savedpc = *ci->u.l.pc; /* may not be saved; save it */ | ||
42 | /* function's pc is saved */ | 38 | /* function's pc is saved */ |
43 | return pcRel(ci->savedpc, ci_func(ci)->l.p); | 39 | return pcRel(ci->savedpc, ci_func(ci)->l.p); |
44 | } | 40 | } |
@@ -95,7 +91,7 @@ LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { | |||
95 | 91 | ||
96 | 92 | ||
97 | static Proto *getluaproto (CallInfo *ci) { | 93 | static Proto *getluaproto (CallInfo *ci) { |
98 | return (isLmark(ci) ? ci_func(ci)->l.p : NULL); | 94 | return (isLua(ci) ? ci_func(ci)->l.p : NULL); |
99 | } | 95 | } |
100 | 96 | ||
101 | 97 | ||
@@ -424,7 +420,7 @@ static const char *kname (Proto *p, int c) { | |||
424 | 420 | ||
425 | static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos, | 421 | static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos, |
426 | const char **name) { | 422 | const char **name) { |
427 | if (isLmark(ci)) { /* an active Lua function? */ | 423 | if (isLua(ci)) { /* an active Lua function? */ |
428 | Proto *p = ci_func(ci)->l.p; | 424 | Proto *p = ci_func(ci)->l.p; |
429 | int pc = currentpc(L, ci); | 425 | int pc = currentpc(L, ci); |
430 | Instruction i; | 426 | Instruction i; |
@@ -462,7 +458,7 @@ static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos, | |||
462 | 458 | ||
463 | 459 | ||
464 | static Instruction getcurrentinstr (lua_State *L, CallInfo *ci) { | 460 | static Instruction getcurrentinstr (lua_State *L, CallInfo *ci) { |
465 | if (ci == L->base_ci || !isLmark(ci)) | 461 | if (ci == L->base_ci || !isLua(ci)) |
466 | return (Instruction)(-1); /* not an active Lua function */ | 462 | return (Instruction)(-1); /* not an active Lua function */ |
467 | else | 463 | else |
468 | return ci_func(ci)->l.p->code[currentpc(L, ci)]; | 464 | return ci_func(ci)->l.p->code[currentpc(L, ci)]; |
@@ -531,7 +527,7 @@ static void addinfo (lua_State *L, int internal) { | |||
531 | CallInfo *ci = L->ci; | 527 | CallInfo *ci = L->ci; |
532 | if (!internal && ci > L->base_ci) ci--; | 528 | if (!internal && ci > L->base_ci) ci--; |
533 | if (strchr(msg, '\n')) return; /* message already `formatted' */ | 529 | if (strchr(msg, '\n')) return; /* message already `formatted' */ |
534 | if (!isLmark(ci)) { /* no Lua code? */ | 530 | if (!isLua(ci)) { /* no Lua code? */ |
535 | luaO_pushfstring(L, "%s\n", msg); /* no extra info */ | 531 | luaO_pushfstring(L, "%s\n", msg); /* no extra info */ |
536 | } | 532 | } |
537 | else { /* add file:line information */ | 533 | else { /* add file:line information */ |