about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-03-13 17:36:01 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-03-13 17:36:01 -0700
commitb68405fe319c1300cc44425d8df5ebd6e3ee6ab4 (patch)
tree5598700f0d9d1e57a35918a0bdfada1dd28dcc91
parent776d9f90325f37e65bc7321138bd929eeee7a69e (diff)
downloadteliva-b68405fe319c1300cc44425d8df5ebd6e3ee6ab4.tar.gz
delete debug library
There's security issues here, and they're subtle. Dropping for now until
I or someone else finds a need for them.
-rw-r--r--doc/contents.html1
-rw-r--r--doc/manual.html278
-rw-r--r--src/Makefile3
-rw-r--r--src/ldblib.c398
-rw-r--r--src/linit.c1
5 files changed, 1 insertions, 680 deletions
diff --git a/doc/contents.html b/doc/contents.html
index 3a45a17..3f237bc 100644
--- a/doc/contents.html
+++ b/doc/contents.html
@@ -109,7 +109,6 @@ Freely available under the terms of the
 <LI><A HREF="manual.html#5.6">5.6 &ndash; Mathematical Functions</A>
 <LI><span class='teliva'><A HREF="manual.html#5.7">5.7 &ndash; File Input and Output Facilities</A></span>
 <LI><A HREF="manual.html#5.8">5.8 &ndash; Operating System Facilities</A>
-<LI><A HREF="manual.html#5.9">5.9 &ndash; The Debug Library</A>
 <LI><span class='teliva'><A HREF="manual.html#5.10">5.10 &ndash; Curses Window Facilities</A></span>
 <LI><span class='teliva'><A HREF="manual.html#5.11">5.11 &ndash; Networking Facilities</A></span>
 <LI><span class='teliva'><A HREF="manual.html#5.12">5.12 &ndash; JSON Facilities</A></span>
diff --git a/doc/manual.html b/doc/manual.html
index e6e2240..1b58c4c 100644
--- a/doc/manual.html
+++ b/doc/manual.html
@@ -4109,284 +4109,6 @@ which automatically removes the file when the program ends.
 
 
 
-<h2>5.9 - <a name="5.9">The Debug Library</a></h2>
-
-<p>
-This library provides
-the functionality of the debug interface to Lua programs.
-You should exert care when using this library.
-The functions provided here should be used exclusively for debugging
-and similar tasks, such as profiling.
-Please resist the temptation to use them as a
-usual programming tool:
-they can be very slow.
-Moreover, several of these functions
-violate some assumptions about Lua code
-(e.g., that variables local to a function
-cannot be accessed from outside or
-that userdata metatables cannot be changed by Lua code)
-and therefore can compromise otherwise secure code.
-<div class='teliva'>TODO: what do we need to secure here?</div>
-
-
-<p>
-All functions in this library are provided
-inside the <a name="pdf-debug"><code>debug</code></a> table.
-All functions that operate over a thread
-have an optional first argument which is the
-thread to operate over.
-The default is always the current thread.
-
-
-<p>
-<hr><h3><a name="pdf-debug.debug"><code>debug.debug ()</code></a></h3>
-
-
-<p>
-Enters an interactive mode with the user,
-running each string that the user enters.
-Using simple commands and other debug facilities,
-the user can inspect global and local variables,
-change their values, evaluate expressions, and so on.
-A line containing only the word <code>cont</code> finishes this function,
-so that the caller continues its execution.
-
-
-<p>
-Note that commands for <code>debug.debug</code> are not lexically nested
-within any function, and so have no direct access to local variables.
-
-
-
-
-<p>
-<hr><h3><a name="pdf-debug.getfenv"><code>debug.getfenv (o)</code></a></h3>
-Returns the environment of object <code>o</code>.
-
-
-
-
-<p>
-<hr><h3><a name="pdf-debug.gethook"><code>debug.gethook ([thread])</code></a></h3>
-
-
-<p>
-Returns the current hook settings of the thread, as three values:
-the current hook function, the current hook mask,
-and the current hook count
-(as set by the <a href="#pdf-debug.sethook"><code>debug.sethook</code></a> function).
-
-
-
-
-<p>
-<hr><h3><a name="pdf-debug.getinfo"><code>debug.getinfo ([thread,] function [, what])</code></a></h3>
-
-
-<p>
-Returns a table with information about a function.
-You can give the function directly,
-or you can give a number as the value of <code>function</code>,
-which means the function running at level <code>function</code> of the call stack
-of the given thread:
-level&nbsp;0 is the current function (<code>getinfo</code> itself);
-level&nbsp;1 is the function that called <code>getinfo</code>;
-and so on.
-If <code>function</code> is a number larger than the number of active functions,
-then <code>getinfo</code> returns <b>nil</b>.
-
-
-<p>
-The returned table can contain all the fields returned by <a href="#lua_getinfo"><code>lua_getinfo</code></a>,
-with the string <code>what</code> describing which fields to fill in.
-The default for <code>what</code> is to get all information available,
-except the table of valid lines.
-If present,
-the option '<code>f</code>'
-adds a field named <code>func</code> with the function itself.
-If present,
-the option '<code>L</code>'
-adds a field named <code>activelines</code> with the table of
-valid lines.
-
-
-<p>
-For instance, the expression <code>debug.getinfo(1,"n").name</code> returns
-a table with a name for the current function,
-if a reasonable name can be found,
-and the expression <code>debug.getinfo(print)</code>
-returns a table with all available information
-about the <a href="#pdf-print"><code>print</code></a> function.
-
-
-
-
-<p>
-<hr><h3><a name="pdf-debug.getlocal"><code>debug.getlocal ([thread,] level, local)</code></a></h3>
-
-
-<p>
-This function returns the name and the value of the local variable
-with index <code>local</code> of the function at level <code>level</code> of the stack.
-(The first parameter or local variable has index&nbsp;1, and so on,
-until the last active local variable.)
-The function returns <b>nil</b> if there is no local
-variable with the given index,
-and raises an error when called with a <code>level</code> out of range.
-(You can call <a href="#pdf-debug.getinfo"><code>debug.getinfo</code></a> to check whether the level is valid.)
-
-
-<p>
-Variable names starting with '<code>(</code>' (open parentheses)
-represent internal variables
-(loop control variables, temporaries, and C&nbsp;function locals).
-
-
-
-
-<p>
-<hr><h3><a name="pdf-debug.getmetatable"><code>debug.getmetatable (object)</code></a></h3>
-
-
-<p>
-Returns the metatable of the given <code>object</code>
-or <b>nil</b> if it does not have a metatable.
-
-
-
-
-<p>
-<hr><h3><a name="pdf-debug.getregistry"><code>debug.getregistry ()</code></a></h3>
-
-
-<p>
-Returns the registry table (see <a href="#3.5">&sect;3.5</a>).
-
-
-
-
-<p>
-<hr><h3><a name="pdf-debug.getupvalue"><code>debug.getupvalue (func, up)</code></a></h3>
-
-
-<p>
-This function returns the name and the value of the upvalue
-with index <code>up</code> of the function <code>func</code>.
-The function returns <b>nil</b> if there is no upvalue with the given index.
-
-
-
-
-<p>
-<hr><h3><a name="pdf-debug.setfenv"><code>debug.setfenv (object, table)</code></a></h3>
-
-
-<p>
-Sets the environment of the given <code>object</code> to the given <code>table</code>.
-Returns <code>object</code>.
-
-
-
-
-<p>
-<hr><h3><a name="pdf-debug.sethook"><code>debug.sethook ([thread,] hook, mask [, count])</code></a></h3>
-
-
-<p>
-Sets the given function as a hook.
-The string <code>mask</code> and the number <code>count</code> describe
-when the hook will be called.
-The string mask may have the following characters,
-with the given meaning:
-
-<ul>
-<li><b><code>"c"</code>:</b> the hook is called every time Lua calls a function;</li>
-<li><b><code>"r"</code>:</b> the hook is called every time Lua returns from a function;</li>
-<li><b><code>"l"</code>:</b> the hook is called every time Lua enters a new line of code.</li>
-</ul><p>
-With a <code>count</code> different from zero,
-the hook is called after every <code>count</code> instructions.
-
-
-<p>
-When called without arguments,
-<a href="#pdf-debug.sethook"><code>debug.sethook</code></a> turns off the hook.
-
-
-<p>
-When the hook is called, its first parameter is a string
-describing the event that has triggered its call:
-<code>"call"</code>, <code>"return"</code> (or <code>"tail return"</code>,
-when simulating a return from a tail call),
-<code>"line"</code>, and <code>"count"</code>.
-For line events,
-the hook also gets the new line number as its second parameter.
-Inside a hook,
-you can call <code>getinfo</code> with level&nbsp;2 to get more information about
-the running function
-(level&nbsp;0 is the <code>getinfo</code> function,
-and level&nbsp;1 is the hook function),
-unless the event is <code>"tail return"</code>.
-In this case, Lua is only simulating the return,
-and a call to <code>getinfo</code> will return invalid data.
-
-
-
-
-<p>
-<hr><h3><a name="pdf-debug.setlocal"><code>debug.setlocal ([thread,] level, local, value)</code></a></h3>
-
-
-<p>
-This function assigns the value <code>value</code> to the local variable
-with index <code>local</code> of the function at level <code>level</code> of the stack.
-The function returns <b>nil</b> if there is no local
-variable with the given index,
-and raises an error when called with a <code>level</code> out of range.
-(You can call <code>getinfo</code> to check whether the level is valid.)
-Otherwise, it returns the name of the local variable.
-
-
-
-
-<p>
-<hr><h3><a name="pdf-debug.setmetatable"><code>debug.setmetatable (object, table)</code></a></h3>
-
-
-<p>
-Sets the metatable for the given <code>object</code> to the given <code>table</code>
-(which can be <b>nil</b>).
-
-
-
-
-<p>
-<hr><h3><a name="pdf-debug.setupvalue"><code>debug.setupvalue (func, up, value)</code></a></h3>
-
-
-<p>
-This function assigns the value <code>value</code> to the upvalue
-with index <code>up</code> of the function <code>func</code>.
-The function returns <b>nil</b> if there is no upvalue
-with the given index.
-Otherwise, it returns the name of the upvalue.
-
-
-
-
-<p>
-<hr><h3><a name="pdf-debug.traceback"><code>debug.traceback ([thread,] [message [, level]])</code></a></h3>
-
-
-<p>
-Returns a string with a traceback of the call stack.
-An optional <code>message</code> string is appended
-at the beginning of the traceback.
-An optional <code>level</code> number tells at which level
-to start the traceback
-(default is 1, the function calling <code>traceback</code>).
-
-
 <div class='teliva'>
 <h2>5.10 - <a name="5.10">Curses Window Facilities</a></h2>
 
diff --git a/src/Makefile b/src/Makefile
index 125e056..bd59283 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -28,7 +28,7 @@ CORE_O=	lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
 	lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o  \
 	lundump.o lvm.o lzio.o \
 	realpath.o lfs.o kilo.o tlv.o teliva.o
-LIB_O=	lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o \
+LIB_O=	lauxlib.o lbaselib.o liolib.o lmathlib.o loslib.o \
 	ltablib.o lstrlib.o linit.o
 
 LUA_T=	teliva
@@ -121,7 +121,6 @@ lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h
 lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \
   lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \
   ltable.h
-ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h
 ldebug.o: ldebug.c lua.h luaconf.h lapi.h lobject.h llimits.h lcode.h \
   llex.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \
   lfunc.h lstring.h lgc.h ltable.h lvm.h
diff --git a/src/ldblib.c b/src/ldblib.c
deleted file mode 100644
index 2027eda..0000000
--- a/src/ldblib.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
-** $Id: ldblib.c,v 1.104.1.4 2009/08/04 18:50:18 roberto Exp $
-** Interface from Lua to its debug API
-** See Copyright Notice in lua.h
-*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define ldblib_c
-#define LUA_LIB
-
-#include "lua.h"
-
-#include "lauxlib.h"
-#include "lualib.h"
-
-
-
-static int db_getregistry (lua_State *L) {
-  lua_pushvalue(L, LUA_REGISTRYINDEX);
-  return 1;
-}
-
-
-static int db_getmetatable (lua_State *L) {
-  luaL_checkany(L, 1);
-  if (!lua_getmetatable(L, 1)) {
-    lua_pushnil(L);  /* no metatable */
-  }
-  return 1;
-}
-
-
-static int db_setmetatable (lua_State *L) {
-  int t = lua_type(L, 2);
-  luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
-                    "nil or table expected");
-  lua_settop(L, 2);
-  lua_pushboolean(L, lua_setmetatable(L, 1));
-  return 1;
-}
-
-
-static int db_getfenv (lua_State *L) {
-  luaL_checkany(L, 1);
-  lua_getfenv(L, 1);
-  return 1;
-}
-
-
-static int db_setfenv (lua_State *L) {
-  luaL_checktype(L, 2, LUA_TTABLE);
-  lua_settop(L, 2);
-  if (lua_setfenv(L, 1) == 0)
-    luaL_error(L, LUA_QL("setfenv")
-                  " cannot change environment of given object");
-  return 1;
-}
-
-
-static void settabss (lua_State *L, const char *i, const char *v) {
-  lua_pushstring(L, v);
-  lua_setfield(L, -2, i);
-}
-
-
-static void settabsi (lua_State *L, const char *i, int v) {
-  lua_pushinteger(L, v);
-  lua_setfield(L, -2, i);
-}
-
-
-static lua_State *getthread (lua_State *L, int *arg) {
-  if (lua_isthread(L, 1)) {
-    *arg = 1;
-    return lua_tothread(L, 1);
-  }
-  else {
-    *arg = 0;
-    return L;
-  }
-}
-
-
-static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) {
-  if (L == L1) {
-    lua_pushvalue(L, -2);
-    lua_remove(L, -3);
-  }
-  else
-    lua_xmove(L1, L, 1);
-  lua_setfield(L, -2, fname);
-}
-
-
-static int db_getinfo (lua_State *L) {
-  lua_Debug ar;
-  int arg;
-  lua_State *L1 = getthread(L, &arg);
-  const char *options = luaL_optstring(L, arg+2, "flnSu");
-  if (lua_isnumber(L, arg+1)) {
-    if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) {
-      lua_pushnil(L);  /* level out of range */
-      return 1;
-    }
-  }
-  else if (lua_isfunction(L, arg+1)) {
-    lua_pushfstring(L, ">%s", options);
-    options = lua_tostring(L, -1);
-    lua_pushvalue(L, arg+1);
-    lua_xmove(L, L1, 1);
-  }
-  else
-    return luaL_argerror(L, arg+1, "function or level expected");
-  if (!lua_getinfo(L1, options, &ar))
-    return luaL_argerror(L, arg+2, "invalid option");
-  lua_createtable(L, 0, 2);
-  if (strchr(options, 'S')) {
-    settabss(L, "source", ar.source);
-    settabss(L, "short_src", ar.short_src);
-    settabsi(L, "linedefined", ar.linedefined);
-    settabsi(L, "lastlinedefined", ar.lastlinedefined);
-    settabss(L, "what", ar.what);
-  }
-  if (strchr(options, 'l'))
-    settabsi(L, "currentline", ar.currentline);
-  if (strchr(options, 'u'))
-    settabsi(L, "nups", ar.nups);
-  if (strchr(options, 'n')) {
-    settabss(L, "name", ar.name);
-    settabss(L, "namewhat", ar.namewhat);
-  }
-  if (strchr(options, 'L'))
-    treatstackoption(L, L1, "activelines");
-  if (strchr(options, 'f'))
-    treatstackoption(L, L1, "func");
-  return 1;  /* return table */
-}
-    
-
-static int db_getlocal (lua_State *L) {
-  int arg;
-  lua_State *L1 = getthread(L, &arg);
-  lua_Debug ar;
-  const char *name;
-  if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar))  /* out of range? */
-    return luaL_argerror(L, arg+1, "level out of range");
-  name = lua_getlocal(L1, &ar, luaL_checkint(L, arg+2));
-  if (name) {
-    lua_xmove(L1, L, 1);
-    lua_pushstring(L, name);
-    lua_pushvalue(L, -2);
-    return 2;
-  }
-  else {
-    lua_pushnil(L);
-    return 1;
-  }
-}
-
-
-static int db_setlocal (lua_State *L) {
-  int arg;
-  lua_State *L1 = getthread(L, &arg);
-  lua_Debug ar;
-  if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar))  /* out of range? */
-    return luaL_argerror(L, arg+1, "level out of range");
-  luaL_checkany(L, arg+3);
-  lua_settop(L, arg+3);
-  lua_xmove(L, L1, 1);
-  lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2)));
-  return 1;
-}
-
-
-static int auxupvalue (lua_State *L, int get) {
-  const char *name;
-  int n = luaL_checkint(L, 2);
-  luaL_checktype(L, 1, LUA_TFUNCTION);
-  if (lua_iscfunction(L, 1)) return 0;  /* cannot touch C upvalues from Lua */
-  name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n);
-  if (name == NULL) return 0;
-  lua_pushstring(L, name);
-  lua_insert(L, -(get+1));
-  return get + 1;
-}
-
-
-static int db_getupvalue (lua_State *L) {
-  return auxupvalue(L, 1);
-}
-
-
-static int db_setupvalue (lua_State *L) {
-  luaL_checkany(L, 3);
-  return auxupvalue(L, 0);
-}
-
-
-
-static const char KEY_HOOK = 'h';
-
-
-static void hookf (lua_State *L, lua_Debug *ar) {
-  static const char *const hooknames[] =
-    {"call", "return", "line", "count", "tail return"};
-  lua_pushlightuserdata(L, (void *)&KEY_HOOK);
-  lua_rawget(L, LUA_REGISTRYINDEX);
-  lua_pushlightuserdata(L, L);
-  lua_rawget(L, -2);
-  if (lua_isfunction(L, -1)) {
-    lua_pushstring(L, hooknames[(int)ar->event]);
-    if (ar->currentline >= 0)
-      lua_pushinteger(L, ar->currentline);
-    else lua_pushnil(L);
-    lua_assert(lua_getinfo(L, "lS", ar));
-    lua_call(L, 2, 0);
-  }
-}
-
-
-static int makemask (const char *smask, int count) {
-  int mask = 0;
-  if (strchr(smask, 'c')) mask |= LUA_MASKCALL;
-  if (strchr(smask, 'r')) mask |= LUA_MASKRET;
-  if (strchr(smask, 'l')) mask |= LUA_MASKLINE;
-  if (count > 0) mask |= LUA_MASKCOUNT;
-  return mask;
-}
-
-
-static char *unmakemask (int mask, char *smask) {
-  int i = 0;
-  if (mask & LUA_MASKCALL) smask[i++] = 'c';
-  if (mask & LUA_MASKRET) smask[i++] = 'r';
-  if (mask & LUA_MASKLINE) smask[i++] = 'l';
-  smask[i] = '\0';
-  return smask;
-}
-
-
-static void gethooktable (lua_State *L) {
-  lua_pushlightuserdata(L, (void *)&KEY_HOOK);
-  lua_rawget(L, LUA_REGISTRYINDEX);
-  if (!lua_istable(L, -1)) {
-    lua_pop(L, 1);
-    lua_createtable(L, 0, 1);
-    lua_pushlightuserdata(L, (void *)&KEY_HOOK);
-    lua_pushvalue(L, -2);
-    lua_rawset(L, LUA_REGISTRYINDEX);
-  }
-}
-
-
-static int db_sethook (lua_State *L) {
-  int arg, mask, count;
-  lua_Hook func;
-  lua_State *L1 = getthread(L, &arg);
-  if (lua_isnoneornil(L, arg+1)) {
-    lua_settop(L, arg+1);
-    func = NULL; mask = 0; count = 0;  /* turn off hooks */
-  }
-  else {
-    const char *smask = luaL_checkstring(L, arg+2);
-    luaL_checktype(L, arg+1, LUA_TFUNCTION);
-    count = luaL_optint(L, arg+3, 0);
-    func = hookf; mask = makemask(smask, count);
-  }
-  gethooktable(L);
-  lua_pushlightuserdata(L, L1);
-  lua_pushvalue(L, arg+1);
-  lua_rawset(L, -3);  /* set new hook */
-  lua_pop(L, 1);  /* remove hook table */
-  lua_sethook(L1, func, mask, count);  /* set hooks */
-  return 0;
-}
-
-
-static int db_gethook (lua_State *L) {
-  int arg;
-  lua_State *L1 = getthread(L, &arg);
-  char buff[5];
-  int mask = lua_gethookmask(L1);
-  lua_Hook hook = lua_gethook(L1);
-  if (hook != NULL && hook != hookf)  /* external hook? */
-    lua_pushliteral(L, "external hook");
-  else {
-    gethooktable(L);
-    lua_pushlightuserdata(L, L1);
-    lua_rawget(L, -2);   /* get hook */
-    lua_remove(L, -2);  /* remove hook table */
-  }
-  lua_pushstring(L, unmakemask(mask, buff));
-  lua_pushinteger(L, lua_gethookcount(L1));
-  return 3;
-}
-
-
-static int db_debug (lua_State *L) {
-  for (;;) {
-    char buffer[250];
-    fputs("lua_debug> ", stderr);
-    if (fgets(buffer, sizeof(buffer), stdin) == 0 ||
-        strcmp(buffer, "cont\n") == 0)
-      return 0;
-    if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") ||
-        lua_pcall(L, 0, 0, 0)) {
-      fputs(lua_tostring(L, -1), stderr);
-      fputs("\n", stderr);
-    }
-    lua_settop(L, 0);  /* remove eventual returns */
-  }
-}
-
-
-#define LEVELS1	12	/* size of the first part of the stack */
-#define LEVELS2	10	/* size of the second part of the stack */
-
-static int db_errorfb (lua_State *L) {
-  int level;
-  int firstpart = 1;  /* still before eventual `...' */
-  int arg;
-  lua_State *L1 = getthread(L, &arg);
-  lua_Debug ar;
-  if (lua_isnumber(L, arg+2)) {
-    level = (int)lua_tointeger(L, arg+2);
-    lua_pop(L, 1);
-  }
-  else
-    level = (L == L1) ? 1 : 0;  /* level 0 may be this own function */
-  if (lua_gettop(L) == arg)
-    lua_pushliteral(L, "");
-  else if (!lua_isstring(L, arg+1)) return 1;  /* message is not a string */
-  else lua_pushliteral(L, "\n");
-  lua_pushliteral(L, "stack traceback:");
-  while (lua_getstack(L1, level++, &ar)) {
-    if (level > LEVELS1 && firstpart) {
-      /* no more than `LEVELS2' more levels? */
-      if (!lua_getstack(L1, level+LEVELS2, &ar))
-        level--;  /* keep going */
-      else {
-        lua_pushliteral(L, "\n\t...");  /* too many levels */
-        while (lua_getstack(L1, level+LEVELS2, &ar))  /* find last levels */
-          level++;
-      }
-      firstpart = 0;
-      continue;
-    }
-    lua_pushliteral(L, "\n\t");
-    lua_getinfo(L1, "Snl", &ar);
-    lua_pushfstring(L, "%s:", ar.short_src);
-    if (ar.currentline > 0)
-      lua_pushfstring(L, "%d:", ar.currentline);
-    if (*ar.namewhat != '\0')  /* is there a name? */
-        lua_pushfstring(L, " in function " LUA_QS, ar.name);
-    else {
-      if (*ar.what == 'm')  /* main? */
-        lua_pushfstring(L, " in main chunk");
-      else if (*ar.what == 'C' || *ar.what == 't')
-        lua_pushliteral(L, " ?");  /* C function or tail call */
-      else
-        lua_pushfstring(L, " in function <%s:%d>",
-                           ar.short_src, ar.linedefined);
-    }
-    lua_concat(L, lua_gettop(L) - arg);
-  }
-  lua_concat(L, lua_gettop(L) - arg);
-  return 1;
-}
-
-
-static const luaL_Reg dblib[] = {
-  {"debug", db_debug},
-  {"getfenv", db_getfenv},
-  {"gethook", db_gethook},
-  {"getinfo", db_getinfo},
-  {"getlocal", db_getlocal},
-  {"getregistry", db_getregistry},
-  {"getmetatable", db_getmetatable},
-  {"getupvalue", db_getupvalue},
-  {"setfenv", db_setfenv},
-  {"sethook", db_sethook},
-  {"setlocal", db_setlocal},
-  {"setmetatable", db_setmetatable},
-  {"setupvalue", db_setupvalue},
-  {"traceback", db_errorfb},
-  {NULL, NULL}
-};
-
-
-LUALIB_API int luaopen_debug (lua_State *L) {
-  luaL_register(L, LUA_DBLIBNAME, dblib);
-  return 1;
-}
-
diff --git a/src/linit.c b/src/linit.c
index fd32a0d..3df394f 100644
--- a/src/linit.c
+++ b/src/linit.c
@@ -29,7 +29,6 @@ static const luaL_Reg lualibs[] = {
   {LUA_SSLCONTEXTLIBNAME, luaopen_ssl_context},
   {LUA_SSLX509LIBNAME, luaopen_ssl_x509},
   {LUA_SSLCONFIGLIBNAME, luaopen_ssl_config},
-  {LUA_DBLIBNAME, luaopen_debug},
   {NULL, NULL}
 };