Implements "trace" command of the Lua debugger. It just prints a backtrace * querying Lua starting from the current callframe back to the outer one. */
| 2644 | /* Implements "trace" command of the Lua debugger. It just prints a backtrace |
| 2645 | * querying Lua starting from the current callframe back to the outer one. */ |
| 2646 | void ldbTrace(lua_State *lua) { |
| 2647 | lua_Debug ar; |
| 2648 | int level = 0; |
| 2649 | |
| 2650 | while(lua_getstack(lua,level,&ar)) { |
| 2651 | lua_getinfo(lua,"Snl",&ar); |
| 2652 | if(strstr(ar.short_src,"user_script") != NULL) { |
| 2653 | ldbLog(sdscatprintf(sdsempty(),"%s %s:", |
| 2654 | (level == 0) ? "In" : "From", |
| 2655 | ar.name ? ar.name : "top level")); |
| 2656 | ldbLogSourceLine(ar.currentline); |
| 2657 | } |
| 2658 | level++; |
| 2659 | } |
| 2660 | if (level == 0) { |
| 2661 | ldbLog(sdsnew("<error> Can't retrieve Lua stack.")); |
| 2662 | } |
| 2663 | } |
| 2664 | |
| 2665 | /* Implements the debugger "maxlen" command. It just queries or sets the |
| 2666 | * ldb.maxlen variable. */ |
no test coverage detected