Files
sdk/pkg/vm_service/test/get_stack_rpc_test.dart
Slava Egorov 53ac68e2dd [vm_service] Deprecate Stack.messages
Make VM always return empty array in the response.

Current implementation for this field comes with a bunch of complexity
because it locks message handler and then invokes Dart code which
makes it difficult to reason about various invariants. This code is 
furthermore demonstrated to cause deadlocks. Given that nobody uses 
it - it is simpler to remove this code altogether.

Fixes https://github.com/flutter/flutter/issues/185156

TEST=ci

Change-Id: I497210e0f1542860caa0d765d634f8ec6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496340
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-04-20 10:28:01 -07:00

69 lines
1.7 KiB
Dart

// 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.
import 'dart:async';
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';
const LINE_A = 22;
int counter = 0;
// This name is used in a test below.
void msgHandler(_) {}
void periodicTask(_) {
debugger(message: 'fo', when: true);
counter++;
if (counter % 300 == 0) {
print('counter = $counter');
}
}
void startTimer() {
Timer.periodic(const Duration(milliseconds: 10), periodicTask);
}
final tests = <IsolateTest>[
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_A),
// Get stack
(VmService service, IsolateRef isolateRef) async {
final isolateId = isolateRef.id!;
final stack = await service.getStack(isolateId);
// Sanity check.
final frames = stack.frames!;
expect(frames.length, greaterThanOrEqualTo(1));
final scriptId = frames[0].location!.script!.id!;
final script = await service.getObject(isolateId, scriptId) as Script;
expect(
script.getLineNumberFromTokenPos(frames[0].location!.tokenPos!),
LINE_A,
);
// Iterate over frames.
int frameDepth = 0;
for (var frame in frames) {
print('checking frame $frameDepth');
expect(frame.index, equals(frameDepth++));
expect(frame.code, isNotNull);
expect(frame.function, isNotNull);
expect(frame.location, isNotNull);
}
},
];
void main([args = const <String>[]]) => runIsolateTests(
args,
tests,
'get_stack_rpc_test.dart',
testeeBefore: startTimer,
);