Commit 01605d56 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by V8 LUCI CQ

[debug] Default to last break index.

When looking up the break index for a given source position, default to
the last break index if there is neither a precise match nor a breakable
position after the source position (in which case we still pick the
first candidate).

Fixed: chromium:1222065
Bug: chromium:901819, chromium:782461, chromium:1222060
Change-Id: I10d6a086b2d5fadc9e6dca0c49ed4187eb0359ff
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2972917
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Kim-Anh Tran <kimanh@chromium.org>
Reviewed-by: 's avatarKim-Anh Tran <kimanh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75284}
parent 18909135
......@@ -220,18 +220,16 @@ BreakIterator::BreakIterator(Handle<DebugInfo> debug_info)
}
int BreakIterator::BreakIndexFromPosition(int source_position) {
int first_break = break_index();
bool first = true;
while (!Done()) {
int next_position = position();
if (source_position == next_position) return break_index();
if (source_position <= next_position && first) {
first_break = break_index();
first = false;
for (; !Done(); Next()) {
if (source_position <= position()) {
int first_break = break_index();
for (; !Done(); Next()) {
if (source_position == position()) return break_index();
}
return first_break;
}
Next();
}
return first_break;
return break_index();
}
void BreakIterator::Next() {
......
Regression test for crbug.com/1222065
Running test: test
- Debugger.setBreakpoint(foo.js:2:9)
function foo(x) {
return x;#
}
- Debugger.setBreakpoint(foo.js:3)
function foo(x) {
return x;#
}
// Copyright 2021 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.
const {session, contextGroup, Protocol} =
InspectorTest.start('Regression test for crbug.com/1222065');
const source = `
function foo(x) {
return x;
}
`;
InspectorTest.runAsyncTestSuite([
async function test() {
session.setupScriptMap();
await Promise.all([
Protocol.Runtime.enable(),
Protocol.Debugger.enable()
]);
contextGroup.addScript(source, 0, 0, 'foo.js');
const { params: { scriptId } } = await Protocol.Debugger.onceScriptParsed();
InspectorTest.log('- Debugger.setBreakpoint(foo.js:2:9)');
let {result: {actualLocation, breakpointId}} = await Protocol.Debugger.setBreakpoint({location: {
scriptId,
lineNumber: 2,
columnNumber: 9,
}});
await session.logSourceLocation(actualLocation);
await Protocol.Debugger.removeBreakpoint({breakpointId});
InspectorTest.log('- Debugger.setBreakpoint(foo.js:3)');
({result: {actualLocation, breakpointId}} = await Protocol.Debugger.setBreakpoint({location: {
scriptId,
lineNumber: 3,
}}));
await session.logSourceLocation(actualLocation);
await Protocol.Debugger.removeBreakpoint({breakpointId});
await Promise.all([
Protocol.Runtime.disable(),
Protocol.Debugger.disable()
]);
}
]);
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