Debugger.lua

Before moving on, let's take a look at an external debugger solution, one not built into Lua. dbeugger.lua is one such solution; it is a debugger written in Lua. You should grab a copy of the debugger.lua file from https://github.com/slembcke/debugger.lua.

To use debugger.lua, you first have to include the module in your source file. This is just a standard call to require, for example:

local debug = require("debugger")

The module that was just included is a functable. That is, it can be called as a function. To set a breakpoint, at any point in your code, just write debug(). Whenever one of these debug() commands is hit, the flow of execution will be given to the debugger. You can use the following console commands to debug:

  • <enter>: re-run the last command
  • c: continue execution
  • s: step forward by one line (into functions)
  • n: step forward to the next line (skipping over functions)
  • p: execute the expression and print the result
  • f: step forward until exiting the current function
  • u: move up the stack by one frame
  • d: move down the stack by one frame
  • t: print the stack trace
  • l: print the function arguments, locals, and upvalues
  • q: quit the program
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.157.197