aboutsummaryrefslogtreecommitdiff
path: root/ldebug.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldebug.c')
-rw-r--r--ldebug.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/ldebug.c b/ldebug.c
index 89b36f07..7323f23a 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 2.142 2017/11/08 14:50:23 roberto Exp roberto $ 2** $Id: ldebug.c,v 2.143 2017/11/13 12:20:51 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*/
@@ -107,7 +107,24 @@ static int currentline (CallInfo *ci) {
107 107
108 108
109/* 109/*
110** This function can be called asynchronously (e.g. during a signal). 110** This function can be called asynchronously (e.g. during a signal),
111** under "reasonable" assumptions. A new 'ci' is completely linked
112** in the list before it becomes part of the "active" list, and
113** we assume that pointers are atomic (see comment in next function).
114** (If we traverse one more item, there is no problem. If we traverse
115** one less item, the worst that can happen is that the signal will
116** not interrupt the script.)
117*/
118static void settraps (CallInfo *ci) {
119 for (; ci != NULL; ci = ci->previous)
120 if (isLua(ci))
121 ci->u.l.trap = 1;
122}
123
124
125/*
126** This function can be called asynchronously (e.g. during a signal),
127** under "reasonable" assumptions.
111** Fields 'oldpc', 'basehookcount', and 'hookcount' (set by 128** Fields 'oldpc', 'basehookcount', and 'hookcount' (set by
112** 'resethookcount') are for debug only, and it is no problem if they 129** 'resethookcount') are for debug only, and it is no problem if they
113** get arbitrary values (causes at most one wrong hook call). 'hookmask' 130** get arbitrary values (causes at most one wrong hook call). 'hookmask'
@@ -126,6 +143,8 @@ LUA_API void lua_sethook (lua_State *L, lua_Hook func, int mask, int count) {
126 L->basehookcount = count; 143 L->basehookcount = count;
127 resethookcount(L); 144 resethookcount(L);
128 L->hookmask = cast_byte(mask); 145 L->hookmask = cast_byte(mask);
146 if (mask & (LUA_MASKLINE | LUA_MASKCOUNT))
147 settraps(L->ci); /* to trace inside 'luaV_execute' */
129} 148}
130 149
131 150