aboutsummaryrefslogtreecommitdiff
path: root/ldebug.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldebug.c')
-rw-r--r--ldebug.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/ldebug.c b/ldebug.c
index 1f961ec1..57215028 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.86 2001/06/28 19:58:57 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.87 2001/07/03 17:01:34 roberto Exp $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -117,7 +117,7 @@ int luaG_getline (int *lineinfo, int pc, int refline, int *prefi) {
117static int currentpc (CallInfo *ci) { 117static int currentpc (CallInfo *ci) {
118 lua_assert(isLmark(ci)); 118 lua_assert(isLmark(ci));
119 if (ci->pc) 119 if (ci->pc)
120 return (*ci->pc - ci_func(ci)->f.l->code) - 1; 120 return (*ci->pc - ci_func(ci)->u.l.p->code) - 1;
121 else 121 else
122 return -1; /* function is not active */ 122 return -1; /* function is not active */
123} 123}
@@ -127,7 +127,7 @@ static int currentline (CallInfo *ci) {
127 if (!isLmark(ci)) 127 if (!isLmark(ci))
128 return -1; /* only active lua functions have current-line information */ 128 return -1; /* only active lua functions have current-line information */
129 else { 129 else {
130 int *lineinfo = ci_func(ci)->f.l->lineinfo; 130 int *lineinfo = ci_func(ci)->u.l.p->lineinfo;
131 return luaG_getline(lineinfo, currentpc(ci), 1, NULL); 131 return luaG_getline(lineinfo, currentpc(ci), 1, NULL);
132 } 132 }
133} 133}
@@ -135,7 +135,7 @@ static int currentline (CallInfo *ci) {
135 135
136 136
137static Proto *getluaproto (CallInfo *ci) { 137static Proto *getluaproto (CallInfo *ci) {
138 return (isLmark(ci) ? ci_func(ci)->f.l : NULL); 138 return (isLmark(ci) ? ci_func(ci)->u.l.p : NULL);
139} 139}
140 140
141 141
@@ -199,7 +199,7 @@ static void funcinfo (lua_State *L, lua_Debug *ar, StkId func) {
199 ar->what = l_s("C"); 199 ar->what = l_s("C");
200 } 200 }
201 else 201 else
202 infoLproto(ar, cl->f.l); 202 infoLproto(ar, cl->u.l.p);
203 luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); 203 luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
204 if (ar->linedefined == 0) 204 if (ar->linedefined == 0)
205 ar->what = l_s("main"); 205 ar->what = l_s("main");
@@ -323,14 +323,15 @@ static int precheck (const Proto *pt) {
323} 323}
324 324
325 325
326static int checkopenop (Instruction i) { 326static int checkopenop (const Proto *pt, int pc) {
327 OpCode op = GET_OPCODE(i); 327 Instruction i = pt->code[pc+1];
328 switch (op) { 328 switch (GET_OPCODE(i)) {
329 case OP_CALL: 329 case OP_CALL:
330 case OP_RETURN: { 330 case OP_RETURN: {
331 check(GETARG_B(i) == NO_REG); 331 check(GETARG_B(i) == NO_REG);
332 return 1; 332 return 1;
333 } 333 }
334 case OP_CLOSE: return checkopenop(pt, pc+1);
334 case OP_SETLISTO: return 1; 335 case OP_SETLISTO: return 1;
335 default: return 0; /* invalid instruction after an open call */ 336 default: return 0; /* invalid instruction after an open call */
336 } 337 }
@@ -382,7 +383,8 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int reg) {
382 last = pc; /* set registers from `a' to `b' */ 383 last = pc; /* set registers from `a' to `b' */
383 break; 384 break;
384 } 385 }
385 case OP_LOADUPVAL: { 386 case OP_GETUPVAL:
387 case OP_SETUPVAL: {
386 check(b < pt->nupvalues); 388 check(b < pt->nupvalues);
387 break; 389 break;
388 } 390 }
@@ -419,7 +421,7 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int reg) {
419 checkreg(pt, a+b); 421 checkreg(pt, a+b);
420 } 422 }
421 if (c == NO_REG) { 423 if (c == NO_REG) {
422 check(checkopenop(pt->code[pc+1])); 424 check(checkopenop(pt, pc));
423 } 425 }
424 else if (c != 0) 426 else if (c != 0)
425 checkreg(pt, a+c-1); 427 checkreg(pt, a+c-1);
@@ -452,7 +454,7 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int reg) {
452 } 454 }
453 case OP_CLOSURE: { 455 case OP_CLOSURE: {
454 check(b < pt->sizep); 456 check(b < pt->sizep);
455 checkreg(pt, a + pt->p[b]->nupvalues - 1); 457 check(pc + pt->p[b]->nupvalues < pt->sizecode);
456 break; 458 break;
457 } 459 }
458 default: break; 460 default: break;
@@ -472,7 +474,7 @@ int luaG_checkcode (const Proto *pt) {
472static const l_char *getobjname (lua_State *L, StkId obj, const l_char **name) { 474static const l_char *getobjname (lua_State *L, StkId obj, const l_char **name) {
473 CallInfo *ci = ci_stack(L, obj); 475 CallInfo *ci = ci_stack(L, obj);
474 if (isLmark(ci)) { /* an active Lua function? */ 476 if (isLmark(ci)) { /* an active Lua function? */
475 Proto *p = ci_func(ci)->f.l; 477 Proto *p = ci_func(ci)->u.l.p;
476 int pc = currentpc(ci); 478 int pc = currentpc(ci);
477 int stackpos = obj - ci->base; 479 int stackpos = obj - ci->base;
478 Instruction i; 480 Instruction i;
@@ -516,7 +518,7 @@ static const l_char *getfuncname (lua_State *L, CallInfo *ci,
516 if (ci == &L->basefunc || !isLmark(ci)) 518 if (ci == &L->basefunc || !isLmark(ci))
517 return NULL; /* not an active Lua function */ 519 return NULL; /* not an active Lua function */
518 else { 520 else {
519 Proto *p = ci_func(ci)->f.l; 521 Proto *p = ci_func(ci)->u.l.p;
520 int pc = currentpc(ci); 522 int pc = currentpc(ci);
521 Instruction i; 523 Instruction i;
522 if (pc == -1) return NULL; /* function is not activated */ 524 if (pc == -1) return NULL; /* function is not activated */