Skip to content

Commit 63894bb

Browse files
authored
Added support for some debugging APIs with the DDC library bundle format (#2564)
* Added support for getClassMetadata with the DDc library bundle format * Added support for some debugging APIs with the DDC library bundle format. * Update pattern test to account for new DDC JS variable naming * reverting change to pattern test * Added support for debugging API with the DDC library bundle format. * updated licenses * updated licenses and remove new line from changelog * Added support for some debugging APIs with the DDC library bundle format - getRecordTypeFieldsJsExpression, callInstanceMethodJsExpression * Added support for some debugging APIs with the DDC library bundle format * updated CHANGELOG * refactored test to use common file * delete main_ddc_library_bundle.dart * fixed broken test - decoded response body to match source and renamed stack property * updated changelog * updated dart_scope to not renamed wildcard and skipped related test case * formatted test/common/chrome_proxy_service_common.dart * replaced wildcard with timer * updated call to DartUri and removed unecessary check * updated DCM version * updated DCM version to 1.26.0-1
1 parent 4a92ba5 commit 63894bb

File tree

9 files changed

+250
-125
lines changed

9 files changed

+250
-125
lines changed

.github/workflows/dcm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
wget -qO- https://dcm.dev/pgp-key.public | sudo gpg --dearmor -o /usr/share/keyrings/dcm.gpg
2020
echo 'deb [signed-by=/usr/share/keyrings/dcm.gpg arch=amd64] https://dcm.dev/debian stable main' | sudo tee /etc/apt/sources.list.d/dart_stable.list
2121
sudo apt-get update
22-
sudo apt-get install dcm=1.16.2-1 # To avoid errors add `-1` (build number) to the version
22+
sudo apt-get install dcm=1.26.0-1 # To avoid errors add `-1` (build number) to the version
2323
sudo chmod +x /usr/bin/dcm
2424
- name: Setup Dart SDK
2525
uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94

dwds/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
## 24.3.3-wip
2+
- Added support for some debugging APIs with the DDC library bundle format. - [#2563](https://github.com/dart-lang/webdev/issues/2563)
3+
- Update `DCM` version to `1.26.0-1`
24

35
## 24.3.2
46

dwds/lib/src/debugging/dart_runtime_debugger.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ class DartRuntimeDebugger {
1818
String _generateJsExpression(
1919
String ddcExpression,
2020
String libraryBundleExpression,
21-
) {
22-
return _useLibraryBundleExpression
23-
? libraryBundleExpression
24-
: ddcExpression;
25-
}
21+
) =>
22+
_useLibraryBundleExpression ? libraryBundleExpression : ddcExpression;
2623

2724
/// Wraps a JS function call with SDK loader logic.
2825
String _wrapWithSdkLoader(String args, String functionCall) {
@@ -199,4 +196,11 @@ class DartRuntimeDebugger {
199196
),
200197
);
201198
}
199+
200+
String invokeExtensionJsExpression(String methodName, String encodedJson) {
201+
return _generateJsExpression(
202+
"${_loadStrategy.loadModuleSnippet}('dart_sdk').developer.invokeExtension('$methodName', JSON.stringify($encodedJson));",
203+
"dartDevEmbedder.debugger.invokeExtension('$methodName', JSON.stringify($encodedJson));",
204+
);
205+
}
202206
}

dwds/lib/src/services/chrome_proxy_service.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,8 @@ class ChromeProxyService implements VmServiceInterface {
518518
v is String ? v : jsonEncode(v),
519519
),
520520
);
521-
final expression = '''
522-
${globalToolConfiguration.loadStrategy.loadModuleSnippet}("dart_sdk").developer.invokeExtension(
523-
"$method", JSON.stringify(${jsonEncode(stringArgs)}));
524-
''';
521+
final expression = globalToolConfiguration.loadStrategy.dartRuntimeDebugger
522+
.invokeExtensionJsExpression(method, jsonEncode(stringArgs));
525523
final result = await inspector.jsEvaluate(expression, awaitPromise: true);
526524
final decodedResponse =
527525
jsonDecode(result.value as String) as Map<String, dynamic>;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
@TestOn('vm')
6+
@Tags(['daily'])
7+
@Timeout(Duration(minutes: 2))
8+
library;
9+
10+
import 'package:dwds/expression_compiler.dart';
11+
import 'package:test/test.dart';
12+
import 'package:test_common/test_sdk_configuration.dart';
13+
14+
import 'common/chrome_proxy_service_common.dart';
15+
import 'fixtures/context.dart';
16+
17+
void main() {
18+
// Enable verbose logging for debugging.
19+
final debug = false;
20+
final canaryFeatures = false;
21+
final moduleFormat = ModuleFormat.amd;
22+
final compilationMode = CompilationMode.buildDaemon;
23+
24+
group('canary: $canaryFeatures |', () {
25+
final provider = TestSdkConfigurationProvider(
26+
verbose: debug,
27+
canaryFeatures: canaryFeatures,
28+
ddcModuleFormat: moduleFormat,
29+
);
30+
tearDownAll(provider.dispose);
31+
32+
runTests(
33+
provider: provider,
34+
moduleFormat: moduleFormat,
35+
compilationMode: compilationMode,
36+
canaryFeatures: canaryFeatures,
37+
debug: debug,
38+
);
39+
});
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
@TestOn('vm')
6+
@Tags(['daily'])
7+
@Timeout(Duration(minutes: 2))
8+
library;
9+
10+
import 'package:dwds/expression_compiler.dart';
11+
import 'package:test/test.dart';
12+
import 'package:test_common/test_sdk_configuration.dart';
13+
14+
import 'common/chrome_proxy_service_common.dart';
15+
import 'fixtures/context.dart';
16+
17+
void main() {
18+
// Enable verbose logging for debugging.
19+
final debug = false;
20+
final canaryFeatures = true;
21+
final moduleFormat = ModuleFormat.ddc;
22+
final compilationMode = CompilationMode.frontendServer;
23+
24+
group('canary: $canaryFeatures |', () {
25+
final provider = TestSdkConfigurationProvider(
26+
verbose: debug,
27+
canaryFeatures: canaryFeatures,
28+
ddcModuleFormat: moduleFormat,
29+
);
30+
tearDownAll(provider.dispose);
31+
32+
runTests(
33+
provider: provider,
34+
moduleFormat: moduleFormat,
35+
compilationMode: compilationMode,
36+
canaryFeatures: canaryFeatures,
37+
debug: debug,
38+
);
39+
});
40+
}

0 commit comments

Comments
 (0)