Debugging Lua Modules


This is just a quick post to outline steps that can be taken to debug a custom Lua module that has been compiled to run with Storyboard. 

Step 1: Compile your Lua module with debug symbols. This can be done by adding the -g option to the flags that are being passed to the compiler. An optional step would be to also disable optimizations by passing a -O0. 

Step 2: Copy your debug Lua module into your Storyboard application and run it as you normally would. Grab the process ID number of Storyboard engine. This can be done by running ps (Linux System) or pidin (QNX System). 

Step 3: Launch the gdb debugger. This can be done by running "gdb <path_to_sbengine>/sbengine". There won't be any symbols for the engine, but you shouldn't need them to debug the custom Lua module. 

Step 4: Once gdb is up you will need to attach to the process with the pid that was obtained in Step 2. At the gdb command prompt, simply type "attach <pid_from_step_2>". This should attach to the running process. It may complain about missing symbols from libraries.

Step 5: Set the search path for your debug Lua module. This will allow gdb to pull in the symbols from the debug Lua module so that you can get information from it while sbengine is running. To do this run "set solib-search-path <path_to_lua_module>

At this point, you should have your symbols loaded in the debugger. Note that this is assuming that everything is being done on one system. If you are using a host to target configuration where you are building on the host and running on a target, you will need to look into how to do remote debugging to your target. These steps are also for a Linux/QNX with gdb based system. 





Please sign in to leave a comment.

Didn't find what you were looking for?

New post