diff options
| -rw-r--r-- | ldebug.c | 34 |
1 files changed, 29 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldebug.c,v 2.34 2006/11/22 11:43:47 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.35 2007/03/26 18:35:34 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 | */ |
| @@ -531,15 +531,39 @@ static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos, | |||
| 531 | 531 | ||
| 532 | 532 | ||
| 533 | static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { | 533 | static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { |
| 534 | TMS tm = 0; | ||
| 534 | Instruction i; | 535 | Instruction i; |
| 535 | if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1)) | 536 | if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1)) |
| 536 | return NULL; /* calling function is not Lua (or is unknown) */ | 537 | return NULL; /* calling function is not Lua (or is unknown) */ |
| 537 | ci--; /* calling function */ | 538 | ci--; /* calling function */ |
| 538 | i = ci_func(ci)->l.p->code[currentpc(L, ci)]; | 539 | i = ci_func(ci)->l.p->code[currentpc(L, ci)]; |
| 539 | if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL || | 540 | switch (GET_OPCODE(i)) { |
| 540 | GET_OPCODE(i) == OP_TFORLOOP) | 541 | case OP_CALL: |
| 541 | return getobjname(L, ci, GETARG_A(i), name); | 542 | case OP_TAILCALL: |
| 542 | return NULL; /* else no useful name can be found */ | 543 | case OP_TFORLOOP: |
| 544 | return getobjname(L, ci, GETARG_A(i), name); | ||
| 545 | case OP_GETGLOBAL: | ||
| 546 | case OP_SELF: | ||
| 547 | case OP_GETTABLE: tm = TM_INDEX; break; | ||
| 548 | case OP_SETGLOBAL: | ||
| 549 | case OP_SETTABLE: tm = TM_NEWINDEX; break; | ||
| 550 | case OP_EQ: tm = TM_EQ; break; | ||
| 551 | case OP_ADD: tm = TM_ADD; break; | ||
| 552 | case OP_SUB: tm = TM_SUB; break; | ||
| 553 | case OP_MUL: tm = TM_MUL; break; | ||
| 554 | case OP_DIV: tm = TM_DIV; break; | ||
| 555 | case OP_MOD: tm = TM_MOD; break; | ||
| 556 | case OP_POW: tm = TM_POW; break; | ||
| 557 | case OP_UNM: tm = TM_UNM; break; | ||
| 558 | case OP_LEN: tm = TM_LEN; break; | ||
| 559 | case OP_LT: tm = TM_LT; break; | ||
| 560 | case OP_LE: tm = TM_LE; break; | ||
| 561 | case OP_CONCAT: tm = TM_CONCAT; break; | ||
| 562 | default: | ||
| 563 | return NULL; /* else no useful name can be found */ | ||
| 564 | } | ||
| 565 | *name = getstr(G(L)->tmname[tm]); | ||
| 566 | return "metamethod"; | ||
| 543 | } | 567 | } |
| 544 | 568 | ||
| 545 | 569 | ||
