Commit 62b6dd19 authored by yangguo's avatar yangguo Committed by Commit bot

[debugger] correctly find inner function scope.

Nested arrow functions can have the same end positions, so
the end position is unsuitable to decide whether a scope is
an inner function scope.

BUG=chromium:696202
R=jgruber@chromium.org, kozyatinskiy@chromium.org

Review-Url: https://codereview.chromium.org/2751573003
Cr-Commit-Position: refs/heads/master@{#43797}
parent 399c1c18
......@@ -838,8 +838,12 @@ void ScopeIterator::GetNestedScopeChain(Isolate* isolate, Scope* scope,
int position) {
if (scope->is_function_scope()) {
// Do not collect scopes of nested inner functions inside the current one.
// Nested arrow functions could have the same end positions.
Handle<JSFunction> function = frame_inspector_->GetFunction();
if (scope->end_position() < function->shared()->end_position()) return;
if (scope->start_position() > function->shared()->start_position() &&
scope->end_position() <= function->shared()->end_position()) {
return;
}
}
if (scope->is_hidden()) {
// We need to add this chain element in case the scope has a context
......
Checks that stepInto nested arrow function doesn't produce crash.
paused
(anonymous) (test.js:2:0)
(anonymous) (:0:6)
paused
rec (test.js:1:19)
(anonymous) (test.js:2:0)
(anonymous) (:0:6)
paused
rec (test.js:2:5)
(anonymous) (test.js:2:0)
(anonymous) (:0:6)
paused
(anonymous) (test.js:2:5)
(anonymous) (:0:6)
paused
(anonymous) (:0:8)
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
InspectorTest.log(
'Checks that stepInto nested arrow function doesn\'t produce crash.');
InspectorTest.setupScriptMap();
InspectorTest.addScript(`
const rec = (x) => (y) =>
rec();
//# sourceURL=test.js`);
Protocol.Debugger.onPaused(message => {
InspectorTest.log("paused");
InspectorTest.logCallFrames(message.params.callFrames);
Protocol.Debugger.stepInto();
})
Protocol.Debugger.enable();
Protocol.Debugger.setBreakpointByUrl({ url: 'test.js', lineNumber: 2 })
.then(() => Protocol.Runtime.evaluate({ expression: 'rec(5)(4)' }))
.then(InspectorTest.completeTest);
......@@ -160,6 +160,7 @@ InspectorTest.logSourceLocation = function(location)
var line = lines[location.lineNumber];
line = line.slice(0, location.columnNumber) + '#' + (line.slice(location.columnNumber) || '');
lines[location.lineNumber] = line;
lines = lines.filter(line => line.indexOf('//# sourceURL=') === -1);
InspectorTest.log(lines.slice(Math.max(location.lineNumber - 1, 0), location.lineNumber + 2).join('\n'));
InspectorTest.log('');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment