diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-03-17 14:30:43 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-03-17 14:30:43 -0300 |
| commit | 205f9aa67b43b3d9b5059769cfc1ed0265341586 (patch) | |
| tree | 88dc9ee32e3ebb3c26c266bc6392893c8fe196a7 | |
| parent | 94d38560c3095190fa2c868cbf7bcf39ca444568 (diff) | |
| download | lua-205f9aa67b43b3d9b5059769cfc1ed0265341586.tar.gz lua-205f9aa67b43b3d9b5059769cfc1ed0265341586.tar.bz2 lua-205f9aa67b43b3d9b5059769cfc1ed0265341586.zip | |
New function 'printallstack' in test library
| -rw-r--r-- | ltests.c | 23 | ||||
| -rw-r--r-- | ltests.h | 1 |
2 files changed, 24 insertions, 0 deletions
| @@ -872,6 +872,28 @@ void lua_printstack (lua_State *L) { | |||
| 872 | } | 872 | } |
| 873 | 873 | ||
| 874 | 874 | ||
| 875 | int lua_printallstack (lua_State *L) { | ||
| 876 | StkId p; | ||
| 877 | int i = 1; | ||
| 878 | CallInfo *ci = &L->base_ci; | ||
| 879 | printf("stack: >>\n"); | ||
| 880 | for (p = L->stack.p; p < L->top.p; p++) { | ||
| 881 | if (ci != NULL && p == ci->func.p) { | ||
| 882 | printf(" ---\n"); | ||
| 883 | if (ci == L->ci) | ||
| 884 | ci = NULL; /* printed last frame */ | ||
| 885 | else | ||
| 886 | ci = ci->next; | ||
| 887 | } | ||
| 888 | printf("%3d: ", i++); | ||
| 889 | lua_printvalue(s2v(p)); | ||
| 890 | printf("\n"); | ||
| 891 | } | ||
| 892 | printf("<<\n"); | ||
| 893 | return 0; | ||
| 894 | } | ||
| 895 | |||
| 896 | |||
| 875 | static int get_limits (lua_State *L) { | 897 | static int get_limits (lua_State *L) { |
| 876 | lua_createtable(L, 0, 5); | 898 | lua_createtable(L, 0, 5); |
| 877 | setnameval(L, "IS32INT", LUAI_IS32INT); | 899 | setnameval(L, "IS32INT", LUAI_IS32INT); |
| @@ -2102,6 +2124,7 @@ static const struct luaL_Reg tests_funcs[] = { | |||
| 2102 | {"limits", get_limits}, | 2124 | {"limits", get_limits}, |
| 2103 | {"listcode", listcode}, | 2125 | {"listcode", listcode}, |
| 2104 | {"printcode", printcode}, | 2126 | {"printcode", printcode}, |
| 2127 | {"printallstack", lua_printallstack}, | ||
| 2105 | {"listk", listk}, | 2128 | {"listk", listk}, |
| 2106 | {"listabslineinfo", listabslineinfo}, | 2129 | {"listabslineinfo", listabslineinfo}, |
| 2107 | {"listlocals", listlocals}, | 2130 | {"listlocals", listlocals}, |
| @@ -94,6 +94,7 @@ LUAI_FUNC void lua_printvalue (struct TValue *v); | |||
| 94 | ** Function to print the stack | 94 | ** Function to print the stack |
| 95 | */ | 95 | */ |
| 96 | LUAI_FUNC void lua_printstack (lua_State *L); | 96 | LUAI_FUNC void lua_printstack (lua_State *L); |
| 97 | LUAI_FUNC int lua_printallstack (lua_State *L); | ||
| 97 | 98 | ||
| 98 | 99 | ||
| 99 | /* test for lock/unlock */ | 100 | /* test for lock/unlock */ |
