Skip to content

Commit 19e2a2d

Browse files
derekxu16Commit Queue
authored andcommitted
[VM/Debugger] Make Debugger::FindBestFit skip functions with non-real start or end positions
TEST=confirmed that pkg/vm_service/test/regress_60396_test passes with the changes in this CL and fails without them Fixes: #60396 Change-Id: I093fa3abf98b41c47786f0d37987ae771efe072e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420880 Commit-Queue: Derek Xu <[email protected]> Reviewed-by: Ben Konyi <[email protected]>
1 parent 0bb3adb commit 19e2a2d

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

pkg/pkg.status

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ vm_service/test/regress_46419_test: SkipByDesign # Debugger is disabled in AOT m
190190
vm_service/test/regress_46559_test: SkipByDesign # Debugger is disabled in AOT mode.
191191
vm_service/test/regress_48279_test: SkipByDesign # Debugger is disabled in AOT mode.
192192
vm_service/test/regress_55559_test: SkipByDesign # Spawns a child process from source.
193+
vm_service/test/regress_60396_test: SkipByDesign # Debugger is disabled in AOT mode.
193194
vm_service/test/regress_88104_test: SkipByDesign # Debugger is disabled in AOT mode.
194195
vm_service/test/reload_sources_rpc_triggers_isolate_reload_event_test: SkipByDesign # Hot reload is disabled in AOT mode.
195196
vm_service/test/reload_sources_test: SkipByDesign # Hot reload is disabled in AOT mode.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// This is a regression test for https://dartbug.com/60396.
6+
7+
import 'common/service_test_common.dart';
8+
import 'common/test_helper.dart';
9+
10+
// AUTOGENERATED START
11+
//
12+
// Update these constants by running:
13+
//
14+
// dart pkg/vm_service/test/update_line_numbers.dart pkg/vm_service/test/regress_60396_test.dart
15+
//
16+
const LINE_A = 22;
17+
// AUTOGENERATED END
18+
19+
void testeeMain() {
20+
(() {
21+
(() {
22+
return 1 + 2; // LINE_A
23+
})();
24+
})();
25+
}
26+
27+
// We define this enum because the bug that this test is a regression test
28+
// against was that Debugger::FindBestFit would sometimes attempt to resolve
29+
// breakpoints in functions with non-real token positions like [_enumToString].
30+
enum MyEnum { A, B }
31+
32+
final tests = <IsolateTest>[
33+
hasPausedAtStart,
34+
setBreakpointAtLine(LINE_A),
35+
resumeIsolate,
36+
hasStoppedAtBreakpoint,
37+
stoppedAtLine(LINE_A),
38+
resumeIsolate,
39+
hasStoppedAtExit,
40+
];
41+
42+
void main([args = const <String>[]]) => runIsolateTests(
43+
args,
44+
tests,
45+
'regress_60396_test.dart',
46+
testeeConcurrent: testeeMain,
47+
pauseOnStart: true,
48+
pauseOnExit: true,
49+
);

runtime/vm/debugger.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2505,7 +2505,8 @@ bool Debugger::FindBestFit(const Script& script,
25052505
function ^= functions.At(pos);
25062506
ASSERT(!function.IsNull());
25072507
if (IsImplicitFunction(function) || function.is_synthetic() ||
2508-
!function.is_debuggable()) {
2508+
!function.token_pos().IsReal() ||
2509+
!function.end_token_pos().IsReal() || !function.is_debuggable()) {
25092510
// We skip implicit functions and synthetic functions because they
25102511
// do not have user specifiable source locations. We also skip
25112512
// functions marked as undebuggable.

0 commit comments

Comments
 (0)