details in 'findsetreg'

This commit is contained in:
Roberto Ierusalimschy 2017-04-29 12:28:38 -03:00
parent 502a1d1108
commit a454e884e0
1 changed files with 17 additions and 19 deletions

View File

@ -1,5 +1,5 @@
/* /*
** $Id: ldebug.c,v 2.122 2017/04/26 17:46:52 roberto Exp roberto $ ** $Id: ldebug.c,v 2.123 2017/04/28 20:57:45 roberto Exp roberto $
** Debug Interface ** Debug Interface
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -398,39 +398,37 @@ static int findsetreg (Proto *p, int lastpc, int reg) {
Instruction i = p->code[pc]; Instruction i = p->code[pc];
OpCode op = GET_OPCODE(i); OpCode op = GET_OPCODE(i);
int a = GETARG_A(i); int a = GETARG_A(i);
int change; /* true if current instruction changed 'reg' */
switch (op) { switch (op) {
case OP_LOADNIL: { case OP_LOADNIL: { /* set registers from 'a' to 'a+b' */
int b = GETARG_B(i); int b = GETARG_B(i);
if (a <= reg && reg <= a + b) /* set registers from 'a' to 'a+b' */ change = (a <= reg && reg <= a + b);
setreg = filterpc(pc, jmptarget);
break; break;
} }
case OP_TFORCALL: { case OP_TFORCALL: { /* affect all regs above its base */
if (reg >= a + 2) /* affect all regs above its base */ change = (reg >= a + 2);
setreg = filterpc(pc, jmptarget);
break; break;
} }
case OP_CALL: case OP_CALL:
case OP_TAILCALL: { case OP_TAILCALL: { /* affect all registers above base */
if (reg >= a) /* affect all registers above base */ change = (reg >= a);
setreg = filterpc(pc, jmptarget);
break; break;
} }
case OP_JMP: { case OP_JMP: { /* doesn't change registers, but changes 'jmptarget' */
int b = GETARG_sBx(i); int b = GETARG_sBx(i);
int dest = pc + 1 + b; int dest = pc + 1 + b;
/* jump is forward and do not skip 'lastpc'? */ /* jump does not skip 'lastpc' and is larger than current one? */
if (pc < dest && dest <= lastpc) { if (dest <= lastpc && dest > jmptarget)
if (dest > jmptarget) jmptarget = dest; /* update 'jmptarget' */
jmptarget = dest; /* update 'jmptarget' */ change = 0;
}
break; break;
} }
default: default: /* any instruction that sets A */
if (testAMode(op) && reg == a) /* any instruction that set A */ change = (testAMode(op) && reg == a);
setreg = filterpc(pc, jmptarget);
break; break;
} }
if (change)
setreg = filterpc(pc, jmptarget);
} }
return setreg; return setreg;
} }