diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-07-16 17:49:02 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-07-16 17:49:02 -0300 |
commit | fa26d294aef136aa4ec48c23b4b87b853df0e3da (patch) | |
tree | f8ccce58fe28fbc116f082766eecf3a50812c82d /ldebug.c | |
parent | 5a761e3a1519eae7264209db8257b040c77556aa (diff) | |
download | lua-fa26d294aef136aa4ec48c23b4b87b853df0e3da.tar.gz lua-fa26d294aef136aa4ec48c23b4b87b853df0e3da.tar.bz2 lua-fa26d294aef136aa4ec48c23b4b87b853df0e3da.zip |
new way to control `pc' of running functions
Diffstat (limited to 'ldebug.c')
-rw-r--r-- | ldebug.c | 19 |
1 files changed, 2 insertions, 17 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.153 2003/05/14 12:09:12 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.154 2003/07/10 11:59:06 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 | */ |
@@ -30,14 +30,8 @@ | |||
30 | static const char *getfuncname (CallInfo *ci, const char **name); | 30 | static const char *getfuncname (CallInfo *ci, const char **name); |
31 | 31 | ||
32 | 32 | ||
33 | #define isLua(ci) (!((ci)->state & CI_C)) | ||
34 | |||
35 | |||
36 | static int currentpc (CallInfo *ci) { | 33 | static int currentpc (CallInfo *ci) { |
37 | if (!isLua(ci)) return -1; /* function is not a Lua function? */ | 34 | if (!isLua(ci)) return -1; /* function is not a Lua function? */ |
38 | if (ci->state & CI_HASFRAME) /* function has a frame? */ | ||
39 | ci->u.l.savedpc = *ci->u.l.pc; /* use `pc' from there */ | ||
40 | /* function's pc is saved */ | ||
41 | return pcRel(ci->u.l.savedpc, ci_func(ci)->l.p); | 35 | return pcRel(ci->u.l.savedpc, ci_func(ci)->l.p); |
42 | } | 36 | } |
43 | 37 | ||
@@ -51,14 +45,6 @@ static int currentline (CallInfo *ci) { | |||
51 | } | 45 | } |
52 | 46 | ||
53 | 47 | ||
54 | void luaG_inithooks (lua_State *L) { | ||
55 | CallInfo *ci; | ||
56 | for (ci = L->ci; ci != L->base_ci; ci--) /* update all `savedpc's */ | ||
57 | currentpc(ci); | ||
58 | L->hookinit = 1; | ||
59 | } | ||
60 | |||
61 | |||
62 | /* | 48 | /* |
63 | ** this function can be called asynchronous (e.g. during a signal) | 49 | ** this function can be called asynchronous (e.g. during a signal) |
64 | */ | 50 | */ |
@@ -71,7 +57,6 @@ LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { | |||
71 | L->basehookcount = count; | 57 | L->basehookcount = count; |
72 | resethookcount(L); | 58 | resethookcount(L); |
73 | L->hookmask = cast(lu_byte, mask); | 59 | L->hookmask = cast(lu_byte, mask); |
74 | L->hookinit = 0; | ||
75 | return 1; | 60 | return 1; |
76 | } | 61 | } |
77 | 62 | ||
@@ -97,7 +82,7 @@ LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { | |||
97 | lua_lock(L); | 82 | lua_lock(L); |
98 | for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) { | 83 | for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) { |
99 | level--; | 84 | level--; |
100 | if (!(ci->state & CI_C)) /* Lua function? */ | 85 | if (f_isLua(ci)) /* Lua function? */ |
101 | level -= ci->u.l.tailcalls; /* skip lost tail calls */ | 86 | level -= ci->u.l.tailcalls; /* skip lost tail calls */ |
102 | } | 87 | } |
103 | if (level > 0 || ci == L->base_ci) status = 0; /* there is no such level */ | 88 | if (level > 0 || ci == L->base_ci) status = 0; /* there is no such level */ |