diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-04-10 09:11:07 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-04-10 09:11:07 -0300 |
commit | 6c7334a9ac4b424a4fd52bfeb4d674bc7cfa4eb3 (patch) | |
tree | f6e3f9fb0bdbf3169426798b12391f8355d52432 /ldebug.c | |
parent | 8e1e61860643baeb443efcdbf51bc25b0c006a88 (diff) | |
download | lua-6c7334a9ac4b424a4fd52bfeb4d674bc7cfa4eb3.tar.gz lua-6c7334a9ac4b424a4fd52bfeb4d674bc7cfa4eb3.tar.bz2 lua-6c7334a9ac4b424a4fd52bfeb4d674bc7cfa4eb3.zip |
line trace uses `savedpc' to save last `pc' seen
Diffstat (limited to 'ldebug.c')
-rw-r--r-- | ldebug.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.106 2002/04/04 17:21:31 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.107 2002/04/09 19:47:44 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 | */ |
@@ -37,9 +37,9 @@ static int isLmark (CallInfo *ci) { | |||
37 | static int currentpc (lua_State *L, CallInfo *ci) { | 37 | static int currentpc (lua_State *L, CallInfo *ci) { |
38 | if (ci->pc == NULL) return -1; /* function is not an active Lua function */ | 38 | if (ci->pc == NULL) return -1; /* function is not an active Lua function */ |
39 | if (ci == L->ci || ci->pc != (ci+1)->pc) /* no other function using `pc'? */ | 39 | if (ci == L->ci || ci->pc != (ci+1)->pc) /* no other function using `pc'? */ |
40 | return (*ci->pc - ci_func(ci)->l.p->code) - 1; | 40 | ci->savedpc = *ci->pc; /* may not be saved; save it */ |
41 | else /* function's pc is saved */ | 41 | /* function's pc is saved */ |
42 | return (ci->savedpc - ci_func(ci)->l.p->code) - 1; | 42 | return pcRel(ci->savedpc, ci_func(ci)->l.p); |
43 | } | 43 | } |
44 | 44 | ||
45 | 45 | ||
@@ -69,7 +69,7 @@ LUA_API lua_Hook lua_setlinehook (lua_State *L, lua_Hook func) { | |||
69 | oldhook = L->linehook; | 69 | oldhook = L->linehook; |
70 | L->linehook = func; | 70 | L->linehook = func; |
71 | for (ci = L->base_ci; ci <= L->ci; ci++) | 71 | for (ci = L->base_ci; ci <= L->ci; ci++) |
72 | ci->lastpc = currentpc(L, ci); | 72 | currentpc(L, ci); /* update `savedpc' */ |
73 | lua_unlock(L); | 73 | lua_unlock(L); |
74 | return oldhook; | 74 | return oldhook; |
75 | } | 75 | } |