Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dwds/lib/src/debugging/debugger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class Debugger extends Domain {
// Chrome is 0 based. Account for this.
var jsLocation = JsLocation.fromZeroBased(location['scriptId'] as String,
location['lineNumber'] as int, location['columnNumber'] as int);
var dartFrame = _frameFor(jsLocation);
var dartFrame = await _frameFor(jsLocation);
if (dartFrame != null) {
dartFrame.code.name = functionName.isEmpty ? '<closure>' : functionName;
dartFrame.index = index++;
Expand Down Expand Up @@ -331,7 +331,7 @@ class Debugger extends Domain {
}

/// Returns a Dart [Frame] for a [JsLocation].
Frame _frameFor(JsLocation jsLocation) {
Future<Frame> _frameFor(JsLocation jsLocation) async {
// TODO(sdk/issues/37240) - ideally we look for an exact location instead
// of the closest location on a given line.
Location bestLocation;
Expand All @@ -346,7 +346,7 @@ class Debugger extends Domain {
}
if (bestLocation == null) return null;
var script =
inspector?.scriptRefFor(bestLocation.dartLocation.uri.serverPath);
await inspector?.scriptRefFor(bestLocation.dartLocation.uri.serverPath);
return Frame()
..code = (CodeRef()..kind = CodeKind.kDart)
..location = (SourceLocation()
Expand Down
8 changes: 7 additions & 1 deletion dwds/lib/src/debugging/inspector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,13 @@ function($argsString) {
}

/// Returns the [ScriptRef] for the provided Dart server path [uri].
ScriptRef scriptRefFor(String uri) => _serverPathToScriptRef[uri];
Future<ScriptRef> scriptRefFor(String uri) async {
if (_serverPathToScriptRef.isEmpty) {
// TODO(grouma) - populate the server path cache a better way.
await getScripts(isolate.id);
}
return _serverPathToScriptRef[uri];
}

Future<ScriptList> getScripts(String isolateId) async {
var scripts = await scriptRefs(isolateId);
Expand Down
7 changes: 5 additions & 2 deletions dwds/lib/src/services/chrome_proxy_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:dwds/src/utilities/dart_uri.dart';
import 'package:pedantic/pedantic.dart';
import 'package:pub_semver/pub_semver.dart' as semver;
import 'package:vm_service_lib/vm_service_lib.dart';
Expand Down Expand Up @@ -187,8 +188,10 @@ class ChromeProxyService implements VmServiceInterface {
@override
Future<Breakpoint> addBreakpointWithScriptUri(
String isolateId, String scriptUri, int line,
{int column}) {
throw UnimplementedError();
{int column}) async {
var dartUri = DartUri(scriptUri, uri);
var ref = await _inspector.scriptRefFor(dartUri.serverPath);
return _debugger.addBreakpoint(isolateId, ref.id, line, column: column);
}

@override
Expand Down
16 changes: 10 additions & 6 deletions dwds/test/chrome_proxy_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void main() {
var bp = await service.addBreakpoint(isolate.id, mainScript.id, 23);
// Remove breakpoint so it doesn't impact other tests.
await service.removeBreakpoint(isolate.id, bp.id);
expect(bp.id, '1');
expect(bp.id, isNotNull);
});

test('addBreakpoint on a part file', () async {
Expand All @@ -58,16 +58,20 @@ void main() {
var bp = await service.addBreakpoint(isolate.id, partScript.id, 10);
// Remove breakpoint so it doesn't impact other tests.
await service.removeBreakpoint(isolate.id, bp.id);
expect(bp.id, '2');
expect(bp.id, isNotNull);
});

test('addBreakpointAtEntry', () {
expect(() => service.addBreakpointAtEntry(null, null),
throwsUnimplementedError);
});
test('addBreakpointWithScriptUri', () {
expect(() => service.addBreakpointWithScriptUri(null, null, null),
throwsUnimplementedError);

test('addBreakpointWithScriptUri', () async {
var bp = await service.addBreakpointWithScriptUri(
isolate.id, mainScript.uri, 23);
// Remove breakpoint so it doesn't impact other tests.
await service.removeBreakpoint(isolate.id, bp.id);
expect(bp.id, isNotNull);
});

test('removeBreakpoint null arguments', () {
Expand Down Expand Up @@ -95,7 +99,7 @@ void main() {
.lastWhere((each) => each.uri.contains('main.dart'));
var bp = await service.addBreakpoint(isolate.id, refreshedMain.id, 23);
expect(isolate.breakpoints, [bp]);
expect(bp.id, '4');
expect(bp.id, isNotNull);
await service.removeBreakpoint(isolate.id, bp.id);
expect(isolate.breakpoints, isEmpty);
});
Expand Down
2 changes: 1 addition & 1 deletion dwds/test/fixtures/fakes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class FakeInspector extends Domain implements AppInspector {
@override
Future<InstanceRef> instanceRefFor(RemoteObject remoteObject) => null;
@override
ScriptRef scriptRefFor(String uri) => null;
Future<ScriptRef> scriptRefFor(String uri) => null;
@override
Future<List<ScriptRef>> scriptRefs(String isolateId) => null;
@override
Expand Down