Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug with system lua 5.1 #5

Open
densechen opened this issue Jan 15, 2019 · 2 comments
Open

debug with system lua 5.1 #5

densechen opened this issue Jan 15, 2019 · 2 comments

Comments

@densechen
Copy link

how can i make it debug with system lua 5.1?

@tan-wei
Copy link

tan-wei commented Jun 5, 2019

I can give you a solution. But I'm not sure whether it is the best.

If you want to debug a lua script located in the ${workspaceFolder}, e.g named test.lua, create a lua debug_script.lua (from LRDB):

lrdb = require("lrdb_server")
lrdb.activate(21110) --21110 is using port number. waiting for connection by debug client.

--debuggee lua code
dofile("test.lua");

lrdb.deactivate() --deactivate debug server if you want.

Then the launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lrdb",
            "request": "launch",
            "name": "Lua Launch",
            "program": "lua5.1.exe", // here is your system lua location
            "cwd": "${workspaceFolder}",
            "stopOnEntry": false,
            "useInternalLua": false,
            "args": ["debug_script.lua"],
        }
    ]
}

It works for me.

Maybe a better solution is create a batch file which can input with ${file} in args, and change the program with it, then you can debug any script without adding any codes.
I don't know if any easy way. Maybe @satoren can give you the best solution which is elegant.

@tan-wei
Copy link

tan-wei commented Jun 5, 2019

A better solution:

  • Adding an executable Lua script in PATH, named lrdb
#!/usr/bin/env lua

if not arg[1] then
	error("Please input a file name")
end

local lrdb = require("lrdb_server")
lrdb.activate(21110) --21110 is using port number. waiting for connection by debug client.

--debuggee lua code
dofile(arg[1]);

lrdb.deactivate() --deactivate debug server if you want.

Then in launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lrdb",
            "request": "launch",
            "name": "Lua Launch",
            "program": "lrdb",
            "cwd": "${workspaceFolder}",
            "stopOnEntry": false,
            "useInternalLua": false,
            "args": ["${relativeFile}"],
        }
    ]
}

Now you can debug any lua script in your VS Code without adding anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants