summaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-07-08 15:21:33 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-07-08 15:21:33 -0300
commit39b2d58c39fd0cd554b27ed071926bc439338964 (patch)
tree6855ede1b0e908439476e54396f94ae9ad275269 /lvm.c
parentd2d24f09713cfecf59a7688c45a3863a35f09254 (diff)
downloadlua-39b2d58c39fd0cd554b27ed071926bc439338964.tar.gz
lua-39b2d58c39fd0cd554b27ed071926bc439338964.tar.bz2
lua-39b2d58c39fd0cd554b27ed071926bc439338964.zip
new interface for debug hooks
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/lvm.c b/lvm.c
index 0e643f7f..20674c61 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.243 2002/06/24 15:07:21 roberto Exp roberto $ 2** $Id: lvm.c,v 1.244 2002/07/05 18:27:39 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*/
@@ -69,17 +69,28 @@ int luaV_tostring (lua_State *L, TObject *obj) {
69 69
70 70
71static void traceexec (lua_State *L) { 71static void traceexec (lua_State *L) {
72 CallInfo *ci = L->ci; 72 int mask = L->hookmask;
73 Proto *p = ci_func(ci)->l.p; 73 if (mask >= LUA_MASKCOUNT) { /* instruction hook set? */
74 int newline = getline(p, pcRel(*ci->pc, p)); 74 if (L->hookcount == 0) {
75 if (pcRel(*ci->pc, p) == 0) /* tracing may be starting now? */ 75 luaD_callhook(L, LUA_HOOKCOUNT, -1);
76 ci->savedpc = *ci->pc; /* initialize `savedpc' */ 76 resethookcount(L);
77 /* calls linehook when enters a new line or jumps back (loop) */ 77 return;
78 if (*ci->pc <= ci->savedpc || newline != getline(p, pcRel(ci->savedpc, p))) { 78 }
79 luaD_lineHook(L, newline); 79 }
80 ci = L->ci; /* previous call may reallocate `ci' */ 80 if (mask & LUA_MASKLINE) {
81 CallInfo *ci = L->ci;
82 Proto *p = ci_func(ci)->l.p;
83 int newline = getline(p, pcRel(*ci->pc, p));
84 if (pcRel(*ci->pc, p) == 0) /* tracing may be starting now? */
85 ci->savedpc = *ci->pc; /* initialize `savedpc' */
86 /* calls linehook when enters a new line or jumps back (loop) */
87 if (*ci->pc <= ci->savedpc ||
88 newline != getline(p, pcRel(ci->savedpc, p))) {
89 luaD_callhook(L, LUA_HOOKLINE, newline);
90 ci = L->ci; /* previous call may reallocate `ci' */
91 }
92 ci->savedpc = *ci->pc;
81 } 93 }
82 ci->savedpc = *ci->pc;
83} 94}
84 95
85 96
@@ -370,8 +381,9 @@ StkId luaV_execute (lua_State *L) {
370 for (;;) { 381 for (;;) {
371 const Instruction i = *pc++; 382 const Instruction i = *pc++;
372 StkId ra; 383 StkId ra;
373 if (L->linehook) 384 if (L->hookmask >= LUA_MASKLINE &&
374 traceexec(L); 385 (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE))
386 traceexec(L);
375 ra = RA(i); 387 ra = RA(i);
376 lua_assert(L->top <= L->stack + L->stacksize && L->top >= L->ci->base); 388 lua_assert(L->top <= L->stack + L->stacksize && L->top >= L->ci->base);
377 lua_assert(L->top == L->ci->top || 389 lua_assert(L->top == L->ci->top ||