Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
a08626d8
Commit
a08626d8
authored
Aug 31, 2015
by
TerryE
Browse files
Add minimum debug library providing traceback() and getregistry() functions
parent
95e2bbb0
Changes
3
Show whitespace changes
Inline
Side-by-side
app/include/user_modules.h
View file @
a08626d8
...
...
@@ -8,7 +8,8 @@
// #define LUA_USE_BUILTIN_IO // for io.xxx(), partially work
// #define LUA_USE_BUILTIN_OS // for os.xxx(), not work
// #define LUA_USE_BUILTIN_DEBUG // for debug.xxx(), not work
// #define LUA_USE_BUILTIN_DEBUG
#define LUA_USE_BUILTIN_DEBUG_MINIMAL // for debug.getregistry() and debug.traceback()
#define LUA_USE_MODULES
...
...
app/lua/
not_used/
ldblib.c
→
app/lua/ldblib.c
View file @
a08626d8
...
...
@@ -17,6 +17,7 @@
#include "lauxlib.h"
#include "lualib.h"
#include "lrotable.h"
#include "user_modules.h"
...
...
@@ -25,6 +26,7 @@ static int db_getregistry (lua_State *L) {
return
1
;
}
#ifndef LUA_USE_BUILTIN_DEBUG_MINIMAL
static
int
db_getmetatable
(
lua_State
*
L
)
{
luaL_checkany
(
L
,
1
);
...
...
@@ -73,7 +75,7 @@ static void settabsi (lua_State *L, const char *i, int v) {
lua_setfield
(
L
,
-
2
,
i
);
}
#endif
static
lua_State
*
getthread
(
lua_State
*
L
,
int
*
arg
)
{
if
(
lua_isthread
(
L
,
1
))
{
*
arg
=
1
;
...
...
@@ -84,7 +86,7 @@ static lua_State *getthread (lua_State *L, int *arg) {
return
L
;
}
}
#ifndef LUA_USE_BUILTIN_DEBUG_MINIMAL
static
void
treatstackoption
(
lua_State
*
L
,
lua_State
*
L1
,
const
char
*
fname
)
{
if
(
L
==
L1
)
{
...
...
@@ -324,7 +326,7 @@ static int db_debug (lua_State *L) {
lua_settop
(
L
,
0
);
/* remove eventual returns */
}
}
#endif
#define LEVELS1 12
/* size of the first part of the stack */
#define LEVELS2 10
/* size of the second part of the stack */
...
...
@@ -384,12 +386,15 @@ static int db_errorfb (lua_State *L) {
#define MIN_OPT_LEVEL 1
#include "lrodefs.h"
const
LUA_REG_TYPE
dblib
[]
=
{
#ifndef LUA_USE_BUILTIN_DEBUG_MINIMAL
{
LSTRKEY
(
"debug"
),
LFUNCVAL
(
db_debug
)},
{
LSTRKEY
(
"getfenv"
),
LFUNCVAL
(
db_getfenv
)},
{
LSTRKEY
(
"gethook"
),
LFUNCVAL
(
db_gethook
)},
{
LSTRKEY
(
"getinfo"
),
LFUNCVAL
(
db_getinfo
)},
{
LSTRKEY
(
"getlocal"
),
LFUNCVAL
(
db_getlocal
)},
#endif
{
LSTRKEY
(
"getregistry"
),
LFUNCVAL
(
db_getregistry
)},
#ifndef LUA_USE_BUILTIN_DEBUG_MINIMAL
{
LSTRKEY
(
"getmetatable"
),
LFUNCVAL
(
db_getmetatable
)},
{
LSTRKEY
(
"getupvalue"
),
LFUNCVAL
(
db_getupvalue
)},
{
LSTRKEY
(
"setfenv"
),
LFUNCVAL
(
db_setfenv
)},
...
...
@@ -397,6 +402,7 @@ const LUA_REG_TYPE dblib[] = {
{
LSTRKEY
(
"setlocal"
),
LFUNCVAL
(
db_setlocal
)},
{
LSTRKEY
(
"setmetatable"
),
LFUNCVAL
(
db_setmetatable
)},
{
LSTRKEY
(
"setupvalue"
),
LFUNCVAL
(
db_setupvalue
)},
#endif
{
LSTRKEY
(
"traceback"
),
LFUNCVAL
(
db_errorfb
)},
{
LNILKEY
,
LNILVAL
}
};
...
...
app/modules/linit.c
View file @
a08626d8
...
...
@@ -47,7 +47,7 @@ static const luaL_Reg lualibs[] = {
{
LUA_TABLIBNAME
,
luaopen_table
},
#endif
#if defined(LUA_USE_BUILTIN_DEBUG)
#if defined(LUA_USE_BUILTIN_DEBUG)
|| defined(LUA_USE_BUILTIN_DEBUG_MINIMAL)
{
LUA_DBLIBNAME
,
luaopen_debug
},
#endif
#endif
...
...
@@ -71,7 +71,7 @@ extern const luaR_entry syslib[];
extern
const
luaR_entry
tab_funcs
[];
#endif
#if defined(LUA_USE_BUILTIN_DEBUG)
#if defined(LUA_USE_BUILTIN_DEBUG)
|| defined(LUA_USE_BUILTIN_DEBUG_MINIMAL)
extern
const
luaR_entry
dblib
[];
#endif
...
...
@@ -99,7 +99,7 @@ const luaR_table lua_rotable[] =
{
LUA_TABLIBNAME
,
tab_funcs
},
#endif
#if defined(LUA_USE_BUILTIN_DEBUG)
#if defined(LUA_USE_BUILTIN_DEBUG)
|| defined(LUA_USE_BUILTIN_DEBUG_MINIMAL)
{
LUA_DBLIBNAME
,
dblib
},
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment