diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-11-26 13:34:15 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-11-26 13:34:15 -0200 |
| commit | 19a6c3874551719f0fab72465339e6d46148396f (patch) | |
| tree | 6c57f0a2056ae4729e197e9a9e905f8c3074f7d5 /ldebug.c | |
| parent | 3c4d970a7b0adf9ef1cb7e6ec81dc9d9e99bfcbf (diff) | |
| download | lua-19a6c3874551719f0fab72465339e6d46148396f.tar.gz lua-19a6c3874551719f0fab72465339e6d46148396f.tar.bz2 lua-19a6c3874551719f0fab72465339e6d46148396f.zip | |
detail in 'currentpc' (only needs to work for Lua functions)
Diffstat (limited to 'ldebug.c')
| -rw-r--r-- | ldebug.c | 12 |
1 files changed, 4 insertions, 8 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldebug.c,v 2.57 2009/10/13 19:07:40 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.58 2009/11/25 15:27: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 | */ |
| @@ -34,17 +34,13 @@ static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); | |||
| 34 | 34 | ||
| 35 | 35 | ||
| 36 | static int currentpc (CallInfo *ci) { | 36 | static int currentpc (CallInfo *ci) { |
| 37 | if (!isLua(ci)) return -1; /* function is not a Lua function? */ | 37 | lua_assert(isLua(ci)); |
| 38 | return pcRel(ci->u.l.savedpc, ci_func(ci)->l.p); | 38 | return pcRel(ci->u.l.savedpc, ci_func(ci)->l.p); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | 41 | ||
| 42 | static int currentline (CallInfo *ci) { | 42 | static int currentline (CallInfo *ci) { |
| 43 | int pc = currentpc(ci); | 43 | return getfuncline(ci_func(ci)->l.p, currentpc(ci)); |
| 44 | if (pc < 0) | ||
| 45 | return -1; /* only active lua functions have current-line information */ | ||
| 46 | else | ||
| 47 | return getfuncline(ci_func(ci)->l.p, pc); | ||
| 48 | } | 44 | } |
| 49 | 45 | ||
| 50 | 46 | ||
| @@ -187,7 +183,7 @@ static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, | |||
| 187 | break; | 183 | break; |
| 188 | } | 184 | } |
| 189 | case 'l': { | 185 | case 'l': { |
| 190 | ar->currentline = (ci) ? currentline(ci) : -1; | 186 | ar->currentline = (ci && isLua(ci)) ? currentline(ci) : -1; |
| 191 | break; | 187 | break; |
| 192 | } | 188 | } |
| 193 | case 'u': { | 189 | case 'u': { |
