[pkg/vm_service] Handle lack of optimized out variables in interpreter.

Test the evaluation of the variable as normal when interpreted, and
expect the appropriate RPCError when not interpreted.

TEST=pkg/vm_service/test/evaluate_optimized_out_variable_test

Cq-Include-Trybots: luci.dart.try:vm-linux-release-x64-try,vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: I964b75fcfbd789aa7ee5b02c325d028a1a9394f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464441
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
This commit is contained in:
Tess Strickland
2025-12-02 06:52:59 -08:00
committed by Commit Queue
parent 140b901f1c
commit 57ea885496
@@ -58,12 +58,14 @@ final tests = <IsolateTest>[
(VmService service, IsolateRef isolateRef) async {
final isolateId = isolateRef.id!;
try {
await service.evaluateInFrame(
final dynamic result = await service.evaluateInFrame(
isolateId,
1,
'data.length',
);
fail('Expected evaluateInFrame to throw an RPCError');
// Check in case the variable isn't optimized out, e.g., if the code is
// interpreted via bytecode instead of compiled to native code.
expect(result.valueAsString, '3');
} on RPCError catch (e) {
expect(e.code, RPCErrorKind.kExpressionCompilationError.code);
expect(e.message, 'Expression compilation error');