Implements "trace" command of the Lua debugger. It just prints a backtrace * querying Lua starting from the current callframe back to the outer one. */
| 2619 | /* Implements "trace" command of the Lua debugger. It just prints a backtrace |
| 2620 | * querying Lua starting from the current callframe back to the outer one. */ |
| 2621 | void ldbTrace(lua_State *lua) { |
| 2622 | lua_Debug ar; |
| 2623 | int level = 0; |
| 2624 | |
| 2625 | while(lua_getstack(lua,level,&ar)) { |
| 2626 | lua_getinfo(lua,"Snl",&ar); |
| 2627 | if(strstr(ar.short_src,"user_script") != NULL) { |
| 2628 | ldbLog(sdscatprintf(sdsempty(),"%s %s:", |
| 2629 | (level == 0) ? "In" : "From", |
| 2630 | ar.name ? ar.name : "top level")); |
| 2631 | ldbLogSourceLine(ar.currentline); |
| 2632 | } |
| 2633 | level++; |
| 2634 | } |
| 2635 | if (level == 0) { |
| 2636 | ldbLog(sdsnew("<error> Can't retrieve Lua stack.")); |
| 2637 | } |
| 2638 | } |
| 2639 | |
| 2640 | /* Implements the debugger "maxlen" command. It just queries or sets the |
| 2641 | * ldb.maxlen variable. */ |
no test coverage detected