diff options
| -rw-r--r-- | ldebug.c | 10 | ||||
| -rw-r--r-- | ldebug.h | 4 | ||||
| -rw-r--r-- | lstate.h | 3 | ||||
| -rw-r--r-- | lvm.c | 17 |
4 files changed, 18 insertions, 16 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 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldebug.h,v 1.17 2002/03/19 12:45:25 roberto Exp roberto $ | 2 | ** $Id: ldebug.h,v 1.18 2002/03/25 17:47:14 roberto Exp roberto $ |
| 3 | ** Auxiliary functions from Debug Interface module | 3 | ** Auxiliary functions from Debug Interface module |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -12,6 +12,8 @@ | |||
| 12 | #include "luadebug.h" | 12 | #include "luadebug.h" |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) | ||
| 16 | |||
| 15 | void luaG_typeerror (lua_State *L, const TObject *o, const char *opname); | 17 | void luaG_typeerror (lua_State *L, const TObject *o, const char *opname); |
| 16 | void luaG_concaterror (lua_State *L, StkId p1, StkId p2); | 18 | void luaG_concaterror (lua_State *L, StkId p1, StkId p2); |
| 17 | void luaG_aritherror (lua_State *L, StkId p1, const TObject *p2); | 19 | void luaG_aritherror (lua_State *L, StkId p1, const TObject *p2); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstate.h,v 1.80 2002/03/25 17:47:14 roberto Exp roberto $ | 2 | ** $Id: lstate.h,v 1.81 2002/03/26 20:46:10 roberto Exp roberto $ |
| 3 | ** Global State | 3 | ** Global State |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -91,7 +91,6 @@ typedef struct CallInfo { | |||
| 91 | StkId top; /* top for this function (when it's a Lua function) */ | 91 | StkId top; /* top for this function (when it's a Lua function) */ |
| 92 | const Instruction **pc; /* points to `pc' variable in `luaV_execute' */ | 92 | const Instruction **pc; /* points to `pc' variable in `luaV_execute' */ |
| 93 | StkId *pb; /* points to `base' variable in `luaV_execute' */ | 93 | StkId *pb; /* points to `base' variable in `luaV_execute' */ |
| 94 | int lastpc; /* last pc traced */ | ||
| 95 | int yield_results; | 94 | int yield_results; |
| 96 | } CallInfo; | 95 | } CallInfo; |
| 97 | 96 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 1.223 2002/03/25 17:47:14 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.224 2002/04/09 19:47:44 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -64,15 +64,16 @@ int luaV_tostring (lua_State *L, TObject *obj) { | |||
| 64 | 64 | ||
| 65 | static void traceexec (lua_State *L) { | 65 | static void traceexec (lua_State *L) { |
| 66 | CallInfo *ci = L->ci; | 66 | CallInfo *ci = L->ci; |
| 67 | int *lineinfo = ci_func(ci)->l.p->lineinfo; | 67 | Proto *p = ci_func(ci)->l.p; |
| 68 | int pc = cast(int, *ci->pc - ci_func(ci)->l.p->code) - 1; | 68 | int newline = p->lineinfo[pcRel(*ci->pc, p)]; |
| 69 | int newline = lineinfo[pc]; | 69 | if (pcRel(*ci->pc, p) == 0) /* tracing may be starting now? */ |
| 70 | if (pc == 0) /* tracing may be starting now? */ | 70 | ci->savedpc = *ci->pc; /* initialize `savedpc' */ |
| 71 | ci->lastpc = 0; /* initialize `lastpc' */ | ||
| 72 | /* calls linehook when enters a new line or jumps back (loop) */ | 71 | /* calls linehook when enters a new line or jumps back (loop) */ |
| 73 | if (pc <= ci->lastpc || newline != lineinfo[ci->lastpc]) | 72 | if (*ci->pc <= ci->savedpc || newline != p->lineinfo[pcRel(ci->savedpc, p)]) { |
| 74 | luaD_lineHook(L, newline); | 73 | luaD_lineHook(L, newline); |
| 75 | L->ci->lastpc = pc; | 74 | ci = L->ci; /* previous call may reallocate `ci' */ |
| 75 | } | ||
| 76 | ci->savedpc = *ci->pc; | ||
| 76 | } | 77 | } |
| 77 | 78 | ||
| 78 | 79 | ||
