diff options
Diffstat (limited to 'ldebug.c')
-rw-r--r-- | ldebug.c | 25 |
1 files changed, 1 insertions, 24 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 2.133 2017/10/31 17:14:02 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.134 2017/11/01 18:20:48 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 | */ |
@@ -107,22 +107,6 @@ static int currentline (CallInfo *ci) { | |||
107 | 107 | ||
108 | 108 | ||
109 | /* | 109 | /* |
110 | ** If function yielded, its 'func' can be in the 'extra' field. The | ||
111 | ** next function restores 'func' to its correct value for debugging | ||
112 | ** purposes. (It exchanges 'func' and 'extra'; so, when called again, | ||
113 | ** after debugging, it also "re-restores" ** 'func' to its altered value. | ||
114 | */ | ||
115 | static void swapextra (lua_State *L) { | ||
116 | if (L->status == LUA_YIELD) { | ||
117 | CallInfo *ci = L->ci; /* get function that yielded */ | ||
118 | StkId temp = ci->func; /* exchange its 'func' and 'extra' values */ | ||
119 | L->func = ci->func = restorestack(L, ci->extra); | ||
120 | ci->extra = savestack(L, temp); | ||
121 | } | ||
122 | } | ||
123 | |||
124 | |||
125 | /* | ||
126 | ** This function can be called asynchronously (e.g. during a signal). | 110 | ** This function can be called asynchronously (e.g. during a signal). |
127 | ** Fields 'oldpc', 'basehookcount', and 'hookcount' (set by | 111 | ** Fields 'oldpc', 'basehookcount', and 'hookcount' (set by |
128 | ** 'resethookcount') are for debug only, and it is no problem if they | 112 | ** 'resethookcount') are for debug only, and it is no problem if they |
@@ -209,7 +193,6 @@ static const char *findlocal (lua_State *L, CallInfo *ci, int n, | |||
209 | LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { | 193 | LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { |
210 | const char *name; | 194 | const char *name; |
211 | lua_lock(L); | 195 | lua_lock(L); |
212 | swapextra(L); | ||
213 | if (ar == NULL) { /* information about non-active function? */ | 196 | if (ar == NULL) { /* information about non-active function? */ |
214 | if (!isLfunction(s2v(L->top - 1))) /* not a Lua function? */ | 197 | if (!isLfunction(s2v(L->top - 1))) /* not a Lua function? */ |
215 | name = NULL; | 198 | name = NULL; |
@@ -224,7 +207,6 @@ LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
224 | api_incr_top(L); | 207 | api_incr_top(L); |
225 | } | 208 | } |
226 | } | 209 | } |
227 | swapextra(L); | ||
228 | lua_unlock(L); | 210 | lua_unlock(L); |
229 | return name; | 211 | return name; |
230 | } | 212 | } |
@@ -234,13 +216,11 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
234 | StkId pos = NULL; /* to avoid warnings */ | 216 | StkId pos = NULL; /* to avoid warnings */ |
235 | const char *name; | 217 | const char *name; |
236 | lua_lock(L); | 218 | lua_lock(L); |
237 | swapextra(L); | ||
238 | name = findlocal(L, ar->i_ci, n, &pos); | 219 | name = findlocal(L, ar->i_ci, n, &pos); |
239 | if (name) { | 220 | if (name) { |
240 | setobjs2s(L, pos, L->top - 1); | 221 | setobjs2s(L, pos, L->top - 1); |
241 | L->top--; /* pop value */ | 222 | L->top--; /* pop value */ |
242 | } | 223 | } |
243 | swapextra(L); | ||
244 | lua_unlock(L); | 224 | lua_unlock(L); |
245 | return name; | 225 | return name; |
246 | } | 226 | } |
@@ -361,7 +341,6 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { | |||
361 | CallInfo *ci; | 341 | CallInfo *ci; |
362 | TValue *func; | 342 | TValue *func; |
363 | lua_lock(L); | 343 | lua_lock(L); |
364 | swapextra(L); | ||
365 | if (*what == '>') { | 344 | if (*what == '>') { |
366 | ci = NULL; | 345 | ci = NULL; |
367 | func = s2v(L->top - 1); | 346 | func = s2v(L->top - 1); |
@@ -380,7 +359,6 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { | |||
380 | setobj2s(L, L->top, func); | 359 | setobj2s(L, L->top, func); |
381 | api_incr_top(L); | 360 | api_incr_top(L); |
382 | } | 361 | } |
383 | swapextra(L); /* correct before option 'L', which can raise a mem. error */ | ||
384 | if (strchr(what, 'L')) | 362 | if (strchr(what, 'L')) |
385 | collectvalidlines(L, cl); | 363 | collectvalidlines(L, cl); |
386 | lua_unlock(L); | 364 | lua_unlock(L); |
@@ -790,7 +768,6 @@ void luaG_traceexec (lua_State *L) { | |||
790 | L->hookcount = 1; /* undo decrement to zero */ | 768 | L->hookcount = 1; /* undo decrement to zero */ |
791 | ci->u.l.savedpc--; /* undo increment (resume will increment it again) */ | 769 | ci->u.l.savedpc--; /* undo increment (resume will increment it again) */ |
792 | ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */ | 770 | ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */ |
793 | L->func = ci->func = L->top - 1; /* protect stack below results */ | ||
794 | luaD_throw(L, LUA_YIELD); | 771 | luaD_throw(L, LUA_YIELD); |
795 | } | 772 | } |
796 | } | 773 | } |