Use VSCode to debug cocos2d-x JSB programs

@IuriiBaranskyi i think it is a bug of debugger extension. I am busy preparing for cocos2d-x v3.12. I will take a look when i have time.

I’ve downloaded the cocos 3.11, and followed the instructions above (on VS Code 1.2, Android 5.0+), but output console display:

ar: attachRequest: address: localhost port: 5086
ar: attachRequest: connected
ar: _termiated: socket error
ar: _termiated: cocos firefox protocol error: input stream error
ar: _termiated: cocos firefox protocol error: error happend in send request
ar: _termiated: cocos firefox protocol close

have i missed something or any configurations?

@shepherdog I don’t know how to reproduce it. Could you provide a project to reproduce it?

OK, that works fine both on Mac and Win7, i guess some Android DevTools interrupt the ADB service i started by hand previously.

Can you make a video tutorial or detailed explanation of this process , it is hard to understand for beginners.

@slackmoehrle can we add a doc of it in PG?

I think that we can. I have it on the list.

Hi:

Finally, I took time out to test this extension. It was exactly we need since Javascript Remote Debugging was discontinued on cocos2d-js 3.6.

NOTE: On Android I’ve needed to disconnect the USB cable after several test, because debugger doesn’t reconnect.

Thanks @zhangxm and good job!

not working on Cocoscreator…
it says “not a valid project” what am i missing?

@eydamson i think you opened wrong folder, you should build native first, then open the folder that contains main.js.

@zhangxm thanks sir…

Hi,@zhangxm
I did the work mentioned above.
Then use coocs new create project and add the code in the below picture marked with circle.
The last run this project in the vs, and attach the project with vscode.
But the debugger can’t stop on the breakpoint which the picture show.
(cocos2d-x : 3.10, vscode: 1.3.1, vs: 2013)


I didn’t know where was wrong, Can you give me some hints?Thanks.

@Djong as the picture showed above, it seems you used the default template. As i know, these codes are executed when the app is launched. What i mean is that, the codes are executed before attaching VSCode to the app. So you should set breakpoints in the codes that will be executed after attaching.

Don’t know you notice to the code of “onTouchBegan:function()”?
Then run the project and touch the screen, the vs console will show the log(“touch began”).
Is that way is correct to test the vscode debugger?
But the vscode console can’t print the log.
Or i needed to test replace scene with other js file?

@Djong could you please use js-tests to have a test? Or make sure you do all the things i mentioned above for v3.10?

I test the js-test, got this err:

@Djong are you sure you do all the things i mentioned above? It seems some js files are missed in cocos/scripting/js-bindings/script/debugger. And i would suggest you using v3.11 or upper version.

@zhangxm
I download the cocos2d-x 3.12 form [cocos2d-x site][1]
First run python setup.py command,
then run js-test, vscode,
finally, got this:(the “require is not defined” err is missing)


When i use 3.10 the vscode can connected to the js-test, but the 3.12 can’t
[1]: http://www.cocos.com/download/%23

@zhangxm
Finally, i download the cocos2d-x 3.11.1.
It runs well, the socket can connected and the breakpoints can stop.
:sweat_smile: I don’t know where is wrong about 3.12.It’s the same way i use them.

@Djong i will take a look. Will you please create an issue in github issue system? Thanks.