aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldebug.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/ldebug.c b/ldebug.c
index 01aab131..b4f7010b 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -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}