aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lcode.c5
-rw-r--r--ldebug.c17
-rw-r--r--ldo.c5
-rw-r--r--lfunc.c4
-rw-r--r--lgc.c10
-rw-r--r--llex.c5
-rw-r--r--lparser.c22
-rw-r--r--lparser.h3
-rw-r--r--lstate.c3
-rw-r--r--lstate.h3
-rw-r--r--ltests.c8
-rw-r--r--luadebug.h4
-rw-r--r--lvm.c26
13 files changed, 40 insertions, 75 deletions
diff --git a/lcode.c b/lcode.c
index 2a47daee..10b8c500 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 1.42 2000/08/04 19:38:35 roberto Exp roberto $ 2** $Id: lcode.c,v 1.43 2000/08/08 18:26:05 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -631,8 +631,7 @@ int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) {
631 case iS: i = CREATE_S(o, arg1); break; 631 case iS: i = CREATE_S(o, arg1); break;
632 case iAB: i = CREATE_AB(o, arg1, arg2); break; 632 case iAB: i = CREATE_AB(o, arg1, arg2); break;
633 } 633 }
634 if (fs->debug) 634 codelineinfo(fs);
635 codelineinfo(fs);
636 /* put new instruction in code array */ 635 /* put new instruction in code array */
637 luaM_growvector(fs->L, fs->f->code, fs->pc, 1, Instruction, 636 luaM_growvector(fs->L, fs->f->code, fs->pc, 1, Instruction,
638 "code size overflow", MAX_INT); 637 "code size overflow", MAX_INT);
diff --git a/ldebug.c b/ldebug.c
index 60fdfa37..40d1a003 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.28 2000/08/07 20:21:34 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.29 2000/08/08 18:26:05 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*/
@@ -57,13 +57,6 @@ lua_Hook lua_setlinehook (lua_State *L, lua_Hook func) {
57} 57}
58 58
59 59
60int lua_setdebug (lua_State *L, int debug) {
61 int old = L->debug;
62 L->debug = debug;
63 return old;
64}
65
66
67static StkId aux_stackedfunction (lua_State *L, int level, StkId top) { 60static StkId aux_stackedfunction (lua_State *L, int level, StkId top) {
68 int i; 61 int i;
69 for (i = (top-1)-L->stack; i>=0; i--) { 62 for (i = (top-1)-L->stack; i>=0; i--) {
@@ -140,9 +133,7 @@ static int lua_currentline (StkId f) {
140 else { 133 else {
141 CallInfo *ci = infovalue(f); 134 CallInfo *ci = infovalue(f);
142 int *lineinfo = ci->func->f.l->lineinfo; 135 int *lineinfo = ci->func->f.l->lineinfo;
143 if (!lineinfo) return -1; /* no static debug information */ 136 return luaG_getline(lineinfo, lua_currentpc(f), 1, NULL);
144 else
145 return luaG_getline(lineinfo, lua_currentpc(f), 1, NULL);
146 } 137 }
147} 138}
148 139
@@ -382,7 +373,8 @@ static const char *getname (lua_State *L, StkId obj, const char **name) {
382 } 373 }
383 case OP_GETLOCAL: { 374 case OP_GETLOCAL: {
384 *name = luaF_getlocalname(p, GETARG_U(i)+1, pc); 375 *name = luaF_getlocalname(p, GETARG_U(i)+1, pc);
385 return (*name) ? "local" : NULL; 376 LUA_ASSERT(*name, "local must exist");
377 return "local";
386 } 378 }
387 case OP_PUSHSELF: 379 case OP_PUSHSELF:
388 case OP_GETDOTTED: { 380 case OP_GETDOTTED: {
@@ -418,3 +410,4 @@ void luaG_callerror (lua_State *L, StkId func) {
418void luaG_indexerror (lua_State *L, StkId t) { 410void luaG_indexerror (lua_State *L, StkId t) {
419 call_index_error(L, t, "index", "table"); 411 call_index_error(L, t, "index", "table");
420} 412}
413
diff --git a/ldo.c b/ldo.c
index 2d922078..0e6859af 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.81 2000/06/28 20:20:36 roberto Exp roberto $ 2** $Id: ldo.c,v 1.82 2000/08/04 19:38:35 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -25,7 +25,6 @@
25#include "lstring.h" 25#include "lstring.h"
26#include "ltable.h" 26#include "ltable.h"
27#include "ltm.h" 27#include "ltm.h"
28#include "luadebug.h"
29#include "lundump.h" 28#include "lundump.h"
30#include "lvm.h" 29#include "lvm.h"
31#include "lzio.h" 30#include "lzio.h"
@@ -324,7 +323,6 @@ static int protectedparser (lua_State *L, ZIO *z, int bin) {
324 323
325static int do_main (lua_State *L, ZIO *z, int bin) { 324static int do_main (lua_State *L, ZIO *z, int bin) {
326 int status; 325 int status;
327 int debug = L->debug; /* save debug status */
328 do { 326 do {
329 unsigned long old_blocks; 327 unsigned long old_blocks;
330 luaC_checkGC(L); 328 luaC_checkGC(L);
@@ -339,7 +337,6 @@ static int do_main (lua_State *L, ZIO *z, int bin) {
339 L->GCthreshold -= newelems2; 337 L->GCthreshold -= newelems2;
340 } 338 }
341 } while (bin && status == 0); 339 } while (bin && status == 0);
342 L->debug = debug; /* restore debug status */
343 return status; 340 return status;
344} 341}
345 342
diff --git a/lfunc.c b/lfunc.c
index 6280cf29..9b8d83f2 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lfunc.c,v 1.26 2000/08/07 20:21:34 roberto Exp roberto $ 2** $Id: lfunc.c,v 1.27 2000/08/08 18:26:05 roberto Exp roberto $
3** Auxiliary functions to manipulate prototypes and closures 3** Auxiliary functions to manipulate prototypes and closures
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -79,8 +79,6 @@ const char *luaF_getlocalname (const Proto *func, int local_number, int pc) {
79 int count = 0; 79 int count = 0;
80 const char *varname = NULL; 80 const char *varname = NULL;
81 LocVar *lv = func->locvars; 81 LocVar *lv = func->locvars;
82 if (lv == NULL)
83 return NULL;
84 for (; lv->pc != -1 && lv->pc <= pc; lv++) { 82 for (; lv->pc != -1 && lv->pc <= pc; lv++) {
85 if (lv->varname) { /* register */ 83 if (lv->varname) { /* register */
86 if (++count == local_number) 84 if (++count == local_number)
diff --git a/lgc.c b/lgc.c
index d884d224..4391316f 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.59 2000/06/30 14:35:17 roberto Exp roberto $ 2** $Id: lgc.c,v 1.60 2000/08/07 20:21:34 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -44,11 +44,9 @@ static void protomark (Proto *f) {
44 strmark(f->kstr[i]); 44 strmark(f->kstr[i]);
45 for (i=0; i<f->nkproto; i++) 45 for (i=0; i<f->nkproto; i++)
46 protomark(f->kproto[i]); 46 protomark(f->kproto[i]);
47 if (f->locvars) { /* is there debug information? */ 47 for (i=0; f->locvars[i].pc != -1; i++) /* mark local-variable names */
48 LocVar *lv; 48 if (f->locvars[i].varname)
49 for (lv=f->locvars; lv->pc != -1; lv++) /* mark local-variable names */ 49 strmark(f->locvars[i].varname);
50 if (lv->varname) strmark(lv->varname);
51 }
52 } 50 }
53} 51}
54 52
diff --git a/llex.c b/llex.c
index 50ffc951..49824b24 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.64 2000/06/19 18:05:14 roberto Exp roberto $ 2** $Id: llex.c,v 1.65 2000/06/21 18:13:56 roberto Exp roberto $
3** Lexical Analyzer 3** Lexical Analyzer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -120,10 +120,7 @@ static void checkpragma (lua_State *L, LexState *LS) {
120 if (LS->current == '$') { /* is a pragma? */ 120 if (LS->current == '$') { /* is a pragma? */
121 switch (luaL_findstring(readname(L, LS)+1, pragmas)) { 121 switch (luaL_findstring(readname(L, LS)+1, pragmas)) {
122 case 0: /* debug */ 122 case 0: /* debug */
123 L->debug = 1;
124 break;
125 case 1: /* nodebug */ 123 case 1: /* nodebug */
126 L->debug = 0;
127 break; 124 break;
128 default: 125 default:
129 luaX_error(LS, "unknown pragma", TK_STRING); 126 luaX_error(LS, "unknown pragma", TK_STRING);
diff --git a/lparser.c b/lparser.c
index deae943f..63af8326 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.102 2000/06/30 14:35:17 roberto Exp roberto $ 2** $Id: lparser.c,v 1.103 2000/08/08 18:26:05 roberto Exp roberto $
3** LL(1) Parser and code generator for Lua 3** LL(1) Parser and code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -154,13 +154,11 @@ static int checkname (LexState *ls) {
154 154
155static void luaI_registerlocalvar (LexState *ls, TString *varname, int pc) { 155static void luaI_registerlocalvar (LexState *ls, TString *varname, int pc) {
156 FuncState *fs = ls->fs; 156 FuncState *fs = ls->fs;
157 if (fs->debug) { 157 Proto *f = fs->f;
158 Proto *f = fs->f; 158 luaM_growvector(ls->L, f->locvars, fs->nvars, 1, LocVar, "", MAX_INT);
159 luaM_growvector(ls->L, f->locvars, fs->nvars, 1, LocVar, "", MAX_INT); 159 f->locvars[fs->nvars].varname = varname;
160 f->locvars[fs->nvars].varname = varname; 160 f->locvars[fs->nvars].pc = pc;
161 f->locvars[fs->nvars].pc = pc; 161 fs->nvars++;
162 fs->nvars++;
163 }
164} 162}
165 163
166 164
@@ -350,10 +348,8 @@ static void close_func (LexState *ls) {
350 luaM_reallocvector(L, f->kproto, f->nkproto, Proto *); 348 luaM_reallocvector(L, f->kproto, f->nkproto, Proto *);
351 luaI_registerlocalvar(ls, NULL, -1); /* flag end of vector */ 349 luaI_registerlocalvar(ls, NULL, -1); /* flag end of vector */
352 luaM_reallocvector(L, f->locvars, fs->nvars, LocVar); 350 luaM_reallocvector(L, f->locvars, fs->nvars, LocVar);
353 if (fs->debug) { 351 luaM_reallocvector(L, f->lineinfo, fs->nlineinfo+1, int);
354 luaM_reallocvector(L, f->lineinfo, fs->nlineinfo+1, int); 352 f->lineinfo[fs->nlineinfo] = MAX_INT; /* end flag */
355 f->lineinfo[fs->nlineinfo] = MAX_INT; /* end flag */
356 }
357 ls->fs = fs->prev; 353 ls->fs = fs->prev;
358 LUA_ASSERT(fs->bl == NULL, "wrong list end"); 354 LUA_ASSERT(fs->bl == NULL, "wrong list end");
359} 355}
@@ -365,7 +361,6 @@ Proto *luaY_parser (lua_State *L, ZIO *z) {
365 luaX_setinput(L, &lexstate, z, luaS_new(L, zname(z))); 361 luaX_setinput(L, &lexstate, z, luaS_new(L, zname(z)));
366 open_func(&lexstate, &funcstate); 362 open_func(&lexstate, &funcstate);
367 next(&lexstate); /* read first token */ 363 next(&lexstate); /* read first token */
368 funcstate.debug = L->debug; /* previous `next' may scan a pragma */
369 chunk(&lexstate); 364 chunk(&lexstate);
370 check_condition(&lexstate, (lexstate.t.token == TK_EOS), "<eof> expected"); 365 check_condition(&lexstate, (lexstate.t.token == TK_EOS), "<eof> expected");
371 close_func(&lexstate); 366 close_func(&lexstate);
@@ -1091,7 +1086,6 @@ static void body (LexState *ls, int needself, int line) {
1091 FuncState new_fs; 1086 FuncState new_fs;
1092 open_func(ls, &new_fs); 1087 open_func(ls, &new_fs);
1093 new_fs.f->lineDefined = line; 1088 new_fs.f->lineDefined = line;
1094 new_fs.debug = ls->L->debug;
1095 check(ls, '('); 1089 check(ls, '(');
1096 if (needself) { 1090 if (needself) {
1097 new_localvarstr(ls, "self", 0); 1091 new_localvarstr(ls, "self", 0);
diff --git a/lparser.h b/lparser.h
index c7f87350..258d6fe7 100644
--- a/lparser.h
+++ b/lparser.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.h,v 1.20 2000/06/28 20:20:36 roberto Exp roberto $ 2** $Id: lparser.h,v 1.21 2000/08/08 18:26:05 roberto Exp roberto $
3** LL(1) Parser and code generator for Lua 3** LL(1) Parser and code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -47,7 +47,6 @@ typedef struct FuncState {
47 int stacklevel; /* number of values on activation register */ 47 int stacklevel; /* number of values on activation register */
48 int nlocalvar; /* number of active local variables */ 48 int nlocalvar; /* number of active local variables */
49 int nupvalues; /* number of upvalues */ 49 int nupvalues; /* number of upvalues */
50 int debug; /* flag for debug information */
51 int nvars; /* number of entries in f->locvars */ 50 int nvars; /* number of entries in f->locvars */
52 int lastline; /* line where last `lineinfo' was generated */ 51 int lastline; /* line where last `lineinfo' was generated */
53 int nlineinfo; /* index of next `lineinfo' to be generated */ 52 int nlineinfo; /* index of next `lineinfo' to be generated */
diff --git a/lstate.c b/lstate.c
index 2d7de542..85357c00 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.c,v 1.29 2000/06/30 19:17:08 roberto Exp roberto $ 2** $Id: lstate.c,v 1.30 2000/08/04 19:38:35 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -52,7 +52,6 @@ lua_State *lua_newstate (int stacksize, int put_builtin) {
52 L->refFree = NONEXT; 52 L->refFree = NONEXT;
53 L->nblocks = 0; 53 L->nblocks = 0;
54 L->GCthreshold = MAX_INT; /* to avoid GC during pre-definitions */ 54 L->GCthreshold = MAX_INT; /* to avoid GC during pre-definitions */
55 L->debug = 0;
56 L->callhook = NULL; 55 L->callhook = NULL;
57 L->linehook = NULL; 56 L->linehook = NULL;
58 L->allowhooks = 1; 57 L->allowhooks = 1;
diff --git a/lstate.h b/lstate.h
index 70bc4600..d177c3a6 100644
--- a/lstate.h
+++ b/lstate.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.h,v 1.34 2000/05/24 13:54:49 roberto Exp roberto $ 2** $Id: lstate.h,v 1.35 2000/08/07 18:39:16 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -79,7 +79,6 @@ struct lua_State {
79 int refFree; /* list of free positions in refArray */ 79 int refFree; /* list of free positions in refArray */
80 unsigned long GCthreshold; 80 unsigned long GCthreshold;
81 unsigned long nblocks; /* number of `blocks' currently allocated */ 81 unsigned long nblocks; /* number of `blocks' currently allocated */
82 int debug;
83 lua_Hook callhook; 82 lua_Hook callhook;
84 lua_Hook linehook; 83 lua_Hook linehook;
85 int allowhooks; 84 int allowhooks;
diff --git a/ltests.c b/ltests.c
index 677f7c8d..233775aa 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 1.30 2000/08/04 19:38:35 roberto Exp roberto $ 2** $Id: ltests.c,v 1.31 2000/08/08 18:26:05 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -69,11 +69,7 @@ static int pushop (Proto *p, int pc) {
69 Instruction i = p->code[pc]; 69 Instruction i = p->code[pc];
70 OpCode o = GET_OPCODE(i); 70 OpCode o = GET_OPCODE(i);
71 const char *name = instrname[o]; 71 const char *name = instrname[o];
72 int *lineinfo = p->lineinfo; 72 sprintf(buff, "%5d - ", luaG_getline(p->lineinfo, pc, 1, NULL));
73 if (lineinfo)
74 sprintf(buff, "%5d - ", luaG_getline(lineinfo, pc, 1, NULL));
75 else
76 strcpy(buff, " ");
77 switch ((enum Mode)luaK_opproperties[o].mode) { 73 switch ((enum Mode)luaK_opproperties[o].mode) {
78 case iO: 74 case iO:
79 sprintf(buff+8, "%s", name); 75 sprintf(buff+8, "%s", name);
diff --git a/luadebug.h b/luadebug.h
index 09f2b1e4..ce69c50e 100644
--- a/luadebug.h
+++ b/luadebug.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luadebug.h,v 1.9 2000/01/19 12:00:45 roberto Exp roberto $ 2** $Id: luadebug.h,v 1.10 2000/03/30 17:19:48 roberto Exp roberto $
3** Debugging API 3** Debugging API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -22,8 +22,6 @@ int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
22int lua_getlocal (lua_State *L, const lua_Debug *ar, lua_Localvar *v); 22int lua_getlocal (lua_State *L, const lua_Debug *ar, lua_Localvar *v);
23int lua_setlocal (lua_State *L, const lua_Debug *ar, lua_Localvar *v); 23int lua_setlocal (lua_State *L, const lua_Debug *ar, lua_Localvar *v);
24 24
25int lua_setdebug (lua_State *L, int debug);
26
27lua_Hook lua_setcallhook (lua_State *L, lua_Hook func); 25lua_Hook lua_setcallhook (lua_State *L, lua_Hook func);
28lua_Hook lua_setlinehook (lua_State *L, lua_Hook func); 26lua_Hook lua_setlinehook (lua_State *L, lua_Hook func);
29 27
diff --git a/lvm.c b/lvm.c
index 0ea8ea9f..1a7629de 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.120 2000/06/30 14:35:17 roberto Exp roberto $ 2** $Id: lvm.c,v 1.121 2000/08/08 18:26:05 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -71,19 +71,17 @@ static void traceexec (lua_State *L, StkId base, StkId top, lua_Hook linehook) {
71 CallInfo *ci = infovalue(base-1); 71 CallInfo *ci = infovalue(base-1);
72 int *lineinfo = ci->func->f.l->lineinfo; 72 int *lineinfo = ci->func->f.l->lineinfo;
73 int pc = (*ci->pc - 1) - ci->func->f.l->code; 73 int pc = (*ci->pc - 1) - ci->func->f.l->code;
74 if (lineinfo) { 74 int newline;
75 int newline; 75 if (ci->line == 0) { /* first time? */
76 if (ci->line == 0) { /* first time? */ 76 ci->line = 1;
77 ci->line = 1; 77 ci->refi = 0;
78 ci->refi = 0; 78 }
79 } 79 newline = luaG_getline(lineinfo, pc, ci->line, &ci->refi);
80 newline = luaG_getline(lineinfo, pc, ci->line, &ci->refi); 80 /* calls linehook when enters a new line or jumps back (loop) */
81 /* calls linehook when enters a new line or jumps back (loop) */ 81 if (newline != ci->line || pc <= ci->lastpc) {
82 if (newline != ci->line || pc <= ci->lastpc) { 82 ci->line = newline;
83 ci->line = newline; 83 L->top = top;
84 L->top = top; 84 luaD_lineHook(L, base-2, newline, linehook);
85 luaD_lineHook(L, base-2, newline, linehook);
86 }
87 } 85 }
88 ci->lastpc = pc; 86 ci->lastpc = pc;
89} 87}