aboutsummaryrefslogtreecommitdiff
path: root/ldebug.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 /ldebug.c
parentd2d24f09713cfecf59a7688c45a3863a35f09254 (diff)
downloadlua-39b2d58c39fd0cd554b27ed071926bc439338964.tar.gz
lua-39b2d58c39fd0cd554b27ed071926bc439338964.tar.bz2
lua-39b2d58c39fd0cd554b27ed071926bc439338964.zip
new interface for debug hooks
Diffstat (limited to 'ldebug.c')
-rw-r--r--ldebug.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/ldebug.c b/ldebug.c
index 5123f77d..73029a5d 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.122 2002/06/20 20:39:44 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.123 2002/06/24 15:07:21 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*/
@@ -53,26 +53,31 @@ static int currentline (lua_State *L, CallInfo *ci) {
53} 53}
54 54
55 55
56LUA_API lua_Hook lua_setcallhook (lua_State *L, lua_Hook func) { 56LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask) {
57 lua_Hook oldhook;
58 lua_lock(L);
59 oldhook = L->callhook;
60 L->callhook = func;
61 lua_unlock(L);
62 return oldhook;
63}
64
65
66LUA_API lua_Hook lua_setlinehook (lua_State *L, lua_Hook func) {
67 CallInfo *ci; 57 CallInfo *ci;
68 lua_Hook oldhook; 58 int allow;
69 lua_lock(L); 59 lua_lock(L);
70 oldhook = L->linehook; 60 allow = allowhook(L);
71 L->linehook = func; 61 if (func == NULL) mask = 0;
62 else if (mask == 0) func = NULL;
63 L->hook = func;
64 L->hookmask = mask;
65 setallowhook(L, allow);
66 resethookcount(L);
72 for (ci = L->base_ci; ci <= L->ci; ci++) 67 for (ci = L->base_ci; ci <= L->ci; ci++)
73 currentpc(L, ci); /* update `savedpc' */ 68 currentpc(L, ci); /* update `savedpc' */
74 lua_unlock(L); 69 lua_unlock(L);
75 return oldhook; 70 return 1;
71}
72
73
74LUA_API lua_Hook lua_gethook (lua_State *L) {
75 return L->hook;
76}
77
78
79LUA_API int lua_gethookmask (lua_State *L) {
80 return L->hookmask;
76} 81}
77 82
78 83
@@ -396,6 +401,10 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int reg) {
396 return pt->code[last]; 401 return pt->code[last];
397} 402}
398 403
404#undef check
405#undef checkjump
406#undef checkreg
407
399/* }====================================================== */ 408/* }====================================================== */
400 409
401 410