|
@ -66,11 +66,18 @@ static void traceexec (lua_State *L, lua_Hook linehook) { |
|
|
int *lineinfo = ci_func(ci)->l.p->lineinfo; |
|
|
int *lineinfo = ci_func(ci)->l.p->lineinfo; |
|
|
int pc = cast(int, *ci->pc - ci_func(ci)->l.p->code) - 1; |
|
|
int pc = cast(int, *ci->pc - ci_func(ci)->l.p->code) - 1; |
|
|
int newline; |
|
|
int newline; |
|
|
if (pc == 0) { /* may be first time? */ |
|
|
if (ci->line == -1) return; /* no linehooks for this function */ |
|
|
|
|
|
else if (ci->line == 0) { /* first linehook? */ |
|
|
|
|
|
if (pc == 0) { /* function is starting now? */ |
|
|
ci->line = 1; |
|
|
ci->line = 1; |
|
|
ci->refi = 0; |
|
|
ci->refi = 0; |
|
|
ci->lastpc = pc+1; /* make sure it will call linehook */ |
|
|
ci->lastpc = pc+1; /* make sure it will call linehook */ |
|
|
} |
|
|
} |
|
|
|
|
|
else { /* function started without hooks: */ |
|
|
|
|
|
ci->line = -1; /* keep it that way */ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
newline = luaG_getline(lineinfo, pc, ci->line, &ci->refi); |
|
|
newline = luaG_getline(lineinfo, pc, ci->line, &ci->refi); |
|
|
/* calls linehook when enters a new line or jumps back (loop) */ |
|
|
/* calls linehook when enters a new line or jumps back (loop) */ |
|
|
if (newline != ci->line || pc <= ci->lastpc) { |
|
|
if (newline != ci->line || pc <= ci->lastpc) { |
|
@ -315,7 +322,7 @@ StkId luaV_execute (lua_State *L) { |
|
|
base = L->ci->base; |
|
|
base = L->ci->base; |
|
|
cl = &clvalue(base - 1)->l; |
|
|
cl = &clvalue(base - 1)->l; |
|
|
k = cl->p->k; |
|
|
k = cl->p->k; |
|
|
linehook = L->ci->linehook; |
|
|
linehook = L->linehook; |
|
|
L->ci->pc = &pc; |
|
|
L->ci->pc = &pc; |
|
|
pc = L->ci->savedpc; |
|
|
pc = L->ci->savedpc; |
|
|
L->ci->savedpc = NULL; |
|
|
L->ci->savedpc = NULL; |
|
@ -513,7 +520,6 @@ StkId luaV_execute (lua_State *L) { |
|
|
int nresults; |
|
|
int nresults; |
|
|
lua_assert(ttype(ci->base-1) == LUA_TFUNCTION); |
|
|
lua_assert(ttype(ci->base-1) == LUA_TFUNCTION); |
|
|
base = ci->base; /* restore previous values */ |
|
|
base = ci->base; /* restore previous values */ |
|
|
linehook = ci->linehook; |
|
|
|
|
|
cl = &clvalue(base - 1)->l; |
|
|
cl = &clvalue(base - 1)->l; |
|
|
k = cl->p->k; |
|
|
k = cl->p->k; |
|
|
pc = ci->savedpc; |
|
|
pc = ci->savedpc; |
|
|