@@ -307,15 +307,22 @@ class Debugger extends Domain {
307307 }
308308 }
309309
310+ /// Returns Chrome script uri for Chrome script ID.
311+ String _urlForScriptId (String scriptId) =>
312+ _remoteDebugger.scripts[scriptId]? .url;
313+
310314 /// Returns source [Location] for the paused event.
311315 ///
312316 /// If we do not have [Location] data for the embedded JS location, null is
313317 /// returned.
314318 Future <Location > _sourceLocation (DebuggerPausedEvent e) {
315319 var frame = e.params['callFrames' ][0 ];
316320 var location = frame['location' ];
317- return _locations.locationForJs (
318- frame['url' ] as String , (location['lineNumber' ] as int ) + 1 );
321+ var scriptId = location['scriptId' ] as String ;
322+ var lineNumber = location['lineNumber' ] as int ;
323+
324+ var url = _urlForScriptId (scriptId);
325+ return _locations.locationForJs (url, lineNumber + 1 );
319326 }
320327
321328 /// The variables visible in a frame in Dart protocol [BoundVariable] form.
@@ -427,10 +434,17 @@ class Debugger extends Domain {
427434 // Chrome is 0 based. Account for this.
428435 var line = location.lineNumber + 1 ;
429436 var column = location.columnNumber + 1 ;
437+
438+ var url = _urlForScriptId (location.scriptId);
439+ if (url == null ) {
440+ logger.severe ('Failed to create dart frame for ${frame .functionName }: '
441+ 'cannot find location for script ${location .scriptId }' );
442+ }
443+
430444 // TODO(sdk/issues/37240) - ideally we look for an exact location instead
431445 // of the closest location on a given line.
432446 Location bestLocation;
433- for (var location in await _locations.locationsForUrl (frame. url)) {
447+ for (var location in await _locations.locationsForUrl (url)) {
434448 if (location.jsLocation.line == line) {
435449 bestLocation ?? = location;
436450 if ((location.jsLocation.column - column).abs () <
@@ -530,8 +544,14 @@ class Debugger extends Domain {
530544 // If we don't have source location continue stepping.
531545 if (_isStepping && (await _sourceLocation (e)) == null ) {
532546 var frame = e.params['callFrames' ][0 ];
533- var url = '${frame ["url" ]}' ;
534547 var scriptId = '${frame ["location" ]["scriptId" ]}' ;
548+
549+ var url = _urlForScriptId (scriptId);
550+ if (url == null ) {
551+ logger.severe ('Stepping failed: '
552+ 'cannot find location for script $scriptId ' );
553+ }
554+
535555 // TODO(grouma) - In the future we should send all previously computed
536556 // skipLists.
537557 await _remoteDebugger.stepInto (params: {
0 commit comments