Forráskód Böngészése

no more options for debug information: it is always on

Roberto Ierusalimschy 25 éve
szülő
commit
0802a9df9e
13 módosított fájl, 40 hozzáadás és 75 törlés
  1. 2 3
      lcode.c
  2. 5 12
      ldebug.c
  3. 1 4
      ldo.c
  4. 1 3
      lfunc.c
  5. 4 6
      lgc.c
  6. 1 4
      llex.c
  7. 8 14
      lparser.c
  8. 1 2
      lparser.h
  9. 1 2
      lstate.c
  10. 1 2
      lstate.h
  11. 2 6
      ltests.c
  12. 1 3
      luadebug.h
  13. 12 14
      lvm.c

+ 2 - 3
lcode.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lcode.c,v 1.42 2000/08/04 19:38:35 roberto Exp roberto $
+** $Id: lcode.c,v 1.43 2000/08/08 18:26:05 roberto Exp roberto $
 ** Code generator for Lua
 ** See Copyright Notice in lua.h
 */
@@ -631,8 +631,7 @@ int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) {
     case iS: i = CREATE_S(o, arg1); break;
     case iAB: i = CREATE_AB(o, arg1, arg2); break;
   }
-  if (fs->debug)
-    codelineinfo(fs);
+  codelineinfo(fs);
   /* put new instruction in code array */
   luaM_growvector(fs->L, fs->f->code, fs->pc, 1, Instruction,
                   "code size overflow", MAX_INT);

+ 5 - 12
ldebug.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldebug.c,v 1.28 2000/08/07 20:21:34 roberto Exp roberto $
+** $Id: ldebug.c,v 1.29 2000/08/08 18:26:05 roberto Exp roberto $
 ** Debug Interface
 ** See Copyright Notice in lua.h
 */
@@ -57,13 +57,6 @@ lua_Hook lua_setlinehook (lua_State *L, lua_Hook func) {
 }
 
 
-int lua_setdebug (lua_State *L, int debug) {
-  int old = L->debug;
-  L->debug = debug;
-  return old;
-}
-
-
 static StkId aux_stackedfunction (lua_State *L, int level, StkId top) {
   int i;
   for (i = (top-1)-L->stack; i>=0; i--) {
@@ -140,9 +133,7 @@ static int lua_currentline (StkId f) {
   else {
     CallInfo *ci = infovalue(f);
     int *lineinfo = ci->func->f.l->lineinfo;
-    if (!lineinfo) return -1;  /* no static debug information */
-    else
-      return luaG_getline(lineinfo, lua_currentpc(f), 1, NULL);
+    return luaG_getline(lineinfo, lua_currentpc(f), 1, NULL);
   }
 }
 
@@ -382,7 +373,8 @@ static const char *getname (lua_State *L, StkId obj, const char **name) {
       }
       case OP_GETLOCAL: {
         *name = luaF_getlocalname(p, GETARG_U(i)+1, pc);
-        return (*name) ? "local" : NULL;
+        LUA_ASSERT(*name, "local must exist");
+        return "local";
       }
       case OP_PUSHSELF:
       case OP_GETDOTTED: {
@@ -418,3 +410,4 @@ void luaG_callerror (lua_State *L, StkId func) {
 void luaG_indexerror (lua_State *L, StkId t) {
   call_index_error(L, t, "index", "table");
 }
+

+ 1 - 4
ldo.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldo.c,v 1.81 2000/06/28 20:20:36 roberto Exp roberto $
+** $Id: ldo.c,v 1.82 2000/08/04 19:38:35 roberto Exp roberto $
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 */
@@ -25,7 +25,6 @@
 #include "lstring.h"
 #include "ltable.h"
 #include "ltm.h"
-#include "luadebug.h"
 #include "lundump.h"
 #include "lvm.h"
 #include "lzio.h"
@@ -324,7 +323,6 @@ static int protectedparser (lua_State *L, ZIO *z, int bin) {
 
 static int do_main (lua_State *L, ZIO *z, int bin) {
   int status;
-  int debug = L->debug;  /* save debug status */
   do {
     unsigned long old_blocks;
     luaC_checkGC(L);
@@ -339,7 +337,6 @@ static int do_main (lua_State *L, ZIO *z, int bin) {
       L->GCthreshold -= newelems2;
     }
   } while (bin && status == 0);
-  L->debug = debug;  /* restore debug status */
   return status;
 }
 

+ 1 - 3
lfunc.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lfunc.c,v 1.26 2000/08/07 20:21:34 roberto Exp roberto $
+** $Id: lfunc.c,v 1.27 2000/08/08 18:26:05 roberto Exp roberto $
 ** Auxiliary functions to manipulate prototypes and closures
 ** See Copyright Notice in lua.h
 */
@@ -79,8 +79,6 @@ const char *luaF_getlocalname (const Proto *func, int local_number, int pc) {
   int count = 0;
   const char *varname = NULL;
   LocVar *lv = func->locvars;
-  if (lv == NULL)
-    return NULL;
   for (; lv->pc != -1 && lv->pc <= pc; lv++) {
     if (lv->varname) {  /* register */
       if (++count == local_number)

+ 4 - 6
lgc.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lgc.c,v 1.59 2000/06/30 14:35:17 roberto Exp roberto $
+** $Id: lgc.c,v 1.60 2000/08/07 20:21:34 roberto Exp roberto $
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 */
@@ -44,11 +44,9 @@ static void protomark (Proto *f) {
       strmark(f->kstr[i]);
     for (i=0; i<f->nkproto; i++)
       protomark(f->kproto[i]);
-    if (f->locvars) {  /* is there debug information? */
-      LocVar *lv;
-      for (lv=f->locvars; lv->pc != -1; lv++)  /* mark local-variable names */
-        if (lv->varname) strmark(lv->varname);
-    }
+    for (i=0; f->locvars[i].pc != -1; i++)  /* mark local-variable names */
+      if (f->locvars[i].varname)
+        strmark(f->locvars[i].varname);
   }
 }
 

+ 1 - 4
llex.c

@@ -1,5 +1,5 @@
 /*
-** $Id: llex.c,v 1.64 2000/06/19 18:05:14 roberto Exp roberto $
+** $Id: llex.c,v 1.65 2000/06/21 18:13:56 roberto Exp roberto $
 ** Lexical Analyzer
 ** See Copyright Notice in lua.h
 */
@@ -120,10 +120,7 @@ static void checkpragma (lua_State *L, LexState *LS) {
   if (LS->current == '$') {  /* is a pragma? */
     switch (luaL_findstring(readname(L, LS)+1, pragmas)) {
       case 0:  /* debug */
-        L->debug = 1;
-        break;
       case 1:  /* nodebug */
-        L->debug = 0;
         break;
       default:
         luaX_error(LS, "unknown pragma", TK_STRING);

+ 8 - 14
lparser.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lparser.c,v 1.102 2000/06/30 14:35:17 roberto Exp roberto $
+** $Id: lparser.c,v 1.103 2000/08/08 18:26:05 roberto Exp roberto $
 ** LL(1) Parser and code generator for Lua
 ** See Copyright Notice in lua.h
 */
@@ -154,13 +154,11 @@ static int checkname (LexState *ls) {
 
 static void luaI_registerlocalvar (LexState *ls, TString *varname, int pc) {
   FuncState *fs = ls->fs;
-  if (fs->debug) {
-    Proto *f = fs->f;
-    luaM_growvector(ls->L, f->locvars, fs->nvars, 1, LocVar, "", MAX_INT);
-    f->locvars[fs->nvars].varname = varname;
-    f->locvars[fs->nvars].pc = pc;
-    fs->nvars++;
-  }
+  Proto *f = fs->f;
+  luaM_growvector(ls->L, f->locvars, fs->nvars, 1, LocVar, "", MAX_INT);
+  f->locvars[fs->nvars].varname = varname;
+  f->locvars[fs->nvars].pc = pc;
+  fs->nvars++;
 }
 
 
@@ -350,10 +348,8 @@ static void close_func (LexState *ls) {
   luaM_reallocvector(L, f->kproto, f->nkproto, Proto *);
   luaI_registerlocalvar(ls, NULL, -1);  /* flag end of vector */
   luaM_reallocvector(L, f->locvars, fs->nvars, LocVar);
-  if (fs->debug) {
-    luaM_reallocvector(L, f->lineinfo, fs->nlineinfo+1, int);
-    f->lineinfo[fs->nlineinfo] = MAX_INT;  /* end flag */
-  }
+  luaM_reallocvector(L, f->lineinfo, fs->nlineinfo+1, int);
+  f->lineinfo[fs->nlineinfo] = MAX_INT;  /* end flag */
   ls->fs = fs->prev;
   LUA_ASSERT(fs->bl == NULL, "wrong list end");
 }
@@ -365,7 +361,6 @@ Proto *luaY_parser (lua_State *L, ZIO *z) {
   luaX_setinput(L, &lexstate, z, luaS_new(L, zname(z)));
   open_func(&lexstate, &funcstate);
   next(&lexstate);  /* read first token */
-  funcstate.debug = L->debug;  /* previous `next' may scan a pragma */
   chunk(&lexstate);
   check_condition(&lexstate, (lexstate.t.token == TK_EOS), "<eof> expected");
   close_func(&lexstate);
@@ -1091,7 +1086,6 @@ static void body (LexState *ls, int needself, int line) {
   FuncState new_fs;
   open_func(ls, &new_fs);
   new_fs.f->lineDefined = line;
-  new_fs.debug = ls->L->debug;
   check(ls, '(');
   if (needself) {
     new_localvarstr(ls, "self", 0);

+ 1 - 2
lparser.h

@@ -1,5 +1,5 @@
 /*
-** $Id: lparser.h,v 1.20 2000/06/28 20:20:36 roberto Exp roberto $
+** $Id: lparser.h,v 1.21 2000/08/08 18:26:05 roberto Exp roberto $
 ** LL(1) Parser and code generator for Lua
 ** See Copyright Notice in lua.h
 */
@@ -47,7 +47,6 @@ typedef struct FuncState {
   int stacklevel;  /* number of values on activation register */
   int nlocalvar;  /* number of active local variables */
   int nupvalues;  /* number of upvalues */
-  int debug;  /* flag for debug information */
   int nvars;  /* number of entries in f->locvars */
   int lastline;  /* line where last `lineinfo' was generated */
   int nlineinfo;  /* index of next `lineinfo' to be generated */

+ 1 - 2
lstate.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lstate.c,v 1.29 2000/06/30 19:17:08 roberto Exp roberto $
+** $Id: lstate.c,v 1.30 2000/08/04 19:38:35 roberto Exp roberto $
 ** Global State
 ** See Copyright Notice in lua.h
 */
@@ -52,7 +52,6 @@ lua_State *lua_newstate (int stacksize, int put_builtin) {
   L->refFree = NONEXT;
   L->nblocks = 0;
   L->GCthreshold = MAX_INT;  /* to avoid GC during pre-definitions */
-  L->debug = 0;
   L->callhook = NULL;
   L->linehook = NULL;
   L->allowhooks = 1;

+ 1 - 2
lstate.h

@@ -1,5 +1,5 @@
 /*
-** $Id: lstate.h,v 1.34 2000/05/24 13:54:49 roberto Exp roberto $
+** $Id: lstate.h,v 1.35 2000/08/07 18:39:16 roberto Exp roberto $
 ** Global State
 ** See Copyright Notice in lua.h
 */
@@ -79,7 +79,6 @@ struct lua_State {
   int refFree;  /* list of free positions in refArray */
   unsigned long GCthreshold;
   unsigned long nblocks;  /* number of `blocks' currently allocated */
-  int debug;
   lua_Hook callhook;
   lua_Hook linehook;
   int allowhooks;

+ 2 - 6
ltests.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ltests.c,v 1.30 2000/08/04 19:38:35 roberto Exp roberto $
+** $Id: ltests.c,v 1.31 2000/08/08 18:26:05 roberto Exp roberto $
 ** Internal Module for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 */
@@ -69,11 +69,7 @@ static int pushop (Proto *p, int pc) {
   Instruction i = p->code[pc];
   OpCode o = GET_OPCODE(i);
   const char *name = instrname[o];
-  int *lineinfo = p->lineinfo;
-  if (lineinfo)
-    sprintf(buff, "%5d - ", luaG_getline(lineinfo, pc, 1, NULL));
-  else
-    strcpy(buff, "         ");
+  sprintf(buff, "%5d - ", luaG_getline(p->lineinfo, pc, 1, NULL));
   switch ((enum Mode)luaK_opproperties[o].mode) {  
     case iO:
       sprintf(buff+8, "%s", name);

+ 1 - 3
luadebug.h

@@ -1,5 +1,5 @@
 /*
-** $Id: luadebug.h,v 1.9 2000/01/19 12:00:45 roberto Exp roberto $
+** $Id: luadebug.h,v 1.10 2000/03/30 17:19:48 roberto Exp roberto $
 ** Debugging API
 ** See Copyright Notice in lua.h
 */
@@ -22,8 +22,6 @@ int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
 int lua_getlocal (lua_State *L, const lua_Debug *ar, lua_Localvar *v);
 int lua_setlocal (lua_State *L, const lua_Debug *ar, lua_Localvar *v);
 
-int lua_setdebug (lua_State *L, int debug);
-
 lua_Hook lua_setcallhook (lua_State *L, lua_Hook func);
 lua_Hook lua_setlinehook (lua_State *L, lua_Hook func);
 

+ 12 - 14
lvm.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lvm.c,v 1.120 2000/06/30 14:35:17 roberto Exp roberto $
+** $Id: lvm.c,v 1.121 2000/08/08 18:26:05 roberto Exp roberto $
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 */
@@ -71,19 +71,17 @@ static void traceexec (lua_State *L, StkId base, StkId top, lua_Hook linehook) {
   CallInfo *ci = infovalue(base-1);
   int *lineinfo = ci->func->f.l->lineinfo;
   int pc = (*ci->pc - 1) - ci->func->f.l->code;
-  if (lineinfo) {
-    int newline;
-    if (ci->line == 0) {  /* first time? */
-      ci->line = 1;
-      ci->refi = 0;
-    }
-    newline = luaG_getline(lineinfo, pc, ci->line, &ci->refi);
-    /* calls linehook when enters a new line or jumps back (loop) */
-    if (newline != ci->line || pc <= ci->lastpc) {
-      ci->line = newline;
-      L->top = top;
-      luaD_lineHook(L, base-2, newline, linehook);
-    }
+  int newline;
+  if (ci->line == 0) {  /* first time? */
+    ci->line = 1;
+    ci->refi = 0;
+  }
+  newline = luaG_getline(lineinfo, pc, ci->line, &ci->refi);
+  /* calls linehook when enters a new line or jumps back (loop) */
+  if (newline != ci->line || pc <= ci->lastpc) {
+    ci->line = newline;
+    L->top = top;
+    luaD_lineHook(L, base-2, newline, linehook);
   }
   ci->lastpc = pc;
 }