Hi guys, i have finished writing a debugger for VSCode to debug
cocos2d-x JSB programs. It is availabe since Cocos2d-x v3.11.
The debugger supports:
- set breakpoints
- step over, step in, step out
- show context variables
- show stack frames
- evaluate expression in the
Please refer to VSCode debugging documentation for more detail information and usage.
- Install VSCode,
v.0.10.8+ is required.
- Download cocos-debug.zip, and upzip it to:
latest codes from cocos2d-x repo is commended)
- If your cocos2d-x version is v3.10 or lower, you should:
cocos/scripting/js-bindings/script/debugger with corresponding contents from cocos2d-x github
cocos/scripting/js-bindings/script/jsb_debugger.js with corresponding file from cocos2d-x github
cocos/scripting/js-bindings/manual/ScriptingCore.cpp as did in this commit did
templates/cocos2dx_files.json as this commit did
- If you use cocos2d-x git repo, then you should synchronize to latest codes.
- You need to create a new project to test, or you should do changes for
cocos/scripting/js-bindings/manual/ScriptingCore.cpp as mentioned above in your
You should re-launch VSCode after upzip cocos-debug.zip.
I only tried on Mac now, other platforms can work in theory because VSCode is cross-platform.
Currently VSCode can only attach to
cocos2d-x JSB program to debug. Which means it can not pause on entry. We will improve it in future.
First you should run
cocos2d-x JSB program, then use VSCode to attach it to the debugger.
Run cocos2dx JSB programs
If you don't know how to run
cocos2d-x JSB program, you can refer to this document.
VSCode attach to
cocos2d-x JSB program
- lauch VSCode and open the folder of your project(for example
- click on the Debugging icon in the View Bar on the side of VSCode
- set up launch configuration
* If you want to debug on iOS devices, you should:
* connect iOS device to Mac via USB cable
* run cocos2d-x JSB program on iOS devices
* use ip address the iOS device to fill the `address` section in launch.json
* If you want to debug on Android devices, you should:
* connect Android devices with PC via USB cable
* run cocos2d-x JSB program on Android devices
* use adb to forward tcp
adb forward tcp:5086 tcp:5086
For more detailed information please refer to VSCode debugging documentation.
I appreciate if you can try it and give some feedback.