Sign in to follow this  
gmaclachlan

Help with debugging lua through luabind from C++

Recommended Posts

gmaclachlan    424
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

Share this post


Link to post
Share on other sites
shadowisadog    3217

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/

Edited by shadowisadog

Share this post


Link to post
Share on other sites
HappyCoder    5053
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

Share this post


Link to post
Share on other sites
gmaclachlan    424

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..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this