Title: [180660] trunk
Revision
180660
Author
msab...@apple.com
Date
2015-02-25 22:05:02 -0800 (Wed, 25 Feb 2015)

Log Message

Web Inspector: CRASH when debugger pauses inside a Promise handler
https://bugs.webkit.org/show_bug.cgi?id=141396

Reviewed by Mark Lam.

Source/_javascript_Core:

For frames that don't have a scope, typically native frames, use the lexicalGlobalObject to
create the DebuggerScope for that frame.

* debugger/DebuggerCallFrame.cpp:
(JSC::DebuggerCallFrame::scope):

LayoutTests:

New test.

* inspector/debugger/breakpoint-scope-expected.txt: Added.
* inspector/debugger/breakpoint-scope.html: Added.
* inspector/debugger/resources/scope.js: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (180659 => 180660)


--- trunk/LayoutTests/ChangeLog	2015-02-26 05:43:59 UTC (rev 180659)
+++ trunk/LayoutTests/ChangeLog	2015-02-26 06:05:02 UTC (rev 180660)
@@ -1,3 +1,16 @@
+2015-02-25  Michael Saboff  <msab...@apple.com>
+
+        Web Inspector: CRASH when debugger pauses inside a Promise handler
+        https://bugs.webkit.org/show_bug.cgi?id=141396
+
+        Reviewed by Mark Lam.
+
+        New test.
+
+        * inspector/debugger/breakpoint-scope-expected.txt: Added.
+        * inspector/debugger/breakpoint-scope.html: Added.
+        * inspector/debugger/resources/scope.js: Added.
+
 2015-02-25  Brent Fulgham  <bfulg...@apple.com>
 
         [Win] Make Windows green again after r180654.

Added: trunk/LayoutTests/inspector/debugger/breakpoint-scope-expected.txt (0 => 180660)


--- trunk/LayoutTests/inspector/debugger/breakpoint-scope-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/breakpoint-scope-expected.txt	2015-02-26 06:05:02 UTC (rev 180660)
@@ -0,0 +1,13 @@
+CONSOLE MESSAGE: line 1: Paused at line: 2, column: 8
+Testing that we can access scope in various functions.
+
+Starting Test
+Hit breakpoint at line: 2, column: 8
+scope-chain-type-local properties:
+    resolve
+    reject
+scope-chain-type-closure properties:
+    p
+scope-chain-type-global (properties not listed)
+Tests done
+

Added: trunk/LayoutTests/inspector/debugger/breakpoint-scope.html (0 => 180660)


--- trunk/LayoutTests/inspector/debugger/breakpoint-scope.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/breakpoint-scope.html	2015-02-26 06:05:02 UTC (rev 180660)
@@ -0,0 +1,100 @@
+<!doctype html>
+<html>
+<head>
+<script type="text/_javascript_" src=""
+<script type="text/_javascript_" src=""
+<script type="text/_javascript_" src=""
+<script>
+
+function test()
+{
+    var testInfoList = [
+        { line : 2, column : 8, startFunc : "testNativeScope()" }
+    ];
+
+    var currentTestIndex = 0;
+    var scriptObject;
+
+    function startTest() {
+        InspectorTest.log("Starting Test");
+        runNextTest();
+    }
+
+    function runNextTest() {
+        if (currentTestIndex >= testInfoList.length) {
+            InspectorTest.log("Tests done");
+            InspectorTest.completeTest();
+            return;
+        }
+
+        var testInfo = testInfoList[currentTestIndex];
+        var location = scriptObject.createSourceCodeLocation(testInfo.line, testInfo.column);
+        var breakpoint = new WebInspector.Breakpoint(location);
+
+        WebInspector.debuggerManager.addBreakpoint(breakpoint);
+        InspectorTest.evaluateInPage(testInfo.startFunc);
+
+        currentTestIndex++;
+    }
+
+    WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.CallFramesDidChange, function(event) {
+        var activeCallFrame = WebInspector.debuggerManager.activeCallFrame;
+
+        if (!activeCallFrame)
+            return;
+
+        var stopLocation = "line: " + activeCallFrame.sourceCodeLocation.lineNumber + ", column: " + activeCallFrame.sourceCodeLocation.columnNumber;
+
+        InspectorTest.log("Hit breakpoint at " + stopLocation);
+        InspectorTest.evaluateInPage("console.log('Paused at " + stopLocation + "')");
+
+        var activeCallFrame = WebInspector.debuggerManager.activeCallFrame;
+        var scopeChain = activeCallFrame.scopeChain;
+        var scopeTypes = [];
+        var scopeTypeIndex = 0;
+        var globalScopeCount = 0;
+
+        for (var scope of scopeChain) {
+            scopeTypes.push(scope.type);
+            if (scope.type !== WebInspector.ScopeChainNode.Type.Global) {
+                scope.object.getAllPropertyDescriptors(function(properties) {
+                    InspectorTest.log(scopeTypes[scopeTypeIndex++] + " properties:");
+                    for (var propertyDescriptor of properties)
+                        InspectorTest.log("    " + propertyDescriptor.name);
+
+                    if (scopeTypeIndex == scopeTypes.length - 1)
+                        InspectorTest.log(scopeTypes[scopeTypeIndex] + " (properties not listed)");
+                });
+            } else
+                globalScopeCount++;
+        }
+
+        if (globalScopeCount != 1)
+            InspectorTest.log("Error: too many " + WebInspector.ScopeChainNode.Type.Global + " scopes");
+
+        WebInspector.debuggerManager.resume();
+    });
+
+    WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.Resumed, function(event) {
+       runNextTest();
+    });
+
+    WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, function(event) {
+        eventScriptObject = event.data.script;
+        
+        if (/scope\.js$/.test(eventScriptObject.url)) {
+            scriptObject = eventScriptObject;
+            startTest();
+            return;
+        }
+
+    });
+
+    InspectorTest.reloadPage();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+    <p>Testing that we can access scope in various functions.</p>
+</body>
+</html>

Added: trunk/LayoutTests/inspector/debugger/resources/scope.js (0 => 180660)


--- trunk/LayoutTests/inspector/debugger/resources/scope.js	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/resources/scope.js	2015-02-26 06:05:02 UTC (rev 180660)
@@ -0,0 +1,8 @@
+function testNativeScope() {
+    var p = new Promise(function(resolve, reject) {
+        debugger;
+    })
+
+    return p;
+}
+

Modified: trunk/Source/_javascript_Core/ChangeLog (180659 => 180660)


--- trunk/Source/_javascript_Core/ChangeLog	2015-02-26 05:43:59 UTC (rev 180659)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-02-26 06:05:02 UTC (rev 180660)
@@ -1,3 +1,16 @@
+2015-02-25  Michael Saboff  <msab...@apple.com>
+
+        Web Inspector: CRASH when debugger pauses inside a Promise handler
+        https://bugs.webkit.org/show_bug.cgi?id=141396
+
+        Reviewed by Mark Lam.
+
+        For frames that don't have a scope, typically native frames, use the lexicalGlobalObject to
+        create the DebuggerScope for that frame.
+
+        * debugger/DebuggerCallFrame.cpp:
+        (JSC::DebuggerCallFrame::scope):
+
 2015-02-25  Filip Pizlo  <fpi...@apple.com>
 
         DFG abstract heaps should respect the difference between heap and stack

Modified: trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp (180659 => 180660)


--- trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp	2015-02-26 05:43:59 UTC (rev 180659)
+++ trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp	2015-02-26 06:05:02 UTC (rev 180660)
@@ -147,8 +147,10 @@
         CodeBlock* codeBlock = m_callFrame->codeBlock();
         if (codeBlock && codeBlock->scopeRegister().isValid())
             scope = m_callFrame->scope(codeBlock->scopeRegister().offset());
+        else if (JSCallee* callee = jsDynamicCast<JSCallee*>(m_callFrame->callee()))
+            scope = callee->scope();
         else
-            scope = jsCast<JSCallee*>(m_callFrame->callee())->scope();
+            scope = m_callFrame->lexicalGlobalObject();
 
         m_scope.set(vm, DebuggerScope::create(vm, scope));
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to