diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-05-03 16:01:17 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-05-03 16:01:17 -0300 |
commit | b320d37a80c6068cf6b7a91cdd8c8bc8bf71e06c (patch) | |
tree | f2e37cb4b7c90913eea3cea8ab8bd7e096fe85cf | |
parent | 9b8d136e1cda86c6292105fb1e92d3b909ce1491 (diff) | |
download | lua-b320d37a80c6068cf6b7a91cdd8c8bc8bf71e06c.tar.gz lua-b320d37a80c6068cf6b7a91cdd8c8bc8bf71e06c.tar.bz2 lua-b320d37a80c6068cf6b7a91cdd8c8bc8bf71e06c.zip |
better tests for correctness of `savedpc'
-rw-r--r-- | ldo.c | 3 | ||||
-rw-r--r-- | ltests.c | 18 | ||||
-rw-r--r-- | ltests.h | 5 |
3 files changed, 22 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 2.21 2005/03/29 16:20:48 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.22 2005/04/05 13:41:29 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -116,6 +116,7 @@ static void correctstack (lua_State *L, TValue *oldstack) { | |||
116 | ci->top = (ci->top - oldstack) + L->stack; | 116 | ci->top = (ci->top - oldstack) + L->stack; |
117 | ci->base = (ci->base - oldstack) + L->stack; | 117 | ci->base = (ci->base - oldstack) + L->stack; |
118 | ci->func = (ci->func - oldstack) + L->stack; | 118 | ci->func = (ci->func - oldstack) + L->stack; |
119 | lua_assert(lua_checkpc(L, ci)); | ||
119 | } | 120 | } |
120 | L->base = L->ci->base; | 121 | L->base = L->ci->base; |
121 | } | 122 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.22 2005/03/23 17:51:11 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.23 2005/03/28 17:17:53 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -281,8 +281,10 @@ static void checkstack (global_State *g, lua_State *L1) { | |||
281 | } | 281 | } |
282 | checkliveness(g, gt(L1)); | 282 | checkliveness(g, gt(L1)); |
283 | if (L1->base_ci) { | 283 | if (L1->base_ci) { |
284 | for (ci = L1->base_ci; ci <= L1->ci; ci++) | 284 | for (ci = L1->base_ci; ci <= L1->ci; ci++) { |
285 | lua_assert(ci->top <= L1->stack_last); | 285 | lua_assert(ci->top <= L1->stack_last); |
286 | lua_assert(lua_checkpc(L1, ci)); | ||
287 | } | ||
286 | } | 288 | } |
287 | else lua_assert(L1->size_ci == 0); | 289 | else lua_assert(L1->size_ci == 0); |
288 | if (L1->stack) { | 290 | if (L1->stack) { |
@@ -337,6 +339,18 @@ printf(">>> %d %s %02x\n", g->gcstate, luaT_typenames[o->gch.tt], o->gch.marke | |||
337 | } | 339 | } |
338 | 340 | ||
339 | 341 | ||
342 | int lua_checkpc (lua_State *L, pCallInfo ci) { | ||
343 | if (ci == L->base_ci || !f_isLua(ci)) return 1; | ||
344 | else { | ||
345 | Proto *p = ci_func(ci)->l.p; | ||
346 | if (ci < L->ci) | ||
347 | return p->code <= ci->savedpc && ci->savedpc <= p->code + p->sizecode; | ||
348 | else | ||
349 | return p->code <= L->savedpc && L->savedpc <= p->code + p->sizecode; | ||
350 | } | ||
351 | } | ||
352 | |||
353 | |||
340 | int lua_checkmemory (lua_State *L) { | 354 | int lua_checkmemory (lua_State *L) { |
341 | global_State *g = G(L); | 355 | global_State *g = G(L); |
342 | GCObject *o; | 356 | GCObject *o; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.h,v 2.12 2005/03/18 18:55:45 roberto Exp roberto $ | 2 | ** $Id: ltests.h,v 2.13 2005/04/13 17:24:20 roberto Exp roberto $ |
3 | ** Internal Header for Debugging of the Lua Implementation | 3 | ** Internal Header for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -47,7 +47,10 @@ void *debug_realloc (void *ud, void *block, size_t osize, size_t nsize); | |||
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | 49 | ||
50 | typedef struct CallInfo *pCallInfo; | ||
51 | |||
50 | int lua_checkmemory (lua_State *L); | 52 | int lua_checkmemory (lua_State *L); |
53 | int lua_checkpc (lua_State *L, pCallInfo ci); | ||
51 | 54 | ||
52 | 55 | ||
53 | /* test for lock/unlock */ | 56 | /* test for lock/unlock */ |