devcat-studio / VSCodeLuaDebug

Visual Studio Code debugger extension for Lua 5.1/5.2/5.3
https://marketplace.visualstudio.com/items?itemName=devCAT.lua-debug
72 stars 80 forks source link

How debug cocos2dx lua using lua debugger? #15

Open SambeauWang opened 6 years ago

SambeauWang commented 6 years ago

This plugin is very pretty, Thank for author. I use it to learn lua and cocos2dx. But when i debug cocos2dx code, i fail. There are my steps. (1) download vscode-debuggee.lua and dkjson.lua , put into my src folder. (2) add follow code in main.lua:

cc.FileUtils:getInstance():setPopupNotify(false)
require "config"
require "cocos.init"

local json = require 'dkjson'
local debuggee = require 'vscode-debuggee'
local startResult, breakerType = debuggee.start(json)
print('debuggee start ->', startResult, breakerType)

local function main()
    require("app.MyApp"):create():run()
end

local status, msg = xpcall(main, __G__TRACKBACK__)
if not status then
    print(msg)
end

(3) launch.json:

{
            "name": "launch-lua",
            "type": "lua",
            "request": "launch",
            "workingDirectory": "${workspaceRoot}",
            "sourceBasePath": "${workspaceRoot}/src",
            "executable": "${workspaceRoot}/simulator/win32/MyGame.exe",
            "listenPublicly": false,
            "listenPort": 56789,
            "encoding": "UTF-8",
            "env": {}
},

When run it, the result is follow. I fail to debug. image

Ander456 commented 5 years ago

hellow, bro have you handle this problem?