diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-10-11 17:24:42 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-10-11 17:24:42 -0300 |
| commit | cd0ebd0a802c55d1f16796d2fbb4a6623a6fda57 (patch) | |
| tree | f7933cd468ce57acc45db2490ba7cc2046d8c4fe | |
| parent | 8bc33a088c99c21493dee173fb394003f3331454 (diff) | |
| download | lua-cd0ebd0a802c55d1f16796d2fbb4a6623a6fda57.tar.gz lua-cd0ebd0a802c55d1f16796d2fbb4a6623a6fda57.tar.bz2 lua-cd0ebd0a802c55d1f16796d2fbb4a6623a6fda57.zip | |
'proto->source' may be NULL (if dump strips debug information)
| -rw-r--r-- | ldebug.c | 16 |
1 files changed, 11 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldebug.c,v 2.72 2010/06/21 16:30:12 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.73 2010/09/07 19:21:39 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 | */ |
| @@ -160,9 +160,10 @@ static void funcinfo (lua_Debug *ar, Closure *cl) { | |||
| 160 | ar->what = "C"; | 160 | ar->what = "C"; |
| 161 | } | 161 | } |
| 162 | else { | 162 | else { |
| 163 | ar->source = getstr(cl->l.p->source); | 163 | Proto *p = cl->l.p; |
| 164 | ar->linedefined = cl->l.p->linedefined; | 164 | ar->source = p->source ? getstr(p->source) : "=?"; |
| 165 | ar->lastlinedefined = cl->l.p->lastlinedefined; | 165 | ar->linedefined = p->linedefined; |
| 166 | ar->lastlinedefined = p->lastlinedefined; | ||
| 166 | ar->what = (ar->linedefined == 0) ? "main" : "Lua"; | 167 | ar->what = (ar->linedefined == 0) ? "main" : "Lua"; |
| 167 | } | 168 | } |
| 168 | luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); | 169 | luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); |
| @@ -496,7 +497,12 @@ static void addinfo (lua_State *L, const char *msg) { | |||
| 496 | if (isLua(ci)) { /* is Lua code? */ | 497 | if (isLua(ci)) { /* is Lua code? */ |
| 497 | char buff[LUA_IDSIZE]; /* add file:line information */ | 498 | char buff[LUA_IDSIZE]; /* add file:line information */ |
| 498 | int line = currentline(ci); | 499 | int line = currentline(ci); |
| 499 | luaO_chunkid(buff, getstr(ci_func(ci)->l.p->source), LUA_IDSIZE); | 500 | TString *src = ci_func(ci)->l.p->source; |
| 501 | if (src) | ||
| 502 | luaO_chunkid(buff, getstr(src), LUA_IDSIZE); | ||
| 503 | else { /* no source available; use "?" instead */ | ||
| 504 | buff[0] = '?'; buff[1] = '\0'; | ||
| 505 | } | ||
| 500 | luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); | 506 | luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); |
| 501 | } | 507 | } |
| 502 | } | 508 | } |
