Commit 21d0de46 authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

[DevTools] better breakpoints with source map

Some source map does not contain entry exactly at the end of the line,
so our frontend fails to find a mapping and ignores current line.

This CL tunes sourcemap to return last mapping in the line if there is
no mapping with offset greater then passed column.

R=dgozman@chromium.org

Bug: chromium:836440
Change-Id: I0da57992ca2c94101084aef2ed21c5b5ba6edc0a
Reviewed-on: https://chromium-review.googlesource.com/1028510
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555626}
parent 9cf9c0c5
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function test() {
TestRunner.addResult('Checks breakpoint in file with dart sourcemap');
await TestRunner.loadModule('sources_test_runner');
await TestRunner.showPanel('sources');
await TestRunner.addScriptTag('resources/breakpoint.js');
let sourceFrame = await new Promise(
resolve =>
SourcesTestRunner.showScriptSource('breakpoint.dart', resolve));
SourcesTestRunner.toggleBreakpoint(sourceFrame, 2, false);
SourcesTestRunner.toggleBreakpoint(sourceFrame, 3, false);
await SourcesTestRunner.waitDebuggerPluginBreakpoints(sourceFrame);
await SourcesTestRunner.waitUntilDebuggerPluginLoaded(sourceFrame);
SourcesTestRunner.dumpDebuggerPluginBreakpoints(sourceFrame);
SourcesTestRunner.completeDebuggerTest();
})();
\ No newline at end of file
void _foo(
String a, List b) {
var val1 = a.codeUnits.length as int;
var val2 = a.runes.last;
var val3 = b.isNotEmpty
? 42
: null;
print(val3);
}
void main() {
_foo("hello", []);
}
define(['dart_sdk'], function(dart_sdk) {
'use strict';
const core = dart_sdk.core;
const dart = dart_sdk.dart;
const dartx = dart_sdk.dartx;
const _root = Object.create(null);
const breakpoint = Object.create(_root);
const $length = dartx.length;
const $codeUnits = dartx.codeUnits;
const $runes = dartx.runes;
const $isNotEmpty = dartx.isNotEmpty;
let StringAndListTovoid = () => (StringAndListTovoid = dart.constFn(dart.fnType(dart.void, [core.String, core.List])))();
let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.fnType(dart.void, [])))();
breakpoint._foo = function(a, b) {
let val1 = a[$codeUnits][$length];
let val2 = a[$runes].last;
let val3 = dart.test(b[$isNotEmpty]) ? 42 : null;
core.print(val3);
};
dart.fn(breakpoint._foo, StringAndListTovoid());
breakpoint.main = function() {
breakpoint._foo("hello", []);
};
dart.fn(breakpoint.main, VoidTovoid());
dart.trackLibraries("breakpoint", {
"breakpoint.dart": breakpoint
}, null);
// Exports:
return {
breakpoint: breakpoint
};
});
//# sourceMappingURL=breakpoint.js.map
{"version":3,"sourceRoot":"","sources":["breakpoint.dart"],"names":[],"mappings":";;;;;;;;;;;;;6BACI,CAAQ,EAAE,CAAM;AAClB,QAAI,OAAO,CAAC,YAAU,SAAO;AAC7B,QAAI,OAAO,CAAC,QAAM,KAAK;AAEvB,QAAI,iBAAO,CAAC,aAAW,IACnB,KACA;AACJ,cAAK,CAAC,IAAI;EACZ;;;AAGE,mBAAI,CAAC,SAAS;EAChB","file":"breakpoint.js"}
\ No newline at end of file
...@@ -340,11 +340,11 @@ SDK.TextSourceMap = class { ...@@ -340,11 +340,11 @@ SDK.TextSourceMap = class {
if (first >= mappings.length || mappings[first].sourceLineNumber !== lineNumber) if (first >= mappings.length || mappings[first].sourceLineNumber !== lineNumber)
return null; return null;
const columnMappings = mappings.slice(first, last); const columnMappings = mappings.slice(first, last);
if (!columnMappings.length)
return null;
const index = const index =
columnMappings.lowerBound(columnNumber, (columnNumber, mapping) => columnNumber - mapping.sourceColumnNumber); columnMappings.lowerBound(columnNumber, (columnNumber, mapping) => columnNumber - mapping.sourceColumnNumber);
if (index >= columnMappings.length) return index >= columnMappings.length ? columnMappings[columnMappings.length - 1] : columnMappings[index];
return null;
return columnMappings[index];
/** /**
* @param {number} lineNumber * @param {number} lineNumber
......
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