How to debug Lua program?

132 views
Skip to first unread message

commo...@tutanota.com

unread,
Jan 24, 2025, 9:20:26 AM1/24/25
to Lua L
I am tracing a Lua project (https://github.com/Nymphium/eff.lua) with the env - Lua 5.1, vscode 1.96.4, Debian trixie/ sid. Initially I inserted print command in the  the project related code. Though it works ok, several parts which reference to Lua table objects inside eff.lua project I do not know how to check the encapsulated values inside those tables. The console merely prints info such as table: 0x55fce37509c0. Therefore, I appreciate if any advice on how to debug Lua program.

First, I attempted to install Lua Debug (https://marketplace.visualstudio.com/items?itemName=actboy168.lua-debug). Then, configuring launch.json

{
   "version": "0.2.0",
    "configurations": [
        {
            "type": "lua",
            "request": "launch",
            "name": "Launch",
            "program": "${workspaceFolder}/test1.lua"
        }
    ]
}

The test1.lua is as below

local eff = require('src/eff')
local inst, perform, handler = eff.inst, eff.perform, eff.handler
local Choice = inst()
local always_right = handler {
    val = function(arg) print("printh ended and args are:", arg) end,
    [Choice] = function(continue_fn, left, right)
        return continue_fn(right)
    end
}
always_right(function()
    print(perform(Choice(3, 4)) + 3)
end)

But after placing several breakpoints and clicking Run > Start Debugging, vscode flashes and immediately finishes as if nothing happened. And no messages - either success or failure - are shown in Debug Console.

I can run the test1.lua by executing the command lua test1.lua within the cloned directory.

+ eff.lua (cloned dir)
  - test1.lua
  + src/eff.lua

The result is something like this

Inside perform e.eff     table: 0x55fce37509c0 -- I want to check what's inside e.eff, but print(e.eff) or print(e.eff[1]) or print(e.eff[2]) shows table: 0x55fce37509c0 or nil or nil
Inside handler left:  3       right:  4
7
printh ended and args are:      nil

If not debugging through vscode, any recommended tutorials or steps that I should check or follow?
Many thanks

Jorge Rezende

unread,
Jan 24, 2025, 9:27:47 AM1/24/25
to lu...@googlegroups.com
you need to setup the lua path and lua c path in you debugger conf 

Just read this tutorial, it is in portuguese but you can translate it with google or chat gpt...

--
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lua-l+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/lua-l/OHNfifx--F-9%40tutanota.com.

commo...@tutanota.com

unread,
Jan 25, 2025, 6:20:05 AM1/25/25
to Lua L, Lua L

Denis Dos Santos Silva

unread,
Jan 25, 2025, 3:51:31 PM1/25/25
to lua-l
zerobrane is a good choice.

Reply all
Reply to author
Forward
0 new messages