Skip to content

Commit 57ba99c

Browse files
DanTupCommit Queue
authored and
Commit Queue
committed
[dds/dap] Handle sentinel values in Scopes and Variables requests
Fixes #51916. Change-Id: I72f02c640084059af5e2b761554ee6ec706f5f6a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292540 Commit-Queue: Ben Konyi <[email protected]> Reviewed-by: Ben Konyi <[email protected]>
1 parent 51cbaed commit 57ba99c

File tree

5 files changed

+53
-4
lines changed

5 files changed

+53
-4
lines changed

pkg/dds/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 2.7.8
2+
- [DAP] Sentinel values (such as uninitialized fields/locals) will no longer cause `scopesRequest`/`variablesRequest` to fail, instead showing appropriate text (like "<not initialized>") against the variable.
3+
14
# 2.7.7
25
- [DAP] Debug adapters now only call `setLibraryDebuggable` when the debuggable flag changes from the default/current values, reducing the amount of VM Service traffic for new isolates/reloads.
36
- [DAP] `breakpoint` events are no longer sometimes sent prior to the response to the `setBreakpointsRequest` that created them.

pkg/dds/lib/src/dap/adapters/dart.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,10 @@ abstract class DartDebugAdapter<TL extends LaunchRequestArguments,
17491749
Future<Variable> convert(int index, vm.BoundVariable variable) {
17501750
// Store the expression that gets this object as we may need it to
17511751
// compute evaluateNames for child objects later.
1752-
storeEvaluateName(variable.value, variable.name);
1752+
final value = variable.value;
1753+
if (value is vm.InstanceRef) {
1754+
storeEvaluateName(value, variable.name);
1755+
}
17531756
return _converter.convertVmResponseToVariable(
17541757
thread,
17551758
variable.value,

pkg/dds/lib/src/dap/protocol_converter.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,9 @@ class ProtocolConverter {
239239
final fieldEvaluateName = name != null
240240
? _adapter.combineEvaluateName(evaluateName, '.$name')
241241
: null;
242-
if (fieldEvaluateName != null) {
243-
_adapter.storeEvaluateName(field.value, fieldEvaluateName);
242+
final value = field.value;
243+
if (fieldEvaluateName != null && value is vm.InstanceRef) {
244+
_adapter.storeEvaluateName(value, fieldEvaluateName);
244245
}
245246
return convertVmResponseToVariable(
246247
thread,

pkg/dds/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: dds
2-
version: 2.7.7
2+
version: 2.7.8
33
description: >-
44
A library used to spawn the Dart Developer Service, used to communicate with
55
a Dart VM Service instance.

pkg/dds/test/dap/integration/debug_variables_test.dart

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,48 @@ void main() {
710710
);
711711
});
712712

713+
test('handles sentinel fields', () async {
714+
final client = dap.client;
715+
final testFile = dap.createTestFile('''
716+
class Foo {
717+
late String foo;
718+
}
719+
720+
void main() {
721+
final myVariable = Foo();
722+
print('Hello!'); $breakpointMarker
723+
}
724+
''');
725+
726+
final breakpointLine = lineWith(testFile, breakpointMarker);
727+
final stop = await client.hitBreakpoint(testFile, breakpointLine);
728+
729+
await client.expectLocalVariable(
730+
stop.threadId!,
731+
expectedName: 'myVariable',
732+
expectedDisplayString: 'Foo',
733+
expectedVariables: 'foo: <not initialized>',
734+
);
735+
});
736+
737+
test('handles sentinel locals', () async {
738+
final client = dap.client;
739+
final testFile = dap.createTestFile('''
740+
void main() {
741+
late String foo;
742+
print('Hello!'); $breakpointMarker
743+
}
744+
''');
745+
final breakpointLine = lineWith(testFile, breakpointMarker);
746+
final stop = await client.hitBreakpoint(testFile, breakpointLine);
747+
748+
await client.expectScopeVariables(
749+
stop.threadId!,
750+
'Locals',
751+
'foo: <not initialized>',
752+
);
753+
});
754+
713755
group('inspect()', () {
714756
/// Helper to test `inspect()` with varying expressions.
715757
void checkInspect(

0 commit comments

Comments
 (0)