Web Inspector: Wrong function name next to scope
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Jun 2016 23:59:35 +0000 (23:59 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Jun 2016 23:59:35 +0000 (23:59 +0000)
commitc620261e502b0db3174df3329cfcb7502778f6df
tree17be99231a6e473d36572de7783b151765e05497
parentde019272ec57ba6750446b8a04e0c8d5486b82eb
Web Inspector: Wrong function name next to scope
https://bugs.webkit.org/show_bug.cgi?id=158210
<rdar://problem/26543093>

Reviewed by Brian Burg.

Source/JavaScriptCore:

* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
Add DebuggerLocation. A helper for describing a unique location.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::setConstantRegisters):
When compiled with debug info, add a SymbolTable rare data pointer
back to the CodeBlock. This will be used later to get JSScope debug
info if Web Inspector pauses.

* runtime/SymbolTable.h:
* runtime/SymbolTable.cpp:
(JSC::SymbolTable::cloneScopePart):
(JSC::SymbolTable::prepareForTypeProfiling):
(JSC::SymbolTable::uniqueIDForVariable):
(JSC::SymbolTable::uniqueIDForOffset):
(JSC::SymbolTable::globalTypeSetForOffset):
(JSC::SymbolTable::globalTypeSetForVariable):
Rename rareData and include a CodeBlock pointer.

(JSC::SymbolTable::rareDataCodeBlock):
(JSC::SymbolTable::setRareDataCodeBlock):
Setter and getter for the rare data. It should only be set once.

(JSC::SymbolTable::visitChildren):
Visit the rare data code block if we have one.

* debugger/DebuggerLocation.cpp: Added.
(JSC::DebuggerLocation::DebuggerLocation):
* debugger/DebuggerLocation.h: Added.
(JSC::DebuggerLocation::DebuggerLocation):
Construction from a ScriptExecutable.

* runtime/JSScope.cpp:
(JSC::JSScope::symbolTable):
* runtime/JSScope.h:
* debugger/DebuggerScope.h:
* debugger/DebuggerScope.cpp:
(JSC::DebuggerScope::name):
(JSC::DebuggerScope::location):
Name and location for a scope. This uses:
JSScope -> SymbolTable -> CodeBlock -> Executable

* inspector/protocol/Debugger.json:
* inspector/InjectedScriptSource.js:
(InjectedScript.CallFrameProxy.prototype._wrapScopeChain):
(InjectedScript.CallFrameProxy._createScopeJson):
* inspector/JSJavaScriptCallFrame.cpp:
(Inspector::valueForScopeType):
(Inspector::valueForScopeLocation):
(Inspector::JSJavaScriptCallFrame::scopeDescriptions):
(Inspector::JSJavaScriptCallFrame::scopeType): Deleted.
* inspector/JSJavaScriptCallFrame.h:
* inspector/JSJavaScriptCallFramePrototype.cpp:
(Inspector::JSJavaScriptCallFramePrototype::finishCreation):
(Inspector::jsJavaScriptCallFramePrototypeFunctionScopeDescriptions):
(Inspector::jsJavaScriptCallFramePrototypeFunctionScopeType): Deleted.
Simplify this code to build the objects we will send across the protocol
to descript a Scope.

Source/WebInspectorUI:

* UserInterface/Controllers/DebuggerManager.js:
(WebInspector.DebuggerManager.prototype._scopeChainNodeFromPayload):
Include new payload data in the construction call.
All the new data is optional, so we gracefully handle
legacy backends.

* UserInterface/Models/ScopeChainNode.js:
(WebInspector.ScopeChainNode):
(WebInspector.ScopeChainNode.prototype.get type):
(WebInspector.ScopeChainNode.prototype.get objects):
(WebInspector.ScopeChainNode.prototype.get name):
(WebInspector.ScopeChainNode.prototype.get location):
(WebInspector.ScopeChainNode.prototype.get hash):
Hash is a rough (name:sourceId:line:column) string for quick comparisons.

(WebInspector.ScopeChainNode.prototype.makeLocalScope):
Make this an action you take on a scope, to avoid having to
do it at construction time, or making it a generic setting.

* UserInterface/Views/ScopeChainDetailsSidebarPanel.js:
(WebInspector.ScopeChainDetailsSidebarPanel.prototype._generateCallFramesSection):
This was wrong before. Move the work to CallFrame
and change it to be correct.

* UserInterface/CallFrame.js:
(WebInspector.CallFrame.prototype.mergedScopeChain):

This transforms the scope chain for a call frame from:

     scope1  scope2  scope3  scope4  scope5  scope6  scope7
      foo     foo     foo     bar     bar      -       -
     Block  Closure Closure Closure Closure   GLE     GBL

To:
     scope1  scope2&3   scope4&5  scope6  scope7
      foo      foo*       bar*      -       -
     Block    Local     Closure    GLE     GBL

Doing a few things:

    - Merge the first two Closure scopes sharing a location.
      These are the "var" and "let" Closure scopes in a function,
      and it is better to present these together in the UI.

    - Mark the first Closure scope within a function (*). When
      this is displayed in the UI, we can provide the name of
      the function: "Closure Scope (name)", and we even have
      location information that we can use to display a goto
      arrow if needed.

    - Make the first Closure scope the Local scope if it
      matches the Call Frame's function name. This lets us
      display the section as "Local Variables".

LayoutTests:

* inspector/debugger/paused-scopes-expected.txt: Added.
* inspector/debugger/paused-scopes.html: Added.
* inspector/debugger/resources/paused-scopes.js: Added.
Test dumps the call frames and scope chains for each call frame
when pausing at different locations in a program. Outputting
the hashes we can see even identically named functions have
different hashes because their location is different.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202659 268f45cc-cd09-0410-ab3c-d52691b4dbfc
26 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/debugger/paused-scopes-expected.txt [new file with mode: 0644]
LayoutTests/inspector/debugger/paused-scopes.html [new file with mode: 0644]
LayoutTests/inspector/debugger/resources/paused-scopes.js [new file with mode: 0644]
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/bytecode/CodeBlock.cpp
Source/JavaScriptCore/debugger/DebuggerLocation.cpp [new file with mode: 0644]
Source/JavaScriptCore/debugger/DebuggerLocation.h [new file with mode: 0644]
Source/JavaScriptCore/debugger/DebuggerScope.cpp
Source/JavaScriptCore/debugger/DebuggerScope.h
Source/JavaScriptCore/inspector/InjectedScriptSource.js
Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp
Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.h
Source/JavaScriptCore/inspector/JSJavaScriptCallFramePrototype.cpp
Source/JavaScriptCore/inspector/protocol/Debugger.json
Source/JavaScriptCore/runtime/JSScope.cpp
Source/JavaScriptCore/runtime/JSScope.h
Source/JavaScriptCore/runtime/SymbolTable.cpp
Source/JavaScriptCore/runtime/SymbolTable.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js
Source/WebInspectorUI/UserInterface/Models/CallFrame.js
Source/WebInspectorUI/UserInterface/Models/ScopeChainNode.js
Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js