mirror of
https://github.com/lua/lua
synced 2026-09-27 00:28:25 +03:00
New function 'printallstack' in test library
This commit is contained in:
parent
94d38560c3
commit
205f9aa67b
2 changed files with 24 additions and 0 deletions
23
ltests.c
23
ltests.c
|
|
@ -872,6 +872,28 @@ void lua_printstack (lua_State *L) {
|
|||
}
|
||||
|
||||
|
||||
int lua_printallstack (lua_State *L) {
|
||||
StkId p;
|
||||
int i = 1;
|
||||
CallInfo *ci = &L->base_ci;
|
||||
printf("stack: >>\n");
|
||||
for (p = L->stack.p; p < L->top.p; p++) {
|
||||
if (ci != NULL && p == ci->func.p) {
|
||||
printf(" ---\n");
|
||||
if (ci == L->ci)
|
||||
ci = NULL; /* printed last frame */
|
||||
else
|
||||
ci = ci->next;
|
||||
}
|
||||
printf("%3d: ", i++);
|
||||
lua_printvalue(s2v(p));
|
||||
printf("\n");
|
||||
}
|
||||
printf("<<\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int get_limits (lua_State *L) {
|
||||
lua_createtable(L, 0, 5);
|
||||
setnameval(L, "IS32INT", LUAI_IS32INT);
|
||||
|
|
@ -2102,6 +2124,7 @@ static const struct luaL_Reg tests_funcs[] = {
|
|||
{"limits", get_limits},
|
||||
{"listcode", listcode},
|
||||
{"printcode", printcode},
|
||||
{"printallstack", lua_printallstack},
|
||||
{"listk", listk},
|
||||
{"listabslineinfo", listabslineinfo},
|
||||
{"listlocals", listlocals},
|
||||
|
|
|
|||
1
ltests.h
1
ltests.h
|
|
@ -94,6 +94,7 @@ LUAI_FUNC void lua_printvalue (struct TValue *v);
|
|||
** Function to print the stack
|
||||
*/
|
||||
LUAI_FUNC void lua_printstack (lua_State *L);
|
||||
LUAI_FUNC int lua_printallstack (lua_State *L);
|
||||
|
||||
|
||||
/* test for lock/unlock */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue