Bug 152193 - Web Inspector: Separate Debugger enable state from the debugger breakpoints enabled state
Summary: Web Inspector: Separate Debugger enable state from the debugger breakpoints e...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Saam Barati
URL:
Keywords: InRadar
Depends on:
Blocks: 155809
  Show dependency treegraph
 
Reported: 2015-12-11 15:42 PST by Joseph Pecoraro
Modified: 2016-03-24 15:43 PDT (History)
12 users (show)

See Also:


Attachments
patch (8.82 KB, patch)
2016-03-23 18:00 PDT, Saam Barati
joepeck: review-
Details | Formatted Diff | Diff
patch (12.43 KB, patch)
2016-03-24 14:03 PDT, Saam Barati
joepeck: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2015-12-11 15:42:17 PST
* SUMMARY
Separate Debugger enable state from being attached.

Currently JSC assumes if a JSC::Debugger is attached the debugger is enabled. We are using the JSC::Debugger to access more debugger properties and we may want a debugger to be attached but disabled.
Comment 1 Radar WebKit Bug Importer 2015-12-11 15:42:34 PST
<rdar://problem/23867520>
Comment 2 Timothy Hatcher 2016-03-23 11:11:19 PDT
This might be less important after some recent changes Saam made to allow the page to inline and use the FTL JIT when the debugger is attached.
Comment 3 Saam Barati 2016-03-23 15:28:31 PDT
(In reply to comment #2)
> This might be less important after some recent changes Saam made to allow
> the page to inline and use the FTL JIT when the debugger is attached.

I'm rolling out my inlining patch. I think this is still important. I'm
going to start work on the JSC bits of this.
Comment 4 Saam Barati 2016-03-23 18:00:11 PDT
Created attachment 274804 [details]
patch
Comment 5 Joseph Pecoraro 2016-03-23 18:08:15 PDT
Comment on attachment 274804 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=274804&action=review

Looks good to me from an inspector perspective.

> Source/JavaScriptCore/debugger/ScriptProfilingScope.h:58
> -        if (!m_globalObject->hasDebugger())
> +        if (!m_globalObject->hasInteractiveDebugger())
>              return false;

This should just stay hasDebugger. The Sampling Profiler just needs globalObject->debugger(), it doesn't care if breakpoints are available or not.

> Source/JavaScriptCore/debugger/ScriptProfilingScope.h:77
>          // Debugger may have been removed.
> -        if (!m_globalObject->hasDebugger())
> +        if (!m_globalObject->hasInteractiveDebugger())
>              return false;

Same here.

I think as a result of doing this you can now remove the FIXMEs in LayoutTests/inspector/script-profiler tests. Namely things that look like:

    // FIXME: <https://webkit.org/b/152193> Web Inspector: Separate Debugger enable state from being attached
    // Debugger should not need to be enabled for profiling to work.
    InspectorProtocol.sendCommand("Debugger.enable", {});
Comment 6 Saam Barati 2016-03-23 20:49:49 PDT
Comment on attachment 274804 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=274804&action=review

>> Source/JavaScriptCore/debugger/ScriptProfilingScope.h:58
>>              return false;
> 
> This should just stay hasDebugger. The Sampling Profiler just needs globalObject->debugger(), it doesn't care if breakpoints are available or not.

Makes sense. I'll revert this.
Comment 7 Joseph Pecoraro 2016-03-23 22:56:55 PDT
Comment on attachment 274804 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=274804&action=review

>> Source/JavaScriptCore/debugger/ScriptProfilingScope.h:77
>>              return false;
> 
> Same here.
> 
> I think as a result of doing this you can now remove the FIXMEs in LayoutTests/inspector/script-profiler tests. Namely things that look like:
> 
>     // FIXME: <https://webkit.org/b/152193> Web Inspector: Separate Debugger enable state from being attached
>     // Debugger should not need to be enabled for profiling to work.
>     InspectorProtocol.sendCommand("Debugger.enable", {});

r- to update these tests, because after all they reference this bugzilla bug!

script-profiler/event-type-API.html
39:    // FIXME: <https://webkit.org/b/152193> Web Inspector: Separate Debugger enable state from being attached

script-profiler/event-type-Microtask.html
40:    // FIXME: <https://webkit.org/b/152193> Web Inspector: Separate Debugger enable state from being attached

script-profiler/event-type-Other.html
57:    // FIXME: <https://webkit.org/b/152193> Web Inspector: Separate Debugger enable state from being attached
Comment 8 Saam Barati 2016-03-24 14:03:07 PDT
Created attachment 274854 [details]
patch
Comment 9 Joseph Pecoraro 2016-03-24 14:21:51 PDT
Comment on attachment 274854 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=274854&action=review

r=me

> Source/JavaScriptCore/debugger/Debugger.cpp:535
>  void Debugger::setBreakpointsActivated(bool activated)
>  {
> +    bool stateChanged = activated != m_breakpointsActivated;
>      m_breakpointsActivated = activated;
> +    if (stateChanged)
> +        recompileAllJSFunctions();
>  }

I think we would normally write this with an early return if the state is not changing:

    if (m_breakpointsActivated == activated)
        return;
    m_breakpointsActivated = activated;
    recompileAllJSFunctions();
Comment 10 Saam Barati 2016-03-24 15:43:27 PDT
landed in:
http://trac.webkit.org/changeset/198648