commit f52f357a5576aad0794e4c46b86bba5c75ddcf3d
parent 79fee990241bc29c9306d7cee655653ff88b3d0c
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 7 Jul 2003 10:37:34 -0300
correct handling when a thread turns on line hooks in another thread
Diffstat:
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/lvm.c b/lvm.c
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.c,v 1.286 2003/05/13 20:15:59 roberto Exp roberto $
+** $Id: lvm.c,v 1.287 2003/05/14 12:09:12 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -76,13 +76,15 @@ static void traceexec (lua_State *L) {
if (mask & LUA_MASKLINE) {
CallInfo *ci = L->ci;
Proto *p = ci_func(ci)->l.p;
- int newline = getline(p, pcRel(*ci->u.l.pc, p));
+ int pc = pcRel(*ci->u.l.pc, p);
+ int newline = getline(p, pc);
if (!L->hookinit) {
luaG_inithooks(L);
- return;
+ if (pc != 0) /* not function start? */
+ return; /* begin tracing on next line */
}
lua_assert(ci->state & CI_HASFRAME);
- if (pcRel(*ci->u.l.pc, p) == 0) /* tracing may be starting now? */
+ if (pc == 0) /* function may be starting now? */
ci->u.l.savedpc = *ci->u.l.pc; /* initialize `savedpc' */
/* calls linehook when enters a new line or jumps back (loop) */
if (*ci->u.l.pc <= ci->u.l.savedpc ||