aboutsummaryrefslogtreecommitdiff
path: root/ldebug.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ldebug.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/ldebug.c b/ldebug.c
index 28b1caab..690ac38f 100644
--- a/ldebug.c
+++ b/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
@@ -866,6 +866,28 @@ static int changedline (const Proto *p, int oldpc, int newpc) {
866 866
867 867
868/* 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/*
869** Traces the execution of a Lua function. Called before the execution 891** Traces the execution of a Lua function. Called before the execution
870** 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
871** instruction traced, to detect line changes. When entering a new 893** instruction traced, to detect line changes. When entering a new