- Revision
- 166756
- Author
- [email protected]
- Date
- 2014-04-03 17:50:49 -0700 (Thu, 03 Apr 2014)
Log Message
Web Inspector: JSContext inspection provide a way to opt-out of including Native Call Stacks in Exception traces reported to Web Inspector
https://bugs.webkit.org/show_bug.cgi?id=131186
Patch by Joseph Pecoraro <[email protected]> on 2014-04-03
Reviewed by Geoffrey Garen.
* API/JSContextPrivate.h:
* API/JSContext.mm:
(-[JSContext _includesNativeCallStackWhenReportingExceptions]):
(-[JSContext _setIncludesNativeCallStackWhenReportingExceptions:]):
JSContext ObjC SPI to opt-out of including native call stacks in exceptions.
* API/JSContextRefPrivate.h:
* API/JSContextRef.cpp:
(JSGlobalContextGetIncludesNativeCallStackWhenReportingExceptions):
(JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions):
JSContext C SPI to opt-out of including native call stacks in exceptions.
* inspector/JSGlobalObjectInspectorController.h:
* inspector/JSGlobalObjectInspectorController.cpp:
(Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
(Inspector::JSGlobalObjectInspectorController::reportAPIException):
Only include the native call stack if the setting is enabled. It is enabled by default.
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/API/JSContext.mm (166755 => 166756)
--- trunk/Source/_javascript_Core/API/JSContext.mm 2014-04-03 23:55:31 UTC (rev 166755)
+++ trunk/Source/_javascript_Core/API/JSContext.mm 2014-04-04 00:50:49 UTC (rev 166756)
@@ -213,6 +213,16 @@
JSGlobalContextSetRemoteInspectionEnabled(m_context, enabled);
}
+- (BOOL)_includesNativeCallStackWhenReportingExceptions
+{
+ return JSGlobalContextGetIncludesNativeCallStackWhenReportingExceptions(m_context);
+}
+
+- (void)_setIncludesNativeCallStackWhenReportingExceptions:(BOOL)includeNativeCallStack
+{
+ JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(m_context, includeNativeCallStack);
+}
+
@end
@implementation JSContext(SubscriptSupport)
Modified: trunk/Source/_javascript_Core/API/JSContextPrivate.h (166755 => 166756)
--- trunk/Source/_javascript_Core/API/JSContextPrivate.h 2014-04-03 23:55:31 UTC (rev 166755)
+++ trunk/Source/_javascript_Core/API/JSContextPrivate.h 2014-04-04 00:50:49 UTC (rev 166756)
@@ -38,6 +38,12 @@
*/
@property (setter=_setRemoteInspectionEnabled:) BOOL _remoteInspectionEnabled NS_AVAILABLE(10_10, 8_0);
+/*!
+@property
+@discussion Set whether or not the native call stack is included when reporting exceptions. Default value is YES.
+*/
+@property (setter=_setIncludesNativeCallStackWhenReportingExceptions:) BOOL _includesNativeCallStackWhenReportingExceptions NS_AVAILABLE(10_10, 8_0);
+
@end
#endif
Modified: trunk/Source/_javascript_Core/API/JSContextRef.cpp (166755 => 166756)
--- trunk/Source/_javascript_Core/API/JSContextRef.cpp 2014-04-03 23:55:31 UTC (rev 166755)
+++ trunk/Source/_javascript_Core/API/JSContextRef.cpp 2014-04-04 00:50:49 UTC (rev 166756)
@@ -40,6 +40,10 @@
#include <wtf/text/StringBuilder.h>
#include <wtf/text/StringHash.h>
+#if ENABLE(REMOTE_INSPECTOR)
+#include "JSGlobalObjectInspectorController.h"
+#endif
+
#if OS(DARWIN)
#include <mach-o/dyld.h>
@@ -320,3 +324,42 @@
exec->vmEntryGlobalObject()->setRemoteDebuggingEnabled(enabled);
}
+
+bool JSGlobalContextGetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx)
+{
+#if ENABLE(REMOTE_INSPECTOR)
+ if (!ctx) {
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+
+ ExecState* exec = toJS(ctx);
+ JSLockHolder lock(exec);
+
+ JSGlobalObject* globalObject = exec->vmEntryGlobalObject();
+ return globalObject->inspectorController().includesNativeCallStackWhenReportingExceptions();
+#else
+ UNUSED_PARAM(ctx);
+ return false;
+#endif
+}
+
+void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx, bool includesNativeCallStack)
+{
+#if ENABLE(REMOTE_INSPECTOR)
+ if (!ctx) {
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ ExecState* exec = toJS(ctx);
+ JSLockHolder lock(exec);
+
+ JSGlobalObject* globalObject = exec->vmEntryGlobalObject();
+ globalObject->inspectorController().setIncludesNativeCallStackWhenReportingExceptions(includesNativeCallStack);
+#else
+ UNUSED_PARAM(ctx);
+ UNUSED_PARAM(includesNativeCallStack);
+#endif
+}
+
Modified: trunk/Source/_javascript_Core/API/JSContextRefPrivate.h (166755 => 166756)
--- trunk/Source/_javascript_Core/API/JSContextRefPrivate.h 2014-04-03 23:55:31 UTC (rev 166755)
+++ trunk/Source/_javascript_Core/API/JSContextRefPrivate.h 2014-04-04 00:50:49 UTC (rev 166756)
@@ -111,6 +111,23 @@
*/
JS_EXPORT void JSGlobalContextSetRemoteInspectionEnabled(JSGlobalContextRef ctx, bool enabled) CF_AVAILABLE(10_10, 8_0);
+/*!
+@function
+@abstract Gets the include native call stack when reporting exceptions setting for a context.
+@param ctx The JSGlobalContext whose setting you want to get.
+@result The value of the setting, true if remote inspection is enabled, otherwise false.
+@discussion This setting is true by default.
+*/
+JS_EXPORT bool JSGlobalContextGetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx) CF_AVAILABLE(10_10, 8_0);
+
+/*!
+@function
+@abstract Sets the include native call stack when reporting exceptions setting for a context.
+@param ctx The JSGlobalContext that you want to change.
+@param includeNativeCallStack The new value of the setting for the context.
+*/
+JS_EXPORT void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx, bool includesNativeCallStack) CF_AVAILABLE(10_10, 8_0);
+
#ifdef __cplusplus
}
#endif
Modified: trunk/Source/_javascript_Core/ChangeLog (166755 => 166756)
--- trunk/Source/_javascript_Core/ChangeLog 2014-04-03 23:55:31 UTC (rev 166755)
+++ trunk/Source/_javascript_Core/ChangeLog 2014-04-04 00:50:49 UTC (rev 166756)
@@ -1,3 +1,28 @@
+2014-04-03 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: JSContext inspection provide a way to opt-out of including Native Call Stacks in Exception traces reported to Web Inspector
+ https://bugs.webkit.org/show_bug.cgi?id=131186
+
+ Reviewed by Geoffrey Garen.
+
+ * API/JSContextPrivate.h:
+ * API/JSContext.mm:
+ (-[JSContext _includesNativeCallStackWhenReportingExceptions]):
+ (-[JSContext _setIncludesNativeCallStackWhenReportingExceptions:]):
+ JSContext ObjC SPI to opt-out of including native call stacks in exceptions.
+
+ * API/JSContextRefPrivate.h:
+ * API/JSContextRef.cpp:
+ (JSGlobalContextGetIncludesNativeCallStackWhenReportingExceptions):
+ (JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions):
+ JSContext C SPI to opt-out of including native call stacks in exceptions.
+
+ * inspector/JSGlobalObjectInspectorController.h:
+ * inspector/JSGlobalObjectInspectorController.cpp:
+ (Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
+ (Inspector::JSGlobalObjectInspectorController::reportAPIException):
+ Only include the native call stack if the setting is enabled. It is enabled by default.
+
2014-04-03 Mark Lam <[email protected]>
Fix bit rot in ARMv7 JIT probe mechanism.
Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp (166755 => 166756)
--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp 2014-04-03 23:55:31 UTC (rev 166755)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp 2014-04-04 00:50:49 UTC (rev 166756)
@@ -55,6 +55,7 @@
: m_globalObject(globalObject)
, m_injectedScriptManager(std::make_unique<InjectedScriptManager>(*this, InjectedScriptHost::create()))
, m_inspectorFrontendChannel(nullptr)
+ , m_includeNativeCallStackWithExceptions(true)
{
auto runtimeAgent = std::make_unique<JSGlobalObjectRuntimeAgent>(m_injectedScriptManager.get(), m_globalObject);
auto consoleAgent = std::make_unique<JSGlobalObjectConsoleAgent>(m_injectedScriptManager.get());
@@ -147,7 +148,8 @@
ErrorHandlingScope errorScope(exec->vm());
RefPtr<ScriptCallStack> callStack = createScriptCallStackFromException(exec, exception, ScriptCallStack::maxCallStackSizeToCapture);
- appendAPIBacktrace(callStack.get());
+ if (includesNativeCallStackWhenReportingExceptions())
+ appendAPIBacktrace(callStack.get());
// FIXME: <http://webkit.org/b/115087> Web Inspector: Should not evaluate _javascript_ handling exceptions
// If this is a custom exception object, call toString on it to try and get a nice string representation for the exception.
Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.h (166755 => 166756)
--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.h 2014-04-03 23:55:31 UTC (rev 166755)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.h 2014-04-04 00:50:49 UTC (rev 166756)
@@ -64,6 +64,9 @@
void globalObjectDestroyed();
+ bool includesNativeCallStackWhenReportingExceptions() const { return m_includeNativeCallStackWithExceptions; }
+ void setIncludesNativeCallStackWhenReportingExceptions(bool includesNativeCallStack) { m_includeNativeCallStackWithExceptions = includesNativeCallStack; }
+
void reportAPIException(JSC::ExecState*, JSC::JSValue exception);
JSC::ConsoleClient* consoleClient() const;
@@ -85,6 +88,7 @@
InspectorAgentRegistry m_agents;
InspectorFrontendChannel* m_inspectorFrontendChannel;
RefPtr<InspectorBackendDispatcher> m_inspectorBackendDispatcher;
+ bool m_includeNativeCallStackWithExceptions;
};
} // namespace Inspector