summaryrefslogtreecommitdiff
path: root/ldebug.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-11-13 13:36:52 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-11-13 13:36:52 -0200
commit5440b42f434ecb6fe7a8e0d19fb8e8baf82e90b7 (patch)
tree6a54560da88065db590bf439c7af64fea88334bb /ldebug.c
parent7d4828cc9fdc982ec713922777e77240892474e8 (diff)
downloadlua-5440b42f434ecb6fe7a8e0d19fb8e8baf82e90b7.tar.gz
lua-5440b42f434ecb6fe7a8e0d19fb8e8baf82e90b7.tar.bz2
lua-5440b42f434ecb6fe7a8e0d19fb8e8baf82e90b7.zip
using 'trap' to stop 'luaV_execute' when necessary (tracing and
to update its copy of 'base' when the stack is reallocated)
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