Topic: Debugging Lua
stdh![]() Topic Opener |
Posted at:
2013-08-05, 01:30 UTC+2.0
Hello Widelands! I've been working on some Lua code, a win condition. Being new to Lua I was a bit surprised at the lack of facilities. A lightweight language indeed... (*) I often read that "Lua doesn't have X, but you can easily code it yourself". Which is true, but not entirely so in the case of a debugger. The central problem is getting pointers to the threads, because if you don't have these, you're stuck in your own thread. Not finding these anywhere, I hacked something together: wrapping coroutine.create, which I didn't load early enough, then coroutine.yield, so that threads passing through this code would be gathered in a table. Alas, this hack refuses to let me save the game. Further hacking m_persistent_globals in src/scripting/persistence.cc fixed this, but then I couldn't load. Maybe this could be fixed in a less hacky way. Would that be a good goal to spend some time and effort on, for me or for someone who does understand these Lua-C++ bindings? If so, how? *Not to bash Lua, to be sure. If it's really lean and mean, that's worth something. ![]() ![]() |
SirVer |
Posted at:
2013-08-05, 04:02 UTC+2.0
I am not too sure what you miss and/or want to achieve with "access to other coroutines". In lua, all variables are global in the global namespace by default and there are no races because everything is single threaded anyways. So you can use good old print debugging to achieve all you want. However, when you have plans to make debugging better or add helper functions which make debugging better: go for it and wohoo! Patches are always welcome :). ![]() ![]() |