News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.

Post Reply  Post Thread 
Debugging with murgaLua - Tutorial
Author Message

Posts: 381
Group: Administrators
Joined: Apr 2007
Status: Offline
Reputation: 2
Post: #1
Debugging with murgaLua - Tutorial

MurgaLua now incorporates a customized version of remDebug.

Soon there will be a GUI for this, but until then here is how to use it.

Invocation :

  • The traditional remDebug way ...
    Adding the following to your code :
    require "remdebug.engine"
  • From the command line ...
    Invoking your program with :
    murgaLua -e "remdebug.engine.start();dofile ('test.lua')"
Tutorial :
  • Open two command line windows.
    One for the debug console, one from the program to be run.
  • Go to the tests/debug directory on both prompts.
  • Run the debug console on one prompt.
    murgaLua controller.lua
  • Switch to the other prompt and run the test program.
    murgaLua test.lua
  • Now switch back to the debug console.
    You should see a line that says "Paused at file" ...
  • Using the file path which is displayed for you type :
    setb "C:/murgaLua/tests/debug/test.lua" 22
  • Then try
    setw == 8
  • Now lets try running it and see what happens, type :
  • Now to see all the local variables try :
    eval murgaLua.debug.dumpTableAsLua(getfenv())

Cool huh :-)

Todo :
  • Testing :-)
  • FilterGlobals function, to return non-system global variables.
  • Decent UI.

John de Murga

10-13-2010 09:07 PM
Visit this user's website Find all posts by this user Quote this message in a reply

Posts: 113
Group: Registered
Joined: Jul 2007
Status: Offline
Reputation: 0
Post: #2
RE: Debugging with murgaLua - Tutorial

This really is cool. It enables really easy debugging, without mixing actual program output and debugging output! great Smile.

There is however one thing I can't get right: I'm having problems setting breakpoints. I tried setting the basedir before, and I tried all variations of:

  • setb test.lua 22
  • setb "test.lua" 22
  • setb /home/.../murgaLua/test/debug/test.lua 22
  • setb "/home/.../murgaLua/test/debug/test.lua" 22
When I enter the run command, it just runs the program all the way through, without breaking at the desired point. listb however lists the breakpoint.

Any idea what I'm doing wrong?

Edit: After fiddling a bit with strange setups (using the debugger to debug itself), I figured out what has happened: Apparently the standard controller hasn't got the brains to use a local path, or look in the local dir by default. If you give a basedir with basedir, then give it a local dir (so not starting with /) with respect to / (while in my opinion, it should be the current dir). I'll try to write up a patch for controller.lua to make it behave as expected.

Here's a patch: It works (at least for Linux) as I would expect:

< local basedir = ""
> local basedir = (lfs.currentdir() or ""):gsub("^/+",""):gsub("/+$","/") -- remove any leading / and add a trailing one.
<     local _, _, dir = string.find(line, "^[a-z]+%s+(.+)$")
>     local _, _, dir = string.find(line, "^[/a-z]+%s+(.+)$")
<       if not string.find(dir, "/$") then dir = dir .. "/" end
<       basedir = dir
>       if dir:match("^/+") then
>         dir = dir:gsub("^/+","")
>       else
>         dir = (lfs.currentdir() or ""):gsub("^/+","")..'/'..dir
>       end
>       basedir = dir:gsub("/+$","/")


This post was last modified: 01-29-2011 08:23 AM by jpjacobs.

01-29-2011 07:07 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: