[debug] Fix locals blocklist reuse outside of closures
Bug: chromium:1363561 Change-Id: I50c1448d79cc64f7de456f20941de0add8c464c6 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4004801 Commit-Queue: Shu-yu Guo <syg@chromium.org> Auto-Submit: Shu-yu Guo <syg@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org> Cr-Commit-Position: refs/heads/main@{#84072}
This commit is contained in:
parent
c82f221882
commit
cd31c5bdcc
@ -274,7 +274,11 @@ DebugEvaluate::ContextBuilder::ContextBuilder(Isolate* isolate,
|
||||
scope_info->SetIsDebugEvaluateScope();
|
||||
|
||||
if (v8_flags.experimental_reuse_locals_blocklists) {
|
||||
if (rit == context_chain_.rbegin()) {
|
||||
// In the case where the "paused function scope" is the script scope
|
||||
// itself, we don't need (and don't have) a blocklist.
|
||||
const bool paused_scope_is_script_scope =
|
||||
scope_iterator_.Done() || scope_iterator_.InInnerScope();
|
||||
if (rit == context_chain_.rbegin() && !paused_scope_is_script_scope) {
|
||||
// The DebugEvaluateContext we create for the closure scope is the only
|
||||
// DebugEvaluateContext with a block list. This means we'll retrieve
|
||||
// the existing block list from the paused function scope
|
||||
|
@ -0,0 +1,17 @@
|
||||
Test for Debugger.evaluateOnCallFrame and locals blocklist reuse
|
||||
|
||||
Running test: testContextChainNotInsideFunction
|
||||
{
|
||||
className : Function
|
||||
description : class C {}
|
||||
objectId : <objectId>
|
||||
type : function
|
||||
}
|
||||
|
||||
Running test: testContextChainInsideFunction
|
||||
{
|
||||
className : Function
|
||||
description : class C {}
|
||||
objectId : <objectId>
|
||||
type : function
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
// Copyright 2022 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: --experimental-reuse-locals-blocklists
|
||||
|
||||
const {session, Protocol} = InspectorTest.start(
|
||||
`Test for Debugger.evaluateOnCallFrame and locals blocklist reuse`);
|
||||
|
||||
InspectorTest.runAsyncTestSuite([
|
||||
async function testContextChainNotInsideFunction() {
|
||||
await Protocol.Debugger.enable();
|
||||
await Protocol.Runtime.enable();
|
||||
|
||||
let source = `
|
||||
class C {}
|
||||
try {
|
||||
let c = new C();
|
||||
} catch (e) {}
|
||||
`;
|
||||
const {result: {scriptId}} = await Protocol.Runtime.compileScript(
|
||||
{expression: source, sourceURL: 'notInside.js', persistScript: true});
|
||||
let {result: {breakpointId}} = await Protocol.Debugger.setBreakpointByUrl(
|
||||
{lineNumber: 3, url: 'notInside.js'});
|
||||
const runPromise = Protocol.Runtime.runScript({scriptId});
|
||||
let {params: {reason, callFrames: [{callFrameId}]}} =
|
||||
await Protocol.Debugger.oncePaused();
|
||||
|
||||
const {result: {result}} = await Protocol.Debugger.evaluateOnCallFrame(
|
||||
{callFrameId, expression: 'C'});
|
||||
InspectorTest.logMessage(result);
|
||||
|
||||
await Protocol.Debugger.resume();
|
||||
await runPromise;
|
||||
|
||||
await Protocol.Debugger.disable();
|
||||
await Protocol.Runtime.disable();
|
||||
},
|
||||
|
||||
async function testContextChainInsideFunction() {
|
||||
await Protocol.Debugger.enable();
|
||||
await Protocol.Runtime.enable();
|
||||
|
||||
let source = `
|
||||
var someRandomStuff = 42;
|
||||
(function foo() {
|
||||
class C {}
|
||||
try {
|
||||
let c = new C();
|
||||
} catch (e) {}
|
||||
})();
|
||||
`;
|
||||
const {result: {scriptId}} = await Protocol.Runtime.compileScript(
|
||||
{expression: source, sourceURL: 'inside.js', persistScript: true});
|
||||
let {result: {breakpointId}} = await Protocol.Debugger.setBreakpointByUrl(
|
||||
{lineNumber: 5, url: 'inside.js'});
|
||||
const runPromise = Protocol.Runtime.runScript({scriptId});
|
||||
let {params: {reason, callFrames: [{callFrameId}]}} =
|
||||
await Protocol.Debugger.oncePaused();
|
||||
|
||||
const {result: {result}} = await Protocol.Debugger.evaluateOnCallFrame(
|
||||
{callFrameId, expression: 'C'});
|
||||
InspectorTest.logMessage(result);
|
||||
|
||||
await Protocol.Debugger.resume();
|
||||
await runPromise;
|
||||
|
||||
await Protocol.Debugger.disable();
|
||||
await Protocol.Runtime.disable();
|
||||
}
|
||||
]);
|
Loading…
Reference in New Issue
Block a user