@@ -309,15 +309,22 @@ class Debugger extends Domain {
309309 }
310310 }
311311
312+ /// Returns Chrome script uri for Chrome script ID.
313+ String _urlForScriptId (String scriptId) =>
314+ _remoteDebugger.scripts[scriptId]? .url;
315+
312316 /// Returns source [Location] for the paused event.
313317 ///
314318 /// If we do not have [Location] data for the embedded JS location, null is
315319 /// returned.
316320 Future <Location > _sourceLocation (DebuggerPausedEvent e) {
317321 var frame = e.params['callFrames' ][0 ];
318322 var location = frame['location' ];
319- return _locations.locationForJs (
320- frame['url' ] as String , (location['lineNumber' ] as int ) + 1 );
323+ var scriptId = location['scriptId' ] as String ;
324+ var lineNumber = location['lineNumber' ] as int ;
325+
326+ var url = _urlForScriptId (scriptId);
327+ return _locations.locationForJs (url, lineNumber + 1 );
321328 }
322329
323330 /// The variables visible in a frame in Dart protocol [BoundVariable] form.
@@ -448,10 +455,17 @@ class Debugger extends Domain {
448455 // Chrome is 0 based. Account for this.
449456 var line = location.lineNumber + 1 ;
450457 var column = location.columnNumber + 1 ;
458+
459+ var url = _urlForScriptId (location.scriptId);
460+ if (url == null ) {
461+ logger.severe ('Failed to create dart frame for ${frame .functionName }: '
462+ 'cannot find location for script ${location .scriptId }' );
463+ }
464+
451465 // TODO(sdk/issues/37240) - ideally we look for an exact location instead
452466 // of the closest location on a given line.
453467 Location bestLocation;
454- for (var location in await _locations.locationsForUrl (frame. url)) {
468+ for (var location in await _locations.locationsForUrl (url)) {
455469 if (location.jsLocation.line == line) {
456470 bestLocation ?? = location;
457471 if ((location.jsLocation.column - column).abs () <
@@ -551,8 +565,14 @@ class Debugger extends Domain {
551565 // If we don't have source location continue stepping.
552566 if (_isStepping && (await _sourceLocation (e)) == null ) {
553567 var frame = e.params['callFrames' ][0 ];
554- var url = '${frame ["url" ]}' ;
555568 var scriptId = '${frame ["location" ]["scriptId" ]}' ;
569+
570+ var url = _urlForScriptId (scriptId);
571+ if (url == null ) {
572+ logger.severe ('Stepping failed: '
573+ 'cannot find location for script $scriptId ' );
574+ }
575+
556576 // TODO(grouma) - In the future we should send all previously computed
557577 // skipLists.
558578 await _remoteDebugger.stepInto (params: {
0 commit comments