[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}
This commit is contained in:
parent
399c1c18c8
commit
62b6dd1942
@ -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
|
||||
|
17
test/inspector/debugger/step-into-nested-arrow-expected.txt
Normal file
17
test/inspector/debugger/step-into-nested-arrow-expected.txt
Normal file
@ -0,0 +1,17 @@
|
||||
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)
|
23
test/inspector/debugger/step-into-nested-arrow.js
Normal file
23
test/inspector/debugger/step-into-nested-arrow.js
Normal file
@ -0,0 +1,23 @@
|
||||
// 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('');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user