Help with debugging lua through luabind from C++

Started by
4 comments, last by gmaclachlan 8 years, 5 months ago
Hi All,
Can anyone help me get step by step debugging of lua code working when it's called from luabind in a C++ host environment, please? I'm working in Xcode on a Mac at the moment, but I'm open to different IDEs and non-Apple solutions if necessary.
I'm writing a small 2D retro game in a framework I've put together using C++ to call into SDL 2 (for windowing and GFX etc.) and using luabind so that the majority of the game logic, level loading etc. is done through lua. The idea is to have the convenience of lua for most of development, but that I can gradually move anything that is too heavy for lua into the C++ wrapper if required. Also, as there are no direct calls into SDL from lua, I can replace SDL calls with OpenGL or similar eventually for more complicated projects. It's all working okay at the moment until I make a mistake in the lua part (as I'm learning lua as a I go along and the game is getting bigger, this is happening a lot).
I get nice debugging of C++ through Xcode as you'd expect, but when there's a problem in the lua side of things at best I get dumped out of it to the calling C++ function with just an error message from luabind and there's no way to set breakpoints etc. It's not the 80s any more and I've been spoilt by modern debuggers so this is getting old fast :(
Thanks, G
Advertisement

You might find this helpful:

http://oberon00.github.io/luabind/errors.html

The idea is to add an error handler and then through that you can add additional information about what exactly happened.

If you need to debug Lua code in general then here are some options:

http://lua-users.org/wiki/DebuggingLuaCode

Maybe you could use something like: http://studio.zerobrane.com/

I was able to get remote debugger working nicely using these two tools. I was able to stop at breakpoints, inspect values, step over/into code. It works pretty well.

https://github.com/pkulchenko/MobDebug
http://studio.zerobrane.com/

Zerobrane isn't free but they offer a pay what you want model.

This might help you get started
http://studio.zerobrane.com/doc-remote-debugging
My current game project Platform RPG

Thanks for the answers. Those links look helpful and it's good to know that someone has got something like what I want to do working. I'll try to have a go with these this week..

Possibly this: http://unknownworlds.com/decoda/

In case anyone else might find this useful, I finally got debugging working today via the links that HappyCoder had posted. Thanks again.

This topic is closed to new replies.

Advertisement