Wiki

Clone wiki

game kitchen / Debugging

Breaking

Game Kitchen can be used for debugging as well as editing. Pressing F5 will launch your project with the debugger activated. If a lua error occurs while you are debugging, you will be presented with the Game Kitchen debug interface rather than love's typical stack trace over cornflower blue. It looks like this:

breaking_1.png

Note how the values of all local variables are displayed in the upper portion of the right pane. If a variable references a table which has keys, the keys are listed when the user clicks on the + icon next to the table variable. Unfortunately, the debugger currently has no means of interacting with metatables.

Clicking on the upvalues and globals tabs allows you to browse those as well.

breaking_2.png

Once you have finished debugging, press F5 to exit debugging mode; this will allow you to resume coding and fix whatever error occurred.

Call Stack Browsing

The lower portion of the right pane displays the call stack. Clicking on an item in the call stack opens up the corresponding source file and location and displays all of the local variables of the stack frame chosen.

stack_browsing_1.png

Breaking on Errors in Coroutines

If an error occurs in a coroutine while it is executing, the debugger will not break. Instead, the default behavior of returning an error message to the resume point will happen. To view the error in Game Kitchen's debugger, we use a special function:

love.debugger.debugThread(coroutine,error)

If an error is detected, call debugThread. Pass the coroutine in as the first argument and its error message as the second. For example:

  local ret,err = coroutine.resume(foo, dt)
  
  if err ~= nil then
    love.debugger.debugThread(foo,err)
    love.event.quit() -- quit the game
  end

Updated