@@ -228,8 +228,9 @@ class Debugger extends Domain {
228228 int line, {
229229 int column,
230230 }) async {
231+ column ?? = 0 ;
231232 checkIsolate ('addBreakpoint' , isolateId);
232- final breakpoint = await _breakpoints.add (scriptId, line);
233+ final breakpoint = await _breakpoints.add (scriptId, line, column );
233234 _notifyBreakpoint (breakpoint);
234235 return breakpoint;
235236 }
@@ -249,7 +250,9 @@ class Debugger extends Domain {
249250 for (var breakpoint in previousBreakpoints) {
250251 var scriptRef = await _updatedScriptRefFor (breakpoint);
251252 var updatedLocation = await _locations.locationForDart (
252- DartUri (scriptRef.uri, _root), _lineNumberFor (breakpoint));
253+ DartUri (scriptRef.uri, _root),
254+ _lineNumberFor (breakpoint),
255+ _columnNumberFor (breakpoint));
253256 var updatedBreakpoint = _breakpoints._dartBreakpoint (
254257 scriptRef, updatedLocation, breakpoint.id);
255258 _breakpoints._note (
@@ -263,7 +266,8 @@ class Debugger extends Domain {
263266 await addBreakpoint (
264267 inspector.isolate.id,
265268 (await _updatedScriptRefFor (breakpoint)).id,
266- _lineNumberFor (breakpoint));
269+ _lineNumberFor (breakpoint),
270+ column: _columnNumberFor (breakpoint));
267271 }
268272 }
269273
@@ -324,10 +328,11 @@ class Debugger extends Domain {
324328 var frame = e.params['callFrames' ][0 ];
325329 var location = frame['location' ];
326330 var scriptId = location['scriptId' ] as String ;
327- var lineNumber = location['lineNumber' ] as int ;
331+ var line = location['lineNumber' ] as int ;
332+ var column = location['columnNumber' ] as int ;
328333
329334 var url = _urlForScriptId (scriptId);
330- return _locations.locationForJs (url, lineNumber + 1 );
335+ return _locations.locationForJs (url, line, column );
331336 }
332337
333338 /// The variables visible in a frame in Dart protocol [BoundVariable] form.
@@ -459,9 +464,8 @@ class Debugger extends Domain {
459464 bool populateVariables = true ,
460465 }) async {
461466 var location = frame.location;
462- // Chrome is 0 based. Account for this.
463- var line = location.lineNumber + 1 ;
464- var column = location.columnNumber + 1 ;
467+ var line = location.lineNumber;
468+ var column = location.columnNumber;
465469
466470 var url = _urlForScriptId (location.scriptId);
467471 if (url == null ) {
@@ -723,14 +727,20 @@ bool isNativeJsObject(InstanceRef instanceRef) {
723727
724728/// Returns the Dart line number for the provided breakpoint.
725729int _lineNumberFor (Breakpoint breakpoint) =>
726- int .parse (breakpoint.id.split ('#' ).last);
730+ int .parse (breakpoint.id.split ('#' ).last.split (':' ).first);
731+
732+ /// Returns the Dart column number for the provided breakpoint.
733+ int _columnNumberFor (Breakpoint breakpoint) =>
734+ int .parse (breakpoint.id.split ('#' ).last.split (':' ).last);
727735
728736/// Returns the breakpoint ID for the provided Dart script ID and Dart line
729737/// number.
730- String breakpointIdFor (String scriptId, int line) => 'bp/$scriptId #$line ' ;
738+ String breakpointIdFor (String scriptId, int line, int column) =>
739+ 'bp/$scriptId #$line :$column ' ;
731740
732741/// Keeps track of the Dart and JS breakpoint Ids that correspond.
733742class _Breakpoints extends Domain {
743+ final logger = Logger ('Breakpoints' );
734744 final _dartIdByJsId = < String , String > {};
735745 final _jsIdByDartId = < String , String > {};
736746
@@ -752,13 +762,16 @@ class _Breakpoints extends Domain {
752762 }) : super (provider);
753763
754764 Future <Breakpoint > _createBreakpoint (
755- String id, String scriptId, int line) async {
765+ String id, String scriptId, int line, int column ) async {
756766 var dartScript = inspector.scriptWithId (scriptId);
757767 var dartUri = DartUri (dartScript.uri, root);
758- var location = await locations.locationForDart (dartUri, line);
759-
768+ var location = await locations.locationForDart (dartUri, line, column);
760769 // TODO: Handle cases where a breakpoint can't be set exactly at that line.
761770 if (location == null ) {
771+ logger
772+ .fine ('Failed to set breakpoint at ${dartScript .uri }:$line :$column : '
773+ 'Dart location not found for scriptId: $scriptId , '
774+ 'server path: ${dartUri .serverPath }, root:$root ' );
762775 throw RPCError (
763776 'addBreakpoint' ,
764777 102 ,
@@ -779,10 +792,10 @@ class _Breakpoints extends Domain {
779792
780793 /// Adds a breakpoint at [scriptId] and [line] or returns an existing one if
781794 /// present.
782- Future <Breakpoint > add (String scriptId, int line) async {
783- final id = breakpointIdFor (scriptId, line);
795+ Future <Breakpoint > add (String scriptId, int line, int column ) async {
796+ final id = breakpointIdFor (scriptId, line, column );
784797 return _bpByDartId.putIfAbsent (
785- id, () => _createBreakpoint (id, scriptId, line));
798+ id, () => _createBreakpoint (id, scriptId, line, column ));
786799 }
787800
788801 /// Create a Dart breakpoint at [location] in [dartScript] with [id] .
@@ -792,17 +805,19 @@ class _Breakpoints extends Domain {
792805 id: id,
793806 breakpointNumber: int .parse (createId ()),
794807 resolved: true ,
795- location: SourceLocation (script: dartScript, tokenPos: location.tokenPos),
808+ location: SourceLocation (
809+ script: dartScript,
810+ tokenPos: location.tokenPos,
811+ line: location.dartLocation.line,
812+ column: location.dartLocation.column,
813+ ),
796814 enabled: true ,
797815 )..id = id;
798816 return breakpoint;
799817 }
800818
801819 /// Calls the Chrome protocol setBreakpoint and returns the remote ID.
802820 Future <String > _setJsBreakpoint (Location location) async {
803- // Location is 0 based according to:
804- // https://chromedevtools.github.io/devtools-protocol/tot/Debugger#type-Location
805-
806821 // The module can be loaded from a nested path and contain an ETAG suffix.
807822 var urlRegex = '.*${location .jsLocation .module }.*' ;
808823 // Prevent `Aww, snap!` errors when setting multiple breakpoints
@@ -811,7 +826,8 @@ class _Breakpoints extends Domain {
811826 var response = await remoteDebugger
812827 .sendCommand ('Debugger.setBreakpointByUrl' , params: {
813828 'urlRegex' : urlRegex,
814- 'lineNumber' : location.jsLocation.line - 1 ,
829+ 'lineNumber' : location.jsLocation.line,
830+ 'columnNumber' : location.jsLocation.column,
815831 });
816832 return response.result['breakpointId' ] as String ;
817833 });
0 commit comments