From 57ea8854965d801a26bca48f68ae85b5141b74bc Mon Sep 17 00:00:00 2001 From: Tess Strickland Date: Tue, 2 Dec 2025 06:52:59 -0800 Subject: [PATCH] [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 Commit-Queue: Tess Strickland --- .../test/evaluate_optimized_out_variable_test.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/vm_service/test/evaluate_optimized_out_variable_test.dart b/pkg/vm_service/test/evaluate_optimized_out_variable_test.dart index 0f96c061267..b3df49e4bbe 100644 --- a/pkg/vm_service/test/evaluate_optimized_out_variable_test.dart +++ b/pkg/vm_service/test/evaluate_optimized_out_variable_test.dart @@ -58,12 +58,14 @@ final tests = [ (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');