diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-11-25 13:27:51 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-11-25 13:27:51 -0200 |
commit | b0f2b288a6b860374b9578d4c51329fc9cd43022 (patch) | |
tree | 82bacf246458c8f97ec22424ff40832df67a52e5 /ldblib.c | |
parent | 2b25489b47ad94e6f970f5d9150937734322f24c (diff) | |
download | lua-b0f2b288a6b860374b9578d4c51329fc9cd43022.tar.gz lua-b0f2b288a6b860374b9578d4c51329fc9cd43022.tar.bz2 lua-b0f2b288a6b860374b9578d4c51329fc9cd43022.zip |
new scheme for debug info about tail calls: no more 'fake' stack entries,
but stack entry knows whether it was tail called
Diffstat (limited to 'ldblib.c')
-rw-r--r-- | ldblib.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.116 2009/11/18 15:50:18 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.117 2009/11/24 12:05:44 roberto Exp roberto $ |
3 | ** Interface from Lua to its debug API | 3 | ** Interface from Lua to its debug API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -100,7 +100,7 @@ static int db_getinfo (lua_State *L) { | |||
100 | lua_Debug ar; | 100 | lua_Debug ar; |
101 | int arg; | 101 | int arg; |
102 | lua_State *L1 = getthread(L, &arg); | 102 | lua_State *L1 = getthread(L, &arg); |
103 | const char *options = luaL_optstring(L, arg+2, "flnSu"); | 103 | const char *options = luaL_optstring(L, arg+2, "flnStu"); |
104 | if (lua_isnumber(L, arg+1)) { | 104 | if (lua_isnumber(L, arg+1)) { |
105 | if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { | 105 | if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { |
106 | lua_pushnil(L); /* level out of range */ | 106 | lua_pushnil(L); /* level out of range */ |
@@ -133,6 +133,10 @@ static int db_getinfo (lua_State *L) { | |||
133 | settabss(L, "name", ar.name); | 133 | settabss(L, "name", ar.name); |
134 | settabss(L, "namewhat", ar.namewhat); | 134 | settabss(L, "namewhat", ar.namewhat); |
135 | } | 135 | } |
136 | if (strchr(options, 't')) { | ||
137 | lua_pushboolean(L, ar.istailcall); | ||
138 | lua_setfield(L, -2, "istailcall"); | ||
139 | } | ||
136 | if (strchr(options, 'L')) | 140 | if (strchr(options, 'L')) |
137 | treatstackoption(L, L1, "activelines"); | 141 | treatstackoption(L, L1, "activelines"); |
138 | if (strchr(options, 'f')) | 142 | if (strchr(options, 'f')) |
@@ -232,7 +236,7 @@ static const char KEY_HOOK = 'h'; | |||
232 | 236 | ||
233 | static void hookf (lua_State *L, lua_Debug *ar) { | 237 | static void hookf (lua_State *L, lua_Debug *ar) { |
234 | static const char *const hooknames[] = | 238 | static const char *const hooknames[] = |
235 | {"call", "return", "line", "count", "tail return"}; | 239 | {"call", "return", "line", "count", "tail call"}; |
236 | lua_pushlightuserdata(L, (void *)&KEY_HOOK); | 240 | lua_pushlightuserdata(L, (void *)&KEY_HOOK); |
237 | lua_rawget(L, LUA_REGISTRYINDEX); | 241 | lua_rawget(L, LUA_REGISTRYINDEX); |
238 | lua_pushlightuserdata(L, L); | 242 | lua_pushlightuserdata(L, L); |