[inspector] Fix calculation of breakpoint hint offset

Bug: chromium:1406169
Bug: chromium:1404643
Change-Id: I03fa130e64cd84f1559c123ca77eb740e424cc70
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4152475
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Jaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85195}
This commit is contained in:
Jaroslav Sevcik 2023-01-10 16:30:54 +01:00 committed by V8 LUCI CQ
parent 3cea5d5425
commit b5c727768e
3 changed files with 28 additions and 10 deletions

View File

@ -262,8 +262,8 @@ void adjustBreakpointLocation(const V8DebuggerScript& script,
offset + prefixLength + hint.length() <= searchArea.length() &&
searchArea.substring(offset + prefixLength, hint.length()) == hint &&
computeCrc32(searchArea.substring(offset, prefixLength)) == prefixHash) {
v8::debug::Location hintPosition =
script.location(static_cast<int>(offset + prefixLength));
v8::debug::Location hintPosition = script.location(
static_cast<int>(searchRegionOffset + offset + prefixLength));
*lineNumber = hintPosition.GetLineNumber();
*columnNumber = hintPosition.GetColumnNumber();
return;

View File

@ -32,6 +32,18 @@ boo();
#boo();
}
Running test: testSameSourceLongCommentBefore
/////////////////////////////////////////////////////////////////////////////...
function foo() {
bad();
#boo();
}
/////////////////////////////////////////////////////////////////////////////...
function foo() {
bad();
#boo();
}
Running test: testSameSourceDuplicateLinesDifferentPrefix
function foo() {
boo();

View File

@ -9,48 +9,54 @@ var finishedTests = 0;
InspectorTest.runTestSuite([
function testSameSource(next) {
var source = 'function foo() {\nboo();\n}';
test(source, source, { lineNumber: 1, columnNumber: 0 }, next);
test(source, source, {lineNumber: 1, columnNumber: 0}, next);
},
function testSameSourceDuplicateLines(next) {
var source = 'function foo() {\nboo();\n// something\nboo();\n}';
test(source, source, { lineNumber: 2, columnNumber: 0 }, next);
test(source, source, {lineNumber: 2, columnNumber: 0}, next);
},
function testSameSourceDuplicateLinesLongLineBetween(next) {
var longComment = '/'.repeat(1e4);
var source = `function foo() {\nboo();\n${longComment}\nboo();\n}`;
test(source, source, { lineNumber: 2, columnNumber: 0 }, next);
test(source, source, {lineNumber: 2, columnNumber: 0}, next);
},
function testSameSourceLongCommentBefore(next) {
var longComment = '/'.repeat(1e3);
var source = `${longComment}\nfunction foo() {\nbad();\nboo();\n}`;
test(source, source, {lineNumber: 3, columnNumber: 0}, next);
},
function testSameSourceDuplicateLinesDifferentPrefix(next) {
var source = 'function foo() {\nboo();\n// something\nboo();\n}';
var newSource = 'function foo() {\nboo();\n// somethinX\nboo();\n}';
test(source, newSource, { lineNumber: 2, columnNumber: 0 }, next);
test(source, newSource, {lineNumber: 2, columnNumber: 0}, next);
},
function testOneLineOffset(next) {
var source = 'function foo() {\nboo();\n}';
var newSource = 'function foo() {\nboo();\nboo();\n}';
test(source, newSource, { lineNumber: 1, columnNumber: 0 }, next);
test(source, newSource, {lineNumber: 1, columnNumber: 0}, next);
},
function testTwoSimilarLinesCloseToOriginalLocation1(next) {
var source = 'function foo() {\n\n\nboo();\n}';
var newSource = 'function foo() {\nboo();\n\nnewCode();\nboo();\n\n\n\nboo();\n}';
test(source, newSource, { lineNumber: 3, columnNumber: 0 }, next);
test(source, newSource, {lineNumber: 3, columnNumber: 0}, next);
},
function testTwoSimilarLinesCloseToOriginalLocation2(next) {
var source = 'function foo() {\n\n\nboo();\n}';
var newSource = 'function foo() {\nboo();\nnewLongCode();\nnewCode();\nboo();\n\n\n\nboo();\n}';
test(source, newSource, { lineNumber: 3, columnNumber: 0 }, next);
test(source, newSource, {lineNumber: 3, columnNumber: 0}, next);
},
function testHintIgnoreWhiteSpaces(next) {
var source = 'function foo() {\n\n\n\nboo();\n}';
var newSource = 'function foo() {\nfoo();\n\n\nboo();\n}';
test(source, newSource, { lineNumber: 1, columnNumber: 0 }, next);
test(source, newSource, {lineNumber: 1, columnNumber: 0}, next);
},
function testCheckOnlyLimitedOffsets(next) {