It is fixed in Xcode 8.0
Xcode 7.3.1, iPhone SE, iOS 9.3.5
I bound C function to JavaScript function by JSObjectMakeFunctionWithCallback
with JavaScriptCore framework.
If I put breakpoint in this C function,
Xcode debugger hangs when execution position comes here from JavaScript by JSEvaluateScript
.
I don't need idea using Objective-C API, Because I want to share code with iOS and Android.
From my experiment, I got these conditions.
JSObjectCallAsFunction
.JSEvaluateScript
.My opinions by looking call stack in Simulator running is this issue is from JavaScriptCore's JIT/LLINT embedded assembly. I guess that these assembly lacks something relates debugging mechanism. So I worry that there is no solution in programmer on user side of JavaScriptCode.
I packaged small reproducible example in this repository.
https://github.com/omochi/jscore-debugger-hangup
test_main.c
.printf
in TestNativeFunc
and JSEvaluateScript
in TestMain
.printf
.JSEvaluateScript
.If you remove two breakpoints, it run correctly and print two func
messages.
static JSValueRef TestNativeFunc(JSContextRef ctx,
JSObjectRef function,
JSObjectRef thisObject,
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef* exception)
{
printf("func\n");
return JSValueMakeNull(ctx);
}
void TestMain() {
JSGlobalContextRef context = JSGlobalContextCreate(NULL);
JSObjectRef func = JSObjectMakeFunctionWithCallback(context, NULL, &TestNativeFunc);
JSValueProtect(context, func);
JSObjectCallAsFunction(context, func, NULL, 0, NULL, NULL);
JSObjectRef global_object = JSContextGetGlobalObject(context);
JSStringRef f_str = JSStringCreateWithUTF8CString("f");
JSObjectSetProperty(context, global_object, f_str, func, 0, NULL);
JSStringRef script = JSStringCreateWithUTF8CString("f();");
JSEvaluateScript(context, script, NULL, NULL, 1, NULL);
JSStringRelease(f_str);
JSValueUnprotect(context, func);
JSGlobalContextRelease(context);
}
This is a known bug in Xcode 7.3.1, and it should be fixed in Xcode 8.0. If you find that it isn't when you get a chance to upgrade to 8.0, please file a bug with http://bugreporter.apple.com.