mirror of
https://github.com/dart-lang/sdk
synced 2024-09-04 16:03:44 +00:00
Reland "[VM/Debugger] Ignore optimized out variables when building scope in ActivationFrame::BuildParameters"
This is a reland of commit e727f4ecbd
We allow the arguments array in
EvaluateCompiledExpressionHelper to contain
Object::optimized_out().ptr() when we have determined that the receiver
has been optimized out but isn't used by the compiled expression. So, I
have moved the assertion that checks for optimized out arguments from
EvaluateCompiledExpressionHelper to
Instance::EvaluateCompiledExpression.
TEST=vm-linux-debug-x64 tryjob
Original change's description:
> [VM/Debugger] Ignore optimized out variables when building scope in ActivationFrame::BuildParameters
>
> TEST=pkg/vm_service/test/evaluate_optimized_out_variable_test.dart
>
> Issue: https://github.com/dart-lang/sdk/issues/53996
> Change-Id: I5e6f0b2c02455af73c2108e6996039c95d3f1f31
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347940
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Derek Xu <derekx@google.com>
Change-Id: Id6df0b0b3e0d26239068041126b034e9469b87af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347945
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
This commit is contained in:
parent
97edad1568
commit
b3abf245a8
|
@ -0,0 +1,85 @@
|
|||
// Copyright (c) 2024, 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/53996.
|
||||
|
||||
import 'package:test/test.dart';
|
||||
import 'package:vm_service/vm_service.dart';
|
||||
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_A = 27;
|
||||
// AUTOGENERATED END
|
||||
|
||||
bool debug = false;
|
||||
|
||||
bool bar(int i) {
|
||||
if (i == 2) {
|
||||
if (debug) {
|
||||
print('woke up'); // LINE_A
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void foo() {
|
||||
final List<int> data = [1, 2, 3];
|
||||
for (int i in data) {
|
||||
if (bar(i)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void testeeMain() {
|
||||
// Trigger optimization of [foo].
|
||||
for (int i = 0; i < 20; i++) {
|
||||
foo();
|
||||
}
|
||||
debug = true;
|
||||
foo();
|
||||
}
|
||||
|
||||
final tests = <IsolateTest>[
|
||||
hasPausedAtStart,
|
||||
setBreakpointAtLine(LINE_A),
|
||||
resumeIsolate,
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_A),
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
final isolateId = isolateRef.id!;
|
||||
try {
|
||||
await service.evaluateInFrame(
|
||||
isolateId,
|
||||
1,
|
||||
'data.length',
|
||||
);
|
||||
fail('Expected evaluateInFrame to throw an RPCError');
|
||||
} on RPCError catch (e) {
|
||||
expect(e.code, RPCErrorKind.kExpressionCompilationError.code);
|
||||
expect(e.message, 'Expression compilation error');
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'evaluate_optimized_out_variable_test.dart',
|
||||
testeeConcurrent: testeeMain,
|
||||
pauseOnStart: true,
|
||||
extraArgs: const [
|
||||
'--deterministic',
|
||||
'--prune-dead-locals',
|
||||
'--optimization-counter-threshold=10',
|
||||
],
|
||||
);
|
|
@ -1111,7 +1111,8 @@ TypeArgumentsPtr ActivationFrame::BuildParameters(
|
|||
type_arguments_available = true;
|
||||
type_arguments ^= value.ptr();
|
||||
} else if (!name.Equals(Symbols::This()) &&
|
||||
!IsSyntheticVariableName(name)) {
|
||||
!IsSyntheticVariableName(name) &&
|
||||
value.ptr() != Object::optimized_out().ptr()) {
|
||||
if (IsPrivateVariableName(name)) {
|
||||
name = Symbols::New(Thread::Current(), String::ScrubName(name));
|
||||
}
|
||||
|
|
|
@ -4945,6 +4945,12 @@ ObjectPtr Instance::EvaluateCompiledExpression(
|
|||
|
||||
const auto& eval_function = Function::Cast(result);
|
||||
|
||||
#if defined(DEBUG)
|
||||
for (intptr_t i = 0; i < arguments.Length(); ++i) {
|
||||
ASSERT(arguments.At(i) != Object::optimized_out().ptr());
|
||||
}
|
||||
#endif // defined(DEBUG)
|
||||
|
||||
auto& all_arguments = Array::Handle(zone, arguments.ptr());
|
||||
if (!eval_function.is_static()) {
|
||||
// `this` may be optimized out (e.g. not accessible from breakpoint due to
|
||||
|
|
Loading…
Reference in a new issue