A debugger for Luau with debug adapter protocol(DAP) support.
- Install
luau-debugger
extension - There are three ways to use this extension:
- Launch: Directly run the debugger installed with the extension.
- Attach: Attach to the luau runtime running externally.
- Advance: Integrate
luau-debugger
into your own project.
- Add a launch configuration in
launch.json
{ "configurations": [ { "type": "luau", "request": "launch", "name": "launch luau debugger", "program": "${workspaceFolder}/main.lua", "port": 58000 }, ] }
program
: The path to the lua script you want to debugport
: The port number to communicate with the debugger
- Press
F5
to start debugging, enjoy!
- Get a
luaud
executable from release which a luau runtime with debug support - Open lua folders in VSCode
- Add a launch configuration in
launch.json
{ "configurations": [ { "type": "luau", "request": "attach", "name": "attach to luau debugger", "address": "localhost", "port": 58000 } ] }
- Using
luaud [PORT] [LUA_ENTRY]
to execute lua script with debug support:luaud 58000 D:/my_lua_projects/hello_world.lua
- Press
F5
to start debugging, enjoy!
- Build luau-debugger from source
- Use the interface provided by
luau-debugger
library.- You can refer to the implementation of
luaud
which is a minimal luau runtime integrated withluau-debugger
.
- You can refer to the implementation of
- Run your project and debug the luau code using a configuration similar to
Attach
.
- Source file mapping is used to map the source file path from remote debugger server to VSCode workspace. Example:
{ { "type": "luau", "request": "attach", "name": "attach with source map", "address": "localhost", "port": 58000, "sourceMap": { "D:/my_lua_projects": "${workspaceFolder}" } } }
- The above configuration will map the source file path
D:/my_lua_projects/hello_world.lua
to${workspaceFolder}/hello_world.lua
.
- The above configuration will map the source file path
- Debugger features
- Attach
- Launch
- Stop on entry
- Breakpoints
- Add break points when running (Considering thread safety)
- Conditional breakpoints
- Data breakpoints
- Breakpoint hit count
- Continue
- Pause
- StackTrace
- StackTrace across coroutine boundary
- Support switching stacktrace between different coroutines
- Scopes
- Get variables
- Locals
- Upvalues
- Display variables
- nil
- boolean
- number
- string
- table
- nested table
- table with cycle reference
- vector
- function
- userdata
- Set variables
- Repl
- Watch
- Hover
- Single step
- Step in
- Step over
- Step out
- Disconnect and reconnect
- Print to debug console
- Coroutine
- Multiple lua vm
- Source file mapping
- Break from lua code (Call debug.break_here())