Closed inn0minatus closed 9 years ago
ZBS cannot catch hard crashes, simply because the debugger is entirely implemented in Lua, and once the interpreter crashes, the debugger is no longer available. (Unlike Decoda, which uses memory manipulation in the debugged process to inject itself into the native Lua executable code)
It is possible to make the interpreter break when there is a problem in the Lua code (such as dereferencing a nil as a table etc) if your interpreter uses lua_xpcall
to call the script. We have managed to get this working with MCServer. The interpreter installs an error handler function that calls a Lua function injected into the code by the ZBS integration package:
ZBS package: https://github.com/pkulchenko/ZeroBranePackage/blob/master/mcserver.lua#L67-L73
C++ interpreter's error handler: https://github.com/mc-server/MCServer/blob/master/src/Bindings/LuaState.cpp#L1380-L1396
C++ interpreter's handler installation:
Note that the ZBS package needs to jump through hoops to actually get the breakpoint working.
@Neovet, Mattes is absolutely correct; what's he described is probably the best you can do at this point (and it's probably not possible to do more with the Lua-level debugger).
Such a quick response, thank you!
Hi, I have a custom C++ engine and using luabind to integrate Lua 5.2. Everything works with breakpoints and watches when using remote debugging but IDE does not catch crashes in Lua code. I see standard Windows error dialogue when app crashes. Could you please help with this? (Used decoda previously)