-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deps: cherry-pick 09de996 from V8 upstream
Original commit message: [debugger] fix switch block source positions. The switch statement itself is part of the switch block. However, the source position of the statement is outside of the block. This leads to confusion for the debugger, if the switch block pushes a block context: the current context is a block context, but the scope analysis based on the current source position tells the debugger that we should be outside the scope, so we should have the function context. R=marja@chromium.org BUG=v8:6085 Review-Url: https://codereview.chromium.org/2744213003 Cr-Commit-Position: refs/heads/master@{#43744} Committed: https://chromium.googlesource.com/v8/v8/+/09de9969ccb9bc3bbd667788afad665b309d02f5 Fixes: #11746 PR-URL: #11905 Fixes: #11746 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
- Loading branch information
Showing
4 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// 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. | ||
|
||
function* serialize() { | ||
debugger; | ||
switch (0) { | ||
case 0: | ||
let x = 1; | ||
return x; // Check scopes | ||
} | ||
} | ||
|
||
let exception = null; | ||
let step_count = 0; | ||
let scopes_checked = false; | ||
|
||
function listener(event, exec_state, event_data, data) { | ||
if (event != Debug.DebugEvent.Break) return; | ||
try { | ||
if (exec_state.frame().sourceLineText().includes("Check scopes")) { | ||
let expected = [ debug.ScopeType.Block, | ||
debug.ScopeType.Local, | ||
debug.ScopeType.Script, | ||
debug.ScopeType.Global ]; | ||
for (let i = 0; i < exec_state.frame().scopeCount(); i++) { | ||
assertEquals(expected[i], exec_state.frame().scope(i).scopeType()); | ||
} | ||
scopes_checked = true; | ||
} | ||
if (step_count++ < 3) exec_state.prepareStep(Debug.StepAction.StepNext); | ||
} catch (e) { | ||
exception = e; | ||
print(e, e.stack); | ||
} | ||
} | ||
|
||
|
||
|
||
let Debug = debug.Debug; | ||
Debug.setListener(listener); | ||
|
||
let gen = serialize(); | ||
gen.next(); | ||
|
||
Debug.setListener(null); | ||
assertNull(exception); | ||
assertEquals(4, step_count); | ||
assertTrue(scopes_checked); |