diff options
Diffstat (limited to 'ldebug.c')
-rw-r--r-- | ldebug.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 2.135 2017/11/02 11:28:56 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.136 2017/11/03 12:12:30 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 | */ |
@@ -44,7 +44,7 @@ static const char *funcnamefromcode (lua_State *L, CallInfo *ci, | |||
44 | 44 | ||
45 | static int currentpc (CallInfo *ci) { | 45 | static int currentpc (CallInfo *ci) { |
46 | lua_assert(isLua(ci->func)); | 46 | lua_assert(isLua(ci->func)); |
47 | return pcRel(ci->u.l.savedpc, ci_func(ci)->p); | 47 | return pcRel(ci->func->stkci.u.l.savedpc, ci_func(ci)->p); |
48 | } | 48 | } |
49 | 49 | ||
50 | 50 | ||
@@ -121,7 +121,7 @@ LUA_API void lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { | |||
121 | func = NULL; | 121 | func = NULL; |
122 | } | 122 | } |
123 | if (isLua(L->func)) | 123 | if (isLua(L->func)) |
124 | L->oldpc = L->ci->u.l.savedpc; | 124 | L->oldpc = L->func->stkci.u.l.savedpc; |
125 | L->hook = func; | 125 | L->hook = func; |
126 | L->basehookcount = count; | 126 | L->basehookcount = count; |
127 | resethookcount(L); | 127 | resethookcount(L); |
@@ -755,19 +755,21 @@ void luaG_traceexec (lua_State *L) { | |||
755 | luaD_hook(L, LUA_HOOKCOUNT, -1); /* call count hook */ | 755 | luaD_hook(L, LUA_HOOKCOUNT, -1); /* call count hook */ |
756 | if (mask & LUA_MASKLINE) { | 756 | if (mask & LUA_MASKLINE) { |
757 | Proto *p = ci_func(ci)->p; | 757 | Proto *p = ci_func(ci)->p; |
758 | int npc = pcRel(ci->u.l.savedpc, p); | 758 | int npc = pcRel(func->stkci.u.l.savedpc, p); |
759 | if (npc == 0 || /* call linehook when enter a new function, */ | 759 | if (npc == 0 || /* call linehook when enter a new function, */ |
760 | ci->u.l.savedpc <= L->oldpc || /* when jump back (loop), or when */ | 760 | func->stkci.u.l.savedpc <= L->oldpc || /* when jump back (loop), */ |
761 | changedline(p, pcRel(L->oldpc, p), npc)) { /* enter new line */ | 761 | changedline(p, pcRel(L->oldpc, p), npc)) { /* when enter new line */ |
762 | int newline = luaG_getfuncline(p, npc); /* new line */ | 762 | int newline = luaG_getfuncline(p, npc); /* new line */ |
763 | luaD_hook(L, LUA_HOOKLINE, newline); /* call line hook */ | 763 | luaD_hook(L, LUA_HOOKLINE, newline); /* call line hook */ |
764 | } | 764 | } |
765 | } | 765 | } |
766 | L->oldpc = ci->u.l.savedpc; | 766 | func = L->func; /* previous calls can reallocate stack */ |
767 | L->oldpc = func->stkci.u.l.savedpc; | ||
767 | if (L->status == LUA_YIELD) { /* did hook yield? */ | 768 | if (L->status == LUA_YIELD) { /* did hook yield? */ |
768 | if (counthook) | 769 | if (counthook) |
769 | L->hookcount = 1; /* undo decrement to zero */ | 770 | L->hookcount = 1; /* undo decrement to zero */ |
770 | ci->u.l.savedpc--; /* undo increment (resume will increment it again) */ | 771 | /* undo increment (resume will increment it again) */ |
772 | func->stkci.u.l.savedpc--; | ||
771 | callstatus(func) |= CIST_HOOKYIELD; /* mark that it yielded */ | 773 | callstatus(func) |= CIST_HOOKYIELD; /* mark that it yielded */ |
772 | luaD_throw(L, LUA_YIELD); | 774 | luaD_throw(L, LUA_YIELD); |
773 | } | 775 | } |