aboutsummaryrefslogtreecommitdiff
path: root/ltests.c
diff options
context:
space:
mode:
Diffstat (limited to 'ltests.c')
-rw-r--r--ltests.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/ltests.c b/ltests.c
index ac548a95..13717da9 100644
--- a/ltests.c
+++ b/ltests.c
@@ -526,7 +526,8 @@ static char *buildop (Proto *p, int pc, char *buff) {
526 OpCode o = GET_OPCODE(i); 526 OpCode o = GET_OPCODE(i);
527 const char *name = opnames[o]; 527 const char *name = opnames[o];
528 int line = luaG_getfuncline(p, pc); 528 int line = luaG_getfuncline(p, pc);
529 sprintf(buff, "(%4d) %4d - ", line, pc); 529 int lineinfo = (p->lineinfo != NULL) ? p->lineinfo[pc] : 0;
530 sprintf(buff, "(%2d - %4d) %4d - ", lineinfo, line, pc);
530 switch (getOpMode(o)) { 531 switch (getOpMode(o)) {
531 case iABC: 532 case iABC:
532 sprintf(buff+strlen(buff), "%-12s%4d %4d %4d%s", name, 533 sprintf(buff+strlen(buff), "%-12s%4d %4d %4d%s", name,
@@ -621,6 +622,24 @@ static int listk (lua_State *L) {
621} 622}
622 623
623 624
625static int listabslineinfo (lua_State *L) {
626 Proto *p;
627 int i;
628 luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
629 1, "Lua function expected");
630 p = getproto(obj_at(L, 1));
631 luaL_argcheck(L, p->abslineinfo != NULL, 1, "function has no debug info");
632 lua_createtable(L, 2 * p->sizeabslineinfo, 0);
633 for (i=0; i < p->sizeabslineinfo; i++) {
634 lua_pushinteger(L, p->abslineinfo[i].pc);
635 lua_rawseti(L, -2, 2 * i + 1);
636 lua_pushinteger(L, p->abslineinfo[i].line);
637 lua_rawseti(L, -2, 2 * i + 2);
638 }
639 return 1;
640}
641
642
624static int listlocals (lua_State *L) { 643static int listlocals (lua_State *L) {
625 Proto *p; 644 Proto *p;
626 int pc = cast_int(luaL_checkinteger(L, 2)) - 1; 645 int pc = cast_int(luaL_checkinteger(L, 2)) - 1;
@@ -1682,6 +1701,7 @@ static const struct luaL_Reg tests_funcs[] = {
1682 {"listcode", listcode}, 1701 {"listcode", listcode},
1683 {"printcode", printcode}, 1702 {"printcode", printcode},
1684 {"listk", listk}, 1703 {"listk", listk},
1704 {"listabslineinfo", listabslineinfo},
1685 {"listlocals", listlocals}, 1705 {"listlocals", listlocals},
1686 {"loadlib", loadlib}, 1706 {"loadlib", loadlib},
1687 {"checkpanic", checkpanic}, 1707 {"checkpanic", checkpanic},