1
0
Fork 0
forked from len0rd/rockbox

lua Add scrollable stack traceback WIP

lua currently splashes a stack traceback on error
for deep tracebacks and especially on devices with smaller screens
this leaves out a lot of vital information

in the past I have resorted to splitting the traceback string or
even saving the return to a file

This patch provides a scrollable buffer with rudimentary text reflow
to allow you to read the whole traceback string

Upon traceback if you press nothing the screen will display for 5 seconds
If you press OK or CANCEL it will quit immediately
PREV/NEXT scrolls the list on button press timeout is disabled

lua now provides rb.splash_scroller(timeout, str)

example script provided too

Change-Id: Idbc8ce0c514196f0fae48c43aeaea8b60d6da1a5
This commit is contained in:
William Wilgus 2020-10-02 14:30:41 -04:00 committed by William Wilgus
parent 1916aca7f3
commit 80c3b84e08
5 changed files with 141 additions and 3 deletions

View file

@ -86,7 +86,7 @@ static int db_errorfb (lua_State *L) {
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");
else lua_pushliteral(L, "\n\n");
lua_pushliteral(L, "stack traceback: ");
while (lua_getstack(L1, level++, &ar)) {
if (level > LEVELS1 && firstpart) {
@ -101,7 +101,7 @@ static int db_errorfb (lua_State *L) {
firstpart = 0;
continue;
}
lua_pushliteral(L, "\n\t");
lua_pushliteral(L, "\n\n\t");
lua_getinfo(L1, "Snl", &ar);
char* filename = rb->strrchr(ar.short_src, '/'); /* remove path */
lua_pushfstring(L, "%s:", filename ? filename : ar.short_src);
@ -118,8 +118,10 @@ static int db_errorfb (lua_State *L) {
lua_pushfstring(L, " in function <%s:%d>",
ar.short_src, ar.linedefined);
}
lua_concat(L, lua_gettop(L) - arg);
}
lua_pushfstring(L, "\n\nRam Used: %d Kb", lua_gc (L, LUA_GCCOUNT, 0));
lua_concat(L, lua_gettop(L) - arg);
return 1;
}
@ -225,6 +227,14 @@ static int lua_split_arguments(lua_State *L, const char *filename)
return 2;
}
static void display_traceback(const char *errstr)
{
#if 1
splash_scroller(HZ * 5, errstr); /*rockaux.c*/
#else
rb->splash(10 * HZ, errstr);
#endif
}
/***************** Plugin Entry Point *****************/
enum plugin_status plugin_start(const void* parameter)
{
@ -251,7 +261,8 @@ enum plugin_status plugin_start(const void* parameter)
if (lu_status) {
DEBUGF("%s\n", lua_tostring(Ls, -1));
rb->splash(10 * HZ, lua_tostring(Ls, -1));
display_traceback(lua_tostring(Ls, -1));
//rb->splash(10 * HZ, lua_tostring(Ls, -1));
/*lua_pop(Ls, 1);*/
}
lua_close(Ls);