Use VSCode to debug cocos2d-x JSB programs

Use VSCode to debug cocos2d-x JSB programs
0.0 0

#124

How to debug win32 project. I use cocos2d-js 3.14.1 :smiley:


#125

As the ticket says, you may need to map localhost to ::1 too, or you can just change "address": "localhost" to "address": "::1".


#126

Thank, it work fine but variable not show value when I hover on it.


#127

The feature is not implemented yet. You and watch the value on the variable view.


#128

@zhangxm Hm, okay, this is nice! :smiley: It would be even better if the source wasn’t just the giant JS blob file; in other words, I could view and set breakpoints in my original individual source files. I’m pretty sure it is possible to resolve this using the “source maps” provided (other VSCode debuggers seem to be doing this).

The other thing that is absolutely killer: No log messages from cc.log are shown in the Debug Console in VSCode. Maybe there’s a way to pass them through?

That would be a very helpful improvement which would make life a bit easier for all of us!


#129

Also, “pausing” doesn’t seem to take me to a “break” at the part of the code that was currently running, like in most debuggers.


#130

@TheChuckster yep, these two features are needed. I will support them ASAP.


#131

Nice! Keep up the good work @zhangxm ! Having worked on debuggers before, I can tell you it is not easy work.


#132

@zhangxm 你好,我有一个问题想要请教,我们公司目前有一个项目,用的是3.5的版本,比较老了, 我用FireFox可以连接到项目里,进行调度,可是无论在哪里打断点,断点都定不住,最后都会跳转到jsb_debugger.js 里的_processIncoming() 这个方法上,也就是说断点无法命中,可是通过调用栈还是可以看调用顺序的,不过此时不能进行单步执行,也无法跳过断点,只能把虚拟机重启。我一度认为是我们项目中的某些代码造成了这个现象,可是我用cocos2d-js 3.5的版本,新建了一个空项目,进行测试,依然如此。我又用3.14的版本新建项目进行测试,调试就可以正常进行,断点命中也正常,操作都正常。因为不能进行调度所以很痛苦。
我看到你这个帖子可以通过其它方式进度调度,很开心,可是我用的版本低于3.11,按你说的,要对相关文件进行修改,可是修改到ScriptingCore.cpp这个文件时,我才发现,requireScript这个方法在ScriptingCore里不存在,:cry:,进行不下去了,希望你看到我的回复,能针对我的版本进行一下指导,万谢!要么能让我在FireFox里远程调试,要么让我可以用你这种新方法调试,谢谢!:slight_smile:


#133

@xujingfire please use english in the forum in future. About using this feature in other version, i also have not idea. As you know, there are so many differences. But you can refer to the PR and modify it yourself. Sorry about that.


#134

@zhangxm OK!Thank you for your reply.


#135

ar: attachRequest: address: localhost port: 5086
ar: attachRequest: retry socket.connect

if windows10 os, try this,
check your ScriptingCore.cpp in project “libjscocos2d”
line 1927, change AF_UNSPEC to AF_INET, rebuild


#136

Hello sir,I have a problem that my file structure like this:
frame
------{other js file}
------ script
---------- main.js
game
----- {other game js file}

if i open the folder with ‘main.js’ ,there is no other js file so i can’t debug other js file in the vscode


#137

Did you modify the folder structure? Currently, the plugin depends on main.js to check if it is a valid project or not. And treat it as the root of the project. So please don’t move main.js to other folder.


#138

Thank you very much


#139

你好,我用3.15版本的引擎新建了个cocos-js项目来测试。但是没有成功进行调试。
这是我的设置:
{
“version”: “0.2.0”,
“configurations”: [
{
“name”: “Cocos-Debug”,
“type”: “cocos”,
“request”: “attach”,
“port”: 5086,
“address”: “localhost”,
“cwd”: “${workspaceRoot}”
}
]
}
我先点击vscode里的运行,然后手动打开已经编译好的.exe文件,最后直到连接超时都没有建立好连接。
ar: attachRequest: address: localhost port: 5086
ar: attachRequest: retry socket.connect
ar: attachRequest: retry socket.connect
ar: attachRequest: retry socket.connect
ar: attachRequest: retry socket.connect
ar: attachRequest: retry socket.connect
ar: attachRequest: retry socket.connect
ar: attachRequest: retry socket.connect
ar: attachRequest: retry socket.connect
c++那边是不是需要修改些什么。


#140

请问 你是怎么运行调试的啊,我这边新建了个3.15版本的cocos-js项目,编译好。vscode里面配置好。然后点击vscode里的运行项目,然后手动运行编译好的exe文件,直到连接超时都没有建立好连接。
只不是我哪里弄错掉了。
这是我的设置:
{
“version”: “0.2.0”,
“configurations”: [
{
“name”: “Cocos-Debug”,
“type”: “cocos”,
“request”: “attach”,
“port”: 5086,
“address”: “localhost”,
“cwd”: “${workspaceRoot}”
}
]
}
这是我这边的log:
ar: attachRequest: address: localhost port: 5086
ar: attachRequest: retry socket.connect
ar: attachRequest: retry socket.connect
ar: attachRequest: retry socket.connect
ar: attachRequest: retry socket.connect
ar: attachRequest: retry socket.connect
ar: attachRequest: retry socket.connect
ar: attachRequest: retry socket.connect
ar: attachRequest: retry socket.connect


#141

@ninggaomeng you may take a look of the answer if you use windows 64 bit system. And please use english. Thanks.


#142

I just tried it. but is not working.
my system is windows 10, 64 bit.
this is my setting:
{
“version”: “0.2.0”,
“configurations”: [
{
“name”: “Cocos-Debug”,
“type”: “cocos”,
“request”: “attach”,
“port”: 5086,
“address”: “::1”,
“cwd”: “${workspaceRoot}”
}
]
}
Is there any problem with my operation?


#143

It seems there is not problem. But i don’t have win10 64bit. I will try win7 64bit.