aboutsummaryrefslogtreecommitdiff
path: root/src/3rdParty/lua/ldebug.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdParty/lua/ldebug.c')
-rw-r--r--src/3rdParty/lua/ldebug.c59
1 files changed, 42 insertions, 17 deletions
diff --git a/src/3rdParty/lua/ldebug.c b/src/3rdParty/lua/ldebug.c
index 3fae5cf..690ac38 100644
--- a/src/3rdParty/lua/ldebug.c
+++ b/src/3rdParty/lua/ldebug.c
@@ -426,7 +426,7 @@ static const char *getobjname (const Proto *p, int lastpc, int reg,
426*/ 426*/
427static void kname (const Proto *p, int c, const char **name) { 427static void kname (const Proto *p, int c, const char **name) {
428 TValue *kvalue = &p->k[c]; 428 TValue *kvalue = &p->k[c];
429 *name = (ttisstring(kvalue)) ? svalue(kvalue) : "?"; 429 *name = (ttisstring(kvalue)) ? getstr(tsvalue(kvalue)) : "?";
430} 430}
431 431
432 432
@@ -569,7 +569,7 @@ static const char *getobjname (const Proto *p, int lastpc, int reg,
569 int b = (op == OP_LOADK) ? GETARG_Bx(i) 569 int b = (op == OP_LOADK) ? GETARG_Bx(i)
570 : GETARG_Ax(p->code[pc + 1]); 570 : GETARG_Ax(p->code[pc + 1]);
571 if (ttisstring(&p->k[b])) { 571 if (ttisstring(&p->k[b])) {
572 *name = svalue(&p->k[b]); 572 *name = getstr(tsvalue(&p->k[b]));
573 return "constant"; 573 return "constant";
574 } 574 }
575 break; 575 break;
@@ -627,7 +627,7 @@ static const char *funcnamefromcode (lua_State *L, const Proto *p,
627 default: 627 default:
628 return NULL; /* cannot find a reasonable name */ 628 return NULL; /* cannot find a reasonable name */
629 } 629 }
630 *name = getstr(G(L)->tmname[tm]) + 2; 630 *name = getshrstr(G(L)->tmname[tm]) + 2;
631 return "metamethod"; 631 return "metamethod";
632} 632}
633 633
@@ -656,18 +656,19 @@ static const char *funcnamefromcall (lua_State *L, CallInfo *ci,
656 656
657 657
658/* 658/*
659** Check whether pointer 'o' points to some value in the stack 659** Check whether pointer 'o' points to some value in the stack frame of
660** frame of the current function. Because 'o' may not point to a 660** the current function and, if so, returns its index. Because 'o' may
661** value in this stack, we cannot compare it with the region 661** not point to a value in this stack, we cannot compare it with the
662** boundaries (undefined behaviour in ISO C). 662** region boundaries (undefined behavior in ISO C).
663*/ 663*/
664static int isinstack (CallInfo *ci, const TValue *o) { 664static int instack (CallInfo *ci, const TValue *o) {
665 StkId pos; 665 int pos;
666 for (pos = ci->func.p + 1; pos < ci->top.p; pos++) { 666 StkId base = ci->func.p + 1;
667 if (o == s2v(pos)) 667 for (pos = 0; base + pos < ci->top.p; pos++) {
668 return 1; 668 if (o == s2v(base + pos))
669 return pos;
669 } 670 }
670 return 0; /* not found */ 671 return -1; /* not found */
671} 672}
672 673
673 674
@@ -708,9 +709,11 @@ static const char *varinfo (lua_State *L, const TValue *o) {
708 const char *kind = NULL; 709 const char *kind = NULL;
709 if (isLua(ci)) { 710 if (isLua(ci)) {
710 kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ 711 kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */
711 if (!kind && isinstack(ci, o)) /* no? try a register */ 712 if (!kind) { /* not an upvalue? */
712 kind = getobjname(ci_func(ci)->p, currentpc(ci), 713 int reg = instack(ci, o); /* try a register */
713 cast_int(cast(StkId, o) - (ci->func.p + 1)), &name); 714 if (reg >= 0) /* is 'o' a register? */
715 kind = getobjname(ci_func(ci)->p, currentpc(ci), reg, &name);
716 }
714 } 717 }
715 return formatvarinfo(L, kind, name); 718 return formatvarinfo(L, kind, name);
716} 719}
@@ -845,7 +848,7 @@ static int changedline (const Proto *p, int oldpc, int newpc) {
845 if (p->lineinfo == NULL) /* no debug information? */ 848 if (p->lineinfo == NULL) /* no debug information? */
846 return 0; 849 return 0;
847 if (newpc - oldpc < MAXIWTHABS / 2) { /* not too far apart? */ 850 if (newpc - oldpc < MAXIWTHABS / 2) { /* not too far apart? */
848 int delta = 0; /* line diference */ 851 int delta = 0; /* line difference */
849 int pc = oldpc; 852 int pc = oldpc;
850 for (;;) { 853 for (;;) {
851 int lineinfo = p->lineinfo[++pc]; 854 int lineinfo = p->lineinfo[++pc];
@@ -863,6 +866,28 @@ static int changedline (const Proto *p, int oldpc, int newpc) {
863 866
864 867
865/* 868/*
869** Traces Lua calls. If code is running the first instruction of a function,
870** and function is not vararg, and it is not coming from an yield,
871** calls 'luaD_hookcall'. (Vararg functions will call 'luaD_hookcall'
872** after adjusting its variable arguments; otherwise, they could call
873** a line/count hook before the call hook. Functions coming from
874** an yield already called 'luaD_hookcall' before yielding.)
875*/
876int luaG_tracecall (lua_State *L) {
877 CallInfo *ci = L->ci;
878 Proto *p = ci_func(ci)->p;
879 ci->u.l.trap = 1; /* ensure hooks will be checked */
880 if (ci->u.l.savedpc == p->code) { /* first instruction (not resuming)? */
881 if (p->is_vararg)
882 return 0; /* hooks will start at VARARGPREP instruction */
883 else if (!(ci->callstatus & CIST_HOOKYIELD)) /* not yieded? */
884 luaD_hookcall(L, ci); /* check 'call' hook */
885 }
886 return 1; /* keep 'trap' on */
887}
888
889
890/*
866** Traces the execution of a Lua function. Called before the execution 891** Traces the execution of a Lua function. Called before the execution
867** of each opcode, when debug is on. 'L->oldpc' stores the last 892** of each opcode, when debug is on. 'L->oldpc' stores the last
868** instruction traced, to detect line changes. When entering a new 893** instruction traced, to detect line changes. When entering a new