Changeset 166756 in webkit


Ignore:
Timestamp:
Apr 3, 2014 5:50:49 PM (10 years ago)
Author:
commit-queue@webkit.org
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 <Joseph Pecoraro> 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.

Location:
trunk/Source/JavaScriptCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSContext.mm

    r166367 r166756  
    214214}
    215215
     216- (BOOL)_includesNativeCallStackWhenReportingExceptions
     217{
     218    return JSGlobalContextGetIncludesNativeCallStackWhenReportingExceptions(m_context);
     219}
     220
     221- (void)_setIncludesNativeCallStackWhenReportingExceptions:(BOOL)includeNativeCallStack
     222{
     223    JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(m_context, includeNativeCallStack);
     224}
     225
    216226@end
    217227
  • trunk/Source/JavaScriptCore/API/JSContextPrivate.h

    r166367 r166756  
    3939@property (setter=_setRemoteInspectionEnabled:) BOOL _remoteInspectionEnabled NS_AVAILABLE(10_10, 8_0);
    4040
     41/*!
     42@property
     43@discussion Set whether or not the native call stack is included when reporting exceptions. Default value is YES.
     44*/
     45@property (setter=_setIncludesNativeCallStackWhenReportingExceptions:) BOOL _includesNativeCallStackWhenReportingExceptions NS_AVAILABLE(10_10, 8_0);
     46
    4147@end
    4248
  • trunk/Source/JavaScriptCore/API/JSContextRef.cpp

    r166415 r166756  
    4141#include <wtf/text/StringHash.h>
    4242
     43#if ENABLE(REMOTE_INSPECTOR)
     44#include "JSGlobalObjectInspectorController.h"
     45#endif
     46
    4347#if OS(DARWIN)
    4448#include <mach-o/dyld.h>
     
    321325    exec->vmEntryGlobalObject()->setRemoteDebuggingEnabled(enabled);
    322326}
     327
     328bool JSGlobalContextGetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx)
     329{
     330#if ENABLE(REMOTE_INSPECTOR)
     331    if (!ctx) {
     332        ASSERT_NOT_REACHED();
     333        return false;
     334    }
     335
     336    ExecState* exec = toJS(ctx);
     337    JSLockHolder lock(exec);
     338
     339    JSGlobalObject* globalObject = exec->vmEntryGlobalObject();
     340    return globalObject->inspectorController().includesNativeCallStackWhenReportingExceptions();
     341#else
     342    UNUSED_PARAM(ctx);
     343    return false;
     344#endif
     345}
     346
     347void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx, bool includesNativeCallStack)
     348{
     349#if ENABLE(REMOTE_INSPECTOR)
     350    if (!ctx) {
     351        ASSERT_NOT_REACHED();
     352        return;
     353    }
     354
     355    ExecState* exec = toJS(ctx);
     356    JSLockHolder lock(exec);
     357
     358    JSGlobalObject* globalObject = exec->vmEntryGlobalObject();
     359    globalObject->inspectorController().setIncludesNativeCallStackWhenReportingExceptions(includesNativeCallStack);
     360#else
     361    UNUSED_PARAM(ctx);
     362    UNUSED_PARAM(includesNativeCallStack);
     363#endif
     364}
     365
  • trunk/Source/JavaScriptCore/API/JSContextRefPrivate.h

    r166367 r166756  
    112112JS_EXPORT void JSGlobalContextSetRemoteInspectionEnabled(JSGlobalContextRef ctx, bool enabled) CF_AVAILABLE(10_10, 8_0);   
    113113
     114/*!
     115@function
     116@abstract Gets the include native call stack when reporting exceptions setting for a context.
     117@param ctx The JSGlobalContext whose setting you want to get.
     118@result The value of the setting, true if remote inspection is enabled, otherwise false.
     119@discussion This setting is true by default.
     120*/
     121JS_EXPORT bool JSGlobalContextGetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx) CF_AVAILABLE(10_10, 8_0);
     122
     123/*!
     124@function
     125@abstract Sets the include native call stack when reporting exceptions setting for a context.
     126@param ctx The JSGlobalContext that you want to change.
     127@param includeNativeCallStack The new value of the setting for the context.
     128*/
     129JS_EXPORT void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx, bool includesNativeCallStack) CF_AVAILABLE(10_10, 8_0);   
     130
    114131#ifdef __cplusplus
    115132}
  • trunk/Source/JavaScriptCore/ChangeLog

    r166732 r166756  
     12014-04-03  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: JSContext inspection provide a way to opt-out of including Native Call Stacks in Exception traces reported to Web Inspector
     4        https://bugs.webkit.org/show_bug.cgi?id=131186
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * API/JSContextPrivate.h:
     9        * API/JSContext.mm:
     10        (-[JSContext _includesNativeCallStackWhenReportingExceptions]):
     11        (-[JSContext _setIncludesNativeCallStackWhenReportingExceptions:]):
     12        JSContext ObjC SPI to opt-out of including native call stacks in exceptions.
     13
     14        * API/JSContextRefPrivate.h:
     15        * API/JSContextRef.cpp:
     16        (JSGlobalContextGetIncludesNativeCallStackWhenReportingExceptions):
     17        (JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions):
     18        JSContext C SPI to opt-out of including native call stacks in exceptions.
     19
     20        * inspector/JSGlobalObjectInspectorController.h:
     21        * inspector/JSGlobalObjectInspectorController.cpp:
     22        (Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
     23        (Inspector::JSGlobalObjectInspectorController::reportAPIException):
     24        Only include the native call stack if the setting is enabled. It is enabled by default.
     25
    1262014-04-03  Mark Lam  <mark.lam@apple.com>
    227
  • trunk/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp

    r165575 r166756  
    5656    , m_injectedScriptManager(std::make_unique<InjectedScriptManager>(*this, InjectedScriptHost::create()))
    5757    , m_inspectorFrontendChannel(nullptr)
     58    , m_includeNativeCallStackWithExceptions(true)
    5859{
    5960    auto runtimeAgent = std::make_unique<JSGlobalObjectRuntimeAgent>(m_injectedScriptManager.get(), m_globalObject);
     
    148149
    149150    RefPtr<ScriptCallStack> callStack = createScriptCallStackFromException(exec, exception, ScriptCallStack::maxCallStackSizeToCapture);
    150     appendAPIBacktrace(callStack.get());
     151    if (includesNativeCallStackWhenReportingExceptions())
     152        appendAPIBacktrace(callStack.get());
    151153
    152154    // FIXME: <http://webkit.org/b/115087> Web Inspector: Should not evaluate JavaScript handling exceptions
  • trunk/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.h

    r165199 r166756  
    6565    void globalObjectDestroyed();
    6666
     67    bool includesNativeCallStackWhenReportingExceptions() const { return m_includeNativeCallStackWithExceptions; }
     68    void setIncludesNativeCallStackWhenReportingExceptions(bool includesNativeCallStack) { m_includeNativeCallStackWithExceptions = includesNativeCallStack; }
     69
    6770    void reportAPIException(JSC::ExecState*, JSC::JSValue exception);
    6871
     
    8689    InspectorFrontendChannel* m_inspectorFrontendChannel;
    8790    RefPtr<InspectorBackendDispatcher> m_inspectorBackendDispatcher;
     91    bool m_includeNativeCallStackWithExceptions;
    8892};
    8993
Note: See TracChangeset for help on using the changeset viewer.