Use VSCode to debug cocos2d-x JSB programs

Use VSCode to debug cocos2d-x JSB programs
0.0 0

#144

Hi,
I still have the problem of the “address”.
both of “localhost” and “::1” are not working…:cry:

I’ve tested it on my pc(win10/64bit) and also mac os x.
and not working on pc and mac…

I’m using cocos creator 1.5.1.

What is my problem…?
Please help.

Thank you.


#145

@rorowaro i will try it later, i am using MBP.


#146

I’m having the same issue as @rorowaro. I’m using Cocos Creator 1.6.1. Chrome debugging works just fine, but when I try to debug the simulator it doesn’t connect. I’ve tried both localhost and ::1 as the address. I’m using the default cocos-2d-x version included in cocos creator 1.6.1. The project folder I have opened in VS Code is located at CocosCreator\resources\cocos2d-x\simulator\win32

My debug config looks like this:
{
“name”: “Cocos-Debug”,
“type”: “cocos”,
“request”: “attach”,
“port”: 5086,
“address”: “localhost”,
“cwd”: “${workspaceRoot}”
}


#147

yes, now I’m using Cocos Creator 1.6.1 with chrome debugger also. :slight_smile:
and I tested it again after reading your reply… debugging in visual studio code still doesn’t work. :sob:
Thank you for your comment.


#148

As i know, Cocos Creator upgrade SpiderMonkey from v33 to v52, so the VSCode plugin can not work now. But cocos2d-x JSB projects can work.


#149

Hi jeffrey_ankrum:
Have you slove this problem?


#150

When trying to attach the debugger, I am getting an error immediately after connecting the debugger.
I am using an example project from Cocos Creator. This is using the version of cocos2d-x that is included with Cocos Creator.

any help would be appreciated.

xcode output:

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

Device callstack from Xcode

Thread 1Queue : com.apple.main-thread (serial)
#0 0x00000001008e29c4 in js::Debugger::wrapDebuggeeValue(JSContext*, JS::MutableHandle) ()
#1 0x00000001008f1058 in DebuggerSource_getElement(JSContext*, unsigned int, JS::Value*) ()
#2 0x000000010090b7f4 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) ()
#3 0x000000010090bc44 in js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value const*, JS::MutableHandle) ()
#4 0x000000010090c098 in js::InvokeGetterOrSetter(JSContext*, JSObject*, JS::Value, unsigned int, JS::Value*, JS::MutableHandle) ()
#5 0x0000000100885040 in js::baseops::GetProperty(JSContext*, JS::Handle, JS::Handle, JS::Handle, JS::MutableHandle) ()
#6 0x0000000100906234 in Interpret(JSContext*, js::RunState&) ()
#7 0x00000001009007f4 in js::RunScript(JSContext*, js::RunState&) ()
#8 0x000000010090b900 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) ()
#9 0x00000001009076bc in Interpret(JSContext*, js::RunState&) ()
#10 0x00000001009007f4 in js::RunScript(JSContext*, js::RunState&) ()
#11 0x000000010090b900 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) ()
#12 0x00000001009076bc in Interpret(JSContext*, js::RunState&) ()
#13 0x00000001009007f4 in js::RunScript(JSContext*, js::RunState&) ()
#14 0x000000010090b900 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) ()
#15 0x00000001009076bc in Interpret(JSContext*, js::RunState&) ()
#16 0x00000001009007f4 in js::RunScript(JSContext*, js::RunState&) ()
#17 0x000000010090b900 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) ()
#18 0x000000010085967c in js::CallOrConstructBoundFunction(JSContext*, unsigned int, JS::Value*) ()
#19 0x000000010090b7f4 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) ()
#20 0x00000001009076bc in Interpret(JSContext*, js::RunState&) ()
#21 0x00000001009007f4 in js::RunScript(JSContext*, js::RunState&) ()
#22 0x000000010090b900 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) ()
#23 0x000000010090bc44 in js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value const*, JS::MutableHandle) ()
#24 0x0000000100833a60 in JS_CallFunctionName(JSContext*, JS::Handle, char const*, JS::HandleValueArray const&, JS::MutableHandle) ()
#25 0x000000010075ca8c in ScriptingCore::debugProcessInput(std::__1::basic_string, std::__1::allocator > const&) at /projects/examples/build/jsb-default/frameworks/cocos2d-x/cocos/scripting/js-bindings/manual/ScriptingCore.cpp:1699
#26 0x000000010075d440 in NS_ProcessNextEvent() at /projects/examples/build/jsb-default/frameworks/cocos2d-x/cocos/scripting/js-bindings/manual/ScriptingCore.cpp:1720
#27 0x000000010075cb48 in JSBDebug_enterNestedEventLoop(JSContext*, unsigned int, JS::Value*) at /projects/examples/build/jsb-default/frameworks/cocos2d-x/cocos/scripting/js-bindings/manual/ScriptingCore.cpp:1745
#28 0x000000010090b7f4 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) ()
#29 0x00000001009076bc in Interpret(JSContext*, js::RunState&) ()
#30 0x00000001009007f4 in js::RunScript(JSContext*, js::RunState&) ()
#31 0x000000010090b900 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) ()
#32 0x000000010085967c in js::CallOrConstructBoundFunction(JSContext*, unsigned int, JS::Value*) ()
#33 0x000000010090b7f4 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) ()
#34 0x00000001009076bc in Interpret(JSContext*, js::RunState&) ()
#35 0x00000001009007f4 in js::RunScript(JSContext*, js::RunState&) ()
#36 0x000000010090b900 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) ()
#37 0x000000010085967c in js::CallOrConstructBoundFunction(JSContext*, unsigned int, JS::Value*) ()
#38 0x000000010090b7f4 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) ()
#39 0x00000001009076bc in Interpret(JSContext*, js::RunState&) ()
#40 0x00000001009007f4 in js::RunScript(JSContext*, js::RunState&) ()
#41 0x000000010090b900 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) ()
#42 0x000000010090bc44 in js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value const*, JS::MutableHandle) ()
#43 0x0000000100833a60 in JS_CallFunctionName(JSContext*, JS::Handle, char const*, JS::HandleValueArray const&, JS::MutableHandle) ()
#44 0x000000010075ca8c in ScriptingCore::debugProcessInput(std::__1::basic_string, std::__1::allocator > const&) at /projects/examples/build/jsb-default/frameworks/cocos2d-x/cocos/scripting/js-bindings/manual/ScriptingCore.cpp:1699
#45 0x000000010075c850 in SimpleRunLoop::update(float) at /projects/examples/build/jsb-default/frameworks/cocos2d-x/cocos/scripting/js-bindings/manual/ScriptingCore.cpp:1683
#46 0x000000010076f440 in void cocos2d::Scheduler::scheduleUpdate(SimpleRunLoop*, int, bool)::‘lambda’(float)::operator()(float) const at /projects/examples/build/jsb-default/frameworks/cocos2d-x/cocos/scripting/js-bindings/proj.ios_mac/…/…/…/…/cocos/base/CCScheduler.h:284
#47 0x000000010076f410 in decltype(std::__1::forward(fp)(std::__1::forward(fp0))) std::__1::__invoke(SimpleRunLoop*, int, bool)::‘lambda’(float)&, float>(SimpleRunLoop&&, float&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/…/include/c++/v1/__functional_base:416
#48 0x000000010076f3f0 in void std::__1::__invoke_void_return_wrapper::__call(SimpleRunLoop*, int, bool)::‘lambda’(float)&, float>(void cocos2d::Scheduler::scheduleUpdate(SimpleRunLoop*, int, bool)::‘lambda’(float)&&&, float&&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/…/include/c++/v1/__functional_base:468
#49 0x000000010076f21c in std::__1::__function::__func(SimpleRunLoop*, int, bool)::‘lambda’(float), std::__1::allocator(SimpleRunLoop*, int, bool)::‘lambda’(float)>, void (float)>::operator()(float&&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/…/include/c++/v1/functional:1437
#50 0x0000000100a9f0cc in std::__1::function::operator()(float) const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/…/include/c++/v1/functional:1817
#51 0x0000000100a9c570 in cocos2d::Scheduler::update(float) at /projects/examples/build/jsb-default/frameworks/cocos2d-x/cocos/base/CCScheduler.cpp:859
#52 0x0000000100ae7560 in cocos2d::Director::drawScene() at /projects/examples/build/jsb-default/frameworks/cocos2d-x/cocos/base/CCDirector.cpp:272
#53 0x0000000100aeb5c0 in cocos2d::DisplayLinkDirector::mainLoop() at /projects/examples/build/jsb-default/frameworks/cocos2d-x/cocos/base/CCDirector.cpp:1348
#54 0x0000000100ea77a0 in -[CCDirectorCaller doCaller:] at /projects/examples/build/jsb-default/frameworks/cocos2d-x/cocos/platform/ios/CCDirectorCaller-ios.mm:138
#55 0x0000000101e37768 in -[DYDisplayLinkInterposer forwardDisplayLinkCallback:] ()
#56 0x000000018531c234 in CA::Display::DisplayLinkItem::dispatch() ()
#57 0x000000018531c0e8 in CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) ()
#58 0x0000000182a61e54 in IODispatchCalloutFromCFMessage ()
#59 0x0000000182789030 in __CFMachPortPerform ()
#60 0x00000001827a17d4 in CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION ()
#61 0x00000001827a0f0c in __CFRunLoopDoSource1 ()
#62 0x000000018279ec64 in __CFRunLoopRun ()
#63 0x00000001826c8c50 in CFRunLoopRunSpecific ()
#64 0x0000000183fb0088 in GSEventRunModal ()
#65 0x00000001879aa088 in UIApplicationMain ()
#66 0x000000010010675c in main at /projects/examples/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/main.m:8
#67 0x00000001822668b8 in start ()


#151

New Creator version breaks the debuging. After Creator v1.7, will use other way to debug JS codes.


#152

im using vscode but can’t do auto completion for js code in latest cocos creator. while trying cocos creator in vscode, it’s pain without code completion and highlighting. any solution for this ? and it’s always cannot connect to JSB (timeout after 10000ms)


#153

Please create another ticket for it in creator category.


#154

ah sure, thanks. i’ve created in this post.


#155

Could you tell me how to debug in new Creator version 1.7.


#156

http://www.cocos2d-x.org/docs/creator/en/advanced-topics/jsb/JSB2.0-learning.html#remote-debugging-and-profile


#157

but how to debug in ios device.


#158

but how to debug in ios device, and I want to know how to debug on my old Creator’s project.


#160

What’s your project version?


#161

Hi zhangxm:
I updated the new cocos2d version 3.1.6 from 3.1.4. but there is a crash in my project. the problem at
call “JSBCore_platform-> platform = Application::getInstance()->getTargetPlatform();” but xcode call method Application -> getVersion.


#162

Please don’t reports issues other than the plugin here, thanks.


#163

Hi, I have a same error, how to fix this error, thanks.