diff options
Diffstat (limited to 'src/lib_debug.c')
| -rw-r--r-- | src/lib_debug.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/lib_debug.c b/src/lib_debug.c index ab504de7..d90c422f 100644 --- a/src/lib_debug.c +++ b/src/lib_debug.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | 15 | ||
| 16 | #include "lj_obj.h" | 16 | #include "lj_obj.h" |
| 17 | #include "lj_err.h" | 17 | #include "lj_err.h" |
| 18 | #include "lj_debug.h" | ||
| 18 | #include "lj_lib.h" | 19 | #include "lj_lib.h" |
| 19 | 20 | ||
| 20 | /* ------------------------------------------------------------------------ */ | 21 | /* ------------------------------------------------------------------------ */ |
| @@ -77,6 +78,12 @@ static void settabsi(lua_State *L, const char *i, int v) | |||
| 77 | lua_setfield(L, -2, i); | 78 | lua_setfield(L, -2, i); |
| 78 | } | 79 | } |
| 79 | 80 | ||
| 81 | static void settabsb(lua_State *L, const char *i, int v) | ||
| 82 | { | ||
| 83 | lua_pushboolean(L, v); | ||
| 84 | lua_setfield(L, -2, i); | ||
| 85 | } | ||
| 86 | |||
| 80 | static lua_State *getthread(lua_State *L, int *arg) | 87 | static lua_State *getthread(lua_State *L, int *arg) |
| 81 | { | 88 | { |
| 82 | if (L->base < L->top && tvisthread(L->base)) { | 89 | if (L->base < L->top && tvisthread(L->base)) { |
| @@ -101,12 +108,12 @@ static void treatstackoption(lua_State *L, lua_State *L1, const char *fname) | |||
| 101 | 108 | ||
| 102 | LJLIB_CF(debug_getinfo) | 109 | LJLIB_CF(debug_getinfo) |
| 103 | { | 110 | { |
| 104 | lua_Debug ar; | 111 | lj_Debug ar; |
| 105 | int arg, opt_f = 0, opt_L = 0; | 112 | int arg, opt_f = 0, opt_L = 0; |
| 106 | lua_State *L1 = getthread(L, &arg); | 113 | lua_State *L1 = getthread(L, &arg); |
| 107 | const char *options = luaL_optstring(L, arg+2, "flnSu"); | 114 | const char *options = luaL_optstring(L, arg+2, "flnSu"); |
| 108 | if (lua_isnumber(L, arg+1)) { | 115 | if (lua_isnumber(L, arg+1)) { |
| 109 | if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { | 116 | if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), (lua_Debug *)&ar)) { |
| 110 | setnilV(L->top-1); | 117 | setnilV(L->top-1); |
| 111 | return 1; | 118 | return 1; |
| 112 | } | 119 | } |
| @@ -116,7 +123,7 @@ LJLIB_CF(debug_getinfo) | |||
| 116 | } else { | 123 | } else { |
| 117 | lj_err_arg(L, arg+1, LJ_ERR_NOFUNCL); | 124 | lj_err_arg(L, arg+1, LJ_ERR_NOFUNCL); |
| 118 | } | 125 | } |
| 119 | if (!lua_getinfo(L1, options, &ar)) | 126 | if (!lj_debug_getinfo(L1, options, &ar, 1)) |
| 120 | lj_err_arg(L, arg+2, LJ_ERR_INVOPT); | 127 | lj_err_arg(L, arg+2, LJ_ERR_INVOPT); |
| 121 | lua_createtable(L, 0, 16); /* Create result table. */ | 128 | lua_createtable(L, 0, 16); /* Create result table. */ |
| 122 | for (; *options; options++) { | 129 | for (; *options; options++) { |
| @@ -133,6 +140,8 @@ LJLIB_CF(debug_getinfo) | |||
| 133 | break; | 140 | break; |
| 134 | case 'u': | 141 | case 'u': |
| 135 | settabsi(L, "nups", ar.nups); | 142 | settabsi(L, "nups", ar.nups); |
| 143 | settabsi(L, "nparams", ar.nparams); | ||
| 144 | settabsb(L, "isvararg", ar.isvararg); | ||
| 136 | break; | 145 | break; |
| 137 | case 'n': | 146 | case 'n': |
| 138 | settabss(L, "name", ar.name); | 147 | settabss(L, "name", ar.name); |
