Commit 01902e4e authored by yangguo's avatar yangguo Committed by Commit bot

Debugger: use FrameInspector in ScopeIterator to find context.

In optimized code, it's not guaranteed that the current context
is stored in its frame slot.

R=bmeurer@chromium.org
BUG=v8:4309
LOG=N

Committed: https://crrev.com/3a0ee39cbde6a9778cfc4e2a6a0a8ff68933ff38
Cr-Commit-Position: refs/heads/master@{#29697}

Review URL: https://codereview.chromium.org/1239033002

Cr-Commit-Position: refs/heads/master@{#29744}
parent cc66a1c6
......@@ -2735,19 +2735,8 @@ void Debug::HandleDebugBreak() {
bool debug_command_only = isolate_->stack_guard()->CheckDebugCommand() &&
!isolate_->stack_guard()->CheckDebugBreak();
bool is_debugger_statement = !isolate_->stack_guard()->CheckDebugCommand() &&
!isolate_->stack_guard()->CheckDebugBreak();
isolate_->stack_guard()->ClearDebugBreak();
if (is_debugger_statement) {
// If we have been called via 'debugger' Javascript statement,
// we might not be prepared for breakpoints.
// TODO(dslomov,yangguo): CheckDebugBreak may race with RequestDebugBreak.
// Revisit this to clean-up.
HandleScope handle_scope(isolate_);
PrepareForBreakPoints();
}
ProcessDebugMessages(debug_command_only);
}
......
This diff is collapsed.
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug
// Flags: --expose-debug-as debug --allow-natives-syntax
// The functions used for testing backtraces. They are at the top to make the
// testing of source line/column easier.
......@@ -187,6 +187,14 @@ function CheckScopeContent(content, number, exec_state) {
}
function assertEqualsUnlessOptimized(expected, value, f) {
try {
assertEquals(expected, value);
} catch (e) {
assertOptimized(f);
}
}
// Simple empty block scope in local scope.
BeginTest("Local block 1");
......@@ -517,11 +525,11 @@ function shadowing_1() {
{
let i = 5;
debugger;
assertEquals(27, i);
assertEqualsUnlessOptimized(27, i, shadowing_1);
}
assertEquals(0, i);
debugger;
assertEquals(27, i);
assertEqualsUnlessOptimized(27, i, shadowing_1);
}
listener_delegate = function (exec_state) {
......@@ -538,9 +546,9 @@ function shadowing_2() {
{
let j = 5;
debugger;
assertEquals(27, j);
assertEqualsUnlessOptimized(27, j, shadowing_2);
}
assertEquals(0, i);
assertEqualsUnlessOptimized(0, i, shadowing_2);
}
listener_delegate = function (exec_state) {
......
// Copyright 2015 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.
// Flags: --expose-debug-as debug --allow-natives-syntax
var Debug = debug.Debug;
var exception = null;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
var scopes = exec_state.frame().allScopes();
assertEquals(3, scopes.length);
assertEquals(debug.ScopeType.Local, scopes[0].scopeType());
assertEquals(debug.ScopeType.Script, scopes[1].scopeType());
assertEquals(debug.ScopeType.Global, scopes[2].scopeType());
} catch (e) {
exception = e;
}
}
function f() {
eval('');
debugger;
}
f();
f();
%OptimizeFunctionOnNextCall(f);
Debug.setListener(listener);
f();
assertNull(exception);
// Copyright 2015 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.
// Flags: --expose-debug-as debug --allow-natives-syntax
var Debug = debug.Debug;
var exception = null;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
var scope = exec_state.frame().scope(0);
assertEquals(5, scope.scopeObject().property("i").value().value());
} catch (e) {
exception = e;
}
}
function f() {
eval('var i = 5');
debugger;
}
f();
f();
%OptimizeFunctionOnNextCall(f);
Debug.setListener(listener);
f();
assertNull(exception);
// Copyright 2015 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.
// Flags: --expose-debug-as debug --allow-natives-syntax
var Debug = debug.Debug;
var exception = null;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
var scopes = exec_state.frame().allScopes();
assertEquals(4, scopes.length);
assertEquals(debug.ScopeType.With, scopes[0].scopeType());
assertEquals(debug.ScopeType.Local, scopes[1].scopeType());
assertEquals(debug.ScopeType.Script, scopes[2].scopeType());
assertEquals(debug.ScopeType.Global, scopes[3].scopeType());
} catch (e) {
exception = e;
}
}
function f() {
with({}) {
debugger;
}
}
f();
f();
%OptimizeFunctionOnNextCall(f);
Debug.setListener(listener);
f();
assertNull(exception);
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