mirror of
https://github.com/lua/lua
synced 2024-12-25 03:46:50 +03:00
better instrumentation for internal debugging
This commit is contained in:
parent
082aded149
commit
9d7bae0b6a
19
lmem.c
19
lmem.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lmem.c,v 1.8 1999/01/22 17:28:00 roberto Exp roberto $
|
||||
** $Id: lmem.c,v 1.9 1999/01/22 18:08:57 roberto Exp roberto $
|
||||
** Interface to Memory Manager
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -24,6 +24,8 @@
|
||||
|
||||
|
||||
|
||||
#ifndef DEBUG
|
||||
|
||||
int luaM_growaux (void **block, unsigned long nelems, int size,
|
||||
char *errormsg, unsigned long limit) {
|
||||
if (nelems >= limit)
|
||||
@ -36,9 +38,6 @@ int luaM_growaux (void **block, unsigned long nelems, int size,
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifndef DEBUG
|
||||
|
||||
/*
|
||||
** generic allocation routine.
|
||||
*/
|
||||
@ -64,6 +63,18 @@ void *luaM_realloc (void *block, unsigned long size) {
|
||||
#include <string.h>
|
||||
|
||||
|
||||
int luaM_growaux (void **block, unsigned long nelems, int size,
|
||||
char *errormsg, unsigned long limit) {
|
||||
if (nelems >= limit)
|
||||
lua_error(errormsg);
|
||||
nelems = nelems+1;
|
||||
if (nelems > limit)
|
||||
nelems = limit;
|
||||
*block = luaM_realloc(*block, nelems*size);
|
||||
return (int)nelems;
|
||||
}
|
||||
|
||||
|
||||
#define HEADER (sizeof(double))
|
||||
|
||||
#define MARK 55
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lopcodes.h,v 1.25 1999/02/09 18:01:55 roberto Exp roberto $
|
||||
** $Id: lopcodes.h,v 1.26 1999/02/23 13:38:38 roberto Exp roberto $
|
||||
** Opcodes for Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -107,7 +107,9 @@ SETLINEW,/* w - - LINE=w */
|
||||
SETLINE,/* b - - LINE=b */
|
||||
|
||||
LONGARGW,/* w (add w*(1<<16) to arg of next instruction) */
|
||||
LONGARG /* b (add b*(1<<16) to arg of next instruction) */
|
||||
LONGARG,/* b (add b*(1<<16) to arg of next instruction) */
|
||||
|
||||
CHECKSTACK /* b (assert #temporaries == b; only for internal debuging!) */
|
||||
|
||||
} OpCode;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lparser.c,v 1.20 1999/02/09 18:01:55 roberto Exp roberto $
|
||||
** $Id: lparser.c,v 1.21 1999/02/24 15:37:19 roberto Exp roberto $
|
||||
** LL(1) Parser and code generator for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -403,6 +403,10 @@ static void close_exp (LexState *ls, int pc, int nresults) {
|
||||
deltastack(ls, nresults); /* push results */
|
||||
deltastack(ls, -(code[pc]+1)); /* pop params (at code[pc]) and function */
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (nresults != MULT_RET)
|
||||
code_oparg(ls, CHECKSTACK, ls->fs->stacksize, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
6
lvm.c
6
lvm.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lvm.c,v 1.49 1999/02/09 18:01:55 roberto Exp roberto $
|
||||
** $Id: lvm.c,v 1.50 1999/02/23 13:38:38 roberto Exp roberto $
|
||||
** Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -643,6 +643,10 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) {
|
||||
aux = highbyte(highbyte(aux));
|
||||
goto switchentry; /* do not reset "aux" */
|
||||
|
||||
case CHECKSTACK: aux = *pc++;
|
||||
LUA_ASSERT((S->top-S->stack)-base == aux, "wrong stack size");
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user