aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-12-08 13:48:23 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-12-08 13:48:23 -0200
commitc6e74e41c9752c8dc9a409e12cb2ae53e92679dd (patch)
treef913bfa4eb1c537fecc8809297a9ef7789bf22f1
parent6909b5a2b443040e09b575a6f320cd60d7e619ff (diff)
downloadlua-c6e74e41c9752c8dc9a409e12cb2ae53e92679dd.tar.gz
lua-c6e74e41c9752c8dc9a409e12cb2ae53e92679dd.tar.bz2
lua-c6e74e41c9752c8dc9a409e12cb2ae53e92679dd.zip
handle case where function was called as a hook
-rw-r--r--ldebug.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/ldebug.c b/ldebug.c
index 1435193a..5ba41c9a 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 2.106 2014/11/10 18:41:19 roberto Exp roberto $ 2** $Id: ldebug.c,v 2.107 2014/11/11 17:08:19 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*/
@@ -438,10 +438,14 @@ static const char *getobjname (Proto *p, int lastpc, int reg,
438 438
439 439
440static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { 440static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
441 TMS tm; 441 TMS tm = (TMS)0; /* to avoid warnings */
442 Proto *p = ci_func(ci)->p; /* calling function */ 442 Proto *p = ci_func(ci)->p; /* calling function */
443 int pc = currentpc(ci); /* calling instruction index */ 443 int pc = currentpc(ci); /* calling instruction index */
444 Instruction i = p->code[pc]; /* calling instruction */ 444 Instruction i = p->code[pc]; /* calling instruction */
445 if (ci->callstatus & CIST_HOOKED) { /* was it called inside a hook? */
446 *name = "?";
447 return "hook";
448 }
445 switch (GET_OPCODE(i)) { 449 switch (GET_OPCODE(i)) {
446 case OP_CALL: 450 case OP_CALL:
447 case OP_TAILCALL: /* get function name */ 451 case OP_TAILCALL: /* get function name */
@@ -471,8 +475,7 @@ static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
471 case OP_EQ: tm = TM_EQ; break; 475 case OP_EQ: tm = TM_EQ; break;
472 case OP_LT: tm = TM_LT; break; 476 case OP_LT: tm = TM_LT; break;
473 case OP_LE: tm = TM_LE; break; 477 case OP_LE: tm = TM_LE; break;
474 default: 478 default: lua_assert(0); /* other instructions cannot call a function */
475 return NULL; /* else no useful name can be found */
476 } 479 }
477 *name = getstr(G(L)->tmname[tm]); 480 *name = getstr(G(L)->tmname[tm]);
478 return "metamethod"; 481 return "metamethod";