aboutsummaryrefslogtreecommitdiff
path: root/src/lj_debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_debug.c')
-rw-r--r--src/lj_debug.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/lj_debug.c b/src/lj_debug.c
index be7fb2b1..ec56b7d2 100644
--- a/src/lj_debug.c
+++ b/src/lj_debug.c
@@ -321,7 +321,7 @@ const char *lj_debug_funcname(lua_State *L, TValue *frame, const char **name)
321/* -- Source code locations ----------------------------------------------- */ 321/* -- Source code locations ----------------------------------------------- */
322 322
323/* Generate shortened source name. */ 323/* Generate shortened source name. */
324void lj_debug_shortname(char *out, GCstr *str) 324void lj_debug_shortname(char *out, GCstr *str, BCLine line)
325{ 325{
326 const char *src = strdata(str); 326 const char *src = strdata(str);
327 if (*src == '=') { 327 if (*src == '=') {
@@ -335,11 +335,11 @@ void lj_debug_shortname(char *out, GCstr *str)
335 *out++ = '.'; *out++ = '.'; *out++ = '.'; 335 *out++ = '.'; *out++ = '.'; *out++ = '.';
336 } 336 }
337 strcpy(out, src); 337 strcpy(out, src);
338 } else { /* Output [string "string"]. */ 338 } else { /* Output [string "string"] or [builtin:name]. */
339 size_t len; /* Length, up to first control char. */ 339 size_t len; /* Length, up to first control char. */
340 for (len = 0; len < LUA_IDSIZE-12; len++) 340 for (len = 0; len < LUA_IDSIZE-12; len++)
341 if (((const unsigned char *)src)[len] < ' ') break; 341 if (((const unsigned char *)src)[len] < ' ') break;
342 strcpy(out, "[string \""); out += 9; 342 strcpy(out, line == ~(BCLine)0 ? "[builtin:" : "[string \""); out += 9;
343 if (src[len] != '\0') { /* Must truncate? */ 343 if (src[len] != '\0') { /* Must truncate? */
344 if (len > LUA_IDSIZE-15) len = LUA_IDSIZE-15; 344 if (len > LUA_IDSIZE-15) len = LUA_IDSIZE-15;
345 strncpy(out, src, len); out += len; 345 strncpy(out, src, len); out += len;
@@ -347,7 +347,7 @@ void lj_debug_shortname(char *out, GCstr *str)
347 } else { 347 } else {
348 strcpy(out, src); out += len; 348 strcpy(out, src); out += len;
349 } 349 }
350 strcpy(out, "\"]"); 350 strcpy(out, line == ~(BCLine)0 ? "]" : "\"]");
351 } 351 }
352} 352}
353 353
@@ -360,8 +360,9 @@ void lj_debug_addloc(lua_State *L, const char *msg,
360 if (isluafunc(fn)) { 360 if (isluafunc(fn)) {
361 BCLine line = debug_frameline(L, fn, nextframe); 361 BCLine line = debug_frameline(L, fn, nextframe);
362 if (line >= 0) { 362 if (line >= 0) {
363 GCproto *pt = funcproto(fn);
363 char buf[LUA_IDSIZE]; 364 char buf[LUA_IDSIZE];
364 lj_debug_shortname(buf, proto_chunkname(funcproto(fn))); 365 lj_debug_shortname(buf, proto_chunkname(pt), pt->firstline);
365 lj_str_pushf(L, "%s:%d: %s", buf, line, msg); 366 lj_str_pushf(L, "%s:%d: %s", buf, line, msg);
366 return; 367 return;
367 } 368 }
@@ -377,7 +378,9 @@ void lj_debug_pushloc(lua_State *L, GCproto *pt, BCPos pc)
377 const char *s = strdata(name); 378 const char *s = strdata(name);
378 MSize i, len = name->len; 379 MSize i, len = name->len;
379 BCLine line = lj_debug_line(pt, pc); 380 BCLine line = lj_debug_line(pt, pc);
380 if (*s == '@') { 381 if (pt->firstline == ~(BCLine)0) {
382 lj_str_pushf(L, "builtin:%s", s);
383 } else if (*s == '@') {
381 s++; len--; 384 s++; len--;
382 for (i = len; i > 0; i--) 385 for (i = len; i > 0; i--)
383 if (s[i] == '/' || s[i] == '\\') { 386 if (s[i] == '/' || s[i] == '\\') {
@@ -453,7 +456,7 @@ int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, int ext)
453 BCLine firstline = pt->firstline; 456 BCLine firstline = pt->firstline;
454 GCstr *name = proto_chunkname(pt); 457 GCstr *name = proto_chunkname(pt);
455 ar->source = strdata(name); 458 ar->source = strdata(name);
456 lj_debug_shortname(ar->short_src, name); 459 lj_debug_shortname(ar->short_src, name, pt->firstline);
457 ar->linedefined = (int)firstline; 460 ar->linedefined = (int)firstline;
458 ar->lastlinedefined = (int)(firstline + pt->numline); 461 ar->lastlinedefined = (int)(firstline + pt->numline);
459 ar->what = firstline ? "Lua" : "main"; 462 ar->what = firstline ? "Lua" : "main";