-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[stable] [VM/Debugger] Fix behaviour of ActivationFrame::EvaluateComp…
…iledExpression when paused inside a closure TEST=pkg/vm_service/test/evaluate_inside_closures_test.dart, pkg tryjob Fixes: #52430 Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/313001 Cherry-pick-request: #53747 Change-Id: Ib3479a0b39377ea20765752fd91fef26e8f46454 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330248 Reviewed-by: Derek Xu <derekx@google.com> Commit-Queue: Kevin Chisholm <kevinjchisholm@google.com> Reviewed-by: Ben Konyi <bkonyi@google.com>
- Loading branch information
Showing
3 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
// Regression test for https://dartbug.com/52430. | ||
|
||
import 'dart:developer'; | ||
|
||
import 'package:test/test.dart'; | ||
import 'package:vm_service/vm_service.dart'; | ||
|
||
import 'common/service_test_common.dart'; | ||
import 'common/test_helper.dart'; | ||
|
||
class C { | ||
static int staticField = 12; | ||
int instanceField = 34; | ||
|
||
static void staticMethod() { | ||
((int x) { | ||
debugger(); | ||
})(56); | ||
} | ||
|
||
void instanceMethod() { | ||
((int y) { | ||
debugger(); | ||
})(78); | ||
} | ||
} | ||
|
||
testMain() { | ||
C c = C(); | ||
C.staticMethod(); | ||
c.instanceMethod(); | ||
} | ||
|
||
final tests = <IsolateTest>[ | ||
hasStoppedAtBreakpoint, | ||
stoppedAtLine(21), | ||
(VmService service, IsolateRef isolateRef) async { | ||
final isolateId = isolateRef.id!; | ||
|
||
final xRef = | ||
await service.evaluateInFrame(isolateId, 0, 'x') as InstanceRef; | ||
expect(xRef.valueAsString, '56'); | ||
|
||
InstanceRef staticFieldRef = await service.evaluateInFrame( | ||
isolateId, 0, 'staticField += 1') as InstanceRef; | ||
expect(staticFieldRef.valueAsString, '13'); | ||
staticFieldRef = await service.evaluateInFrame(isolateId, 0, 'staticField') | ||
as InstanceRef; | ||
expect(staticFieldRef.valueAsString, '13'); | ||
|
||
// Evaluating 'instanceField' should fail since we are paused in the context | ||
// of a static method. | ||
try { | ||
await service.evaluateInFrame(isolateId, 0, 'instanceField'); | ||
fail('Expected RPCError'); | ||
} catch (e) { | ||
final rpcError = e as RPCError; | ||
expect(rpcError.code, RPCErrorKind.kExpressionCompilationError.code); | ||
} | ||
}, | ||
resumeIsolate, | ||
stoppedAtLine(27), | ||
(VmService service, IsolateRef isolateRef) async { | ||
final isolateId = isolateRef.id!; | ||
|
||
final yRef = | ||
await service.evaluateInFrame(isolateId, 0, 'y') as InstanceRef; | ||
expect(yRef.valueAsString, '78'); | ||
|
||
InstanceRef staticFieldRef = await service.evaluateInFrame( | ||
isolateId, 0, 'staticField += 1') as InstanceRef; | ||
expect(staticFieldRef.valueAsString, '14'); | ||
staticFieldRef = await service.evaluateInFrame(isolateId, 0, 'staticField') | ||
as InstanceRef; | ||
expect(staticFieldRef.valueAsString, '14'); | ||
|
||
InstanceRef instanceFieldRef = await service.evaluateInFrame( | ||
isolateId, 0, 'instanceField += 1') as InstanceRef; | ||
expect(instanceFieldRef.valueAsString, '35'); | ||
instanceFieldRef = await service.evaluateInFrame( | ||
isolateId, 0, 'instanceField') as InstanceRef; | ||
expect(instanceFieldRef.valueAsString, '35'); | ||
} | ||
]; | ||
|
||
main([args = const <String>[]]) async => | ||
runIsolateTests(args, tests, 'evaluate_inside_closures_test.dart', | ||
testeeConcurrent: testMain); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters