Skip to content

Commit c2f0140

Browse files
zichanggcommit-bot@chromium.org
authored andcommitted
[vm/debugger] Ensure TopLevel class is finalized when setting breakpoint
Following the revert #98360, make sure the finalizing happens only in debugger. Create the test cases to demonstrate the behavior. Bug: #35859 Change-Id: Ib27fef18a7c0696ec6dc6d045fa06f60677333c8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98422 Reviewed-by: Alexander Markov <[email protected]> Commit-Queue: Zichang Guo <[email protected]>
1 parent e979895 commit c2f0140

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) 2019, 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+
library breakpoint_in_parts_class;
6+
7+
import 'package:observatory_test_package/has_part.dart' as hasPart;
8+
import 'test_helper.dart';
9+
import 'service_test_common.dart';
10+
11+
const int LINE = 8;
12+
const String breakpointFile =
13+
"package:observatory_test_package/the_part_2.dart";
14+
const String shortFile = "the_part_2.dart";
15+
16+
code() {
17+
hasPart.bar();
18+
}
19+
20+
List<String> stops = [];
21+
22+
List<String> expected = [
23+
"$shortFile:${LINE + 0}:3", // on 'print'
24+
"$shortFile:${LINE + 1}:1" // on class ending '}'
25+
];
26+
27+
var tests = <IsolateTest>[
28+
hasPausedAtStart,
29+
setBreakpointAtUriAndLine(breakpointFile, LINE),
30+
runStepThroughProgramRecordingStops(stops),
31+
checkRecordedStops(stops, expected)
32+
];
33+
34+
main(args) {
35+
runIsolateTestsSynchronous(args, tests,
36+
testeeConcurrent: code, pause_on_start: true, pause_on_exit: true);
37+
}

runtime/observatory/tests/service/observatory_test_package/has_part.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
library has_part;
66

77
part 'the_part.dart';
8+
part 'the_part_2.dart';
89

910
main() {
1011
Foo10 foo = new Foo10("Foo!");
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright (c) 2019, 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+
part of has_part;
6+
7+
void bar() {
8+
print('Should break here');
9+
}

runtime/vm/debugger.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3014,6 +3014,10 @@ BreakpointLocation* Debugger::BreakpointLocationAtLineCol(
30143014
bool is_package = script_url.StartsWith(Symbols::PackageScheme());
30153015
for (intptr_t i = 0; i < libs.Length(); i++) {
30163016
lib ^= libs.At(i);
3017+
// Ensure that all top-level members are loaded so their scripts
3018+
// are available for look up. When certain script only contains
3019+
// top level functions, scripts could still be loaded correctly.
3020+
lib.EnsureTopLevelClassIsFinalized();
30173021
script = lib.LookupScript(script_url, !is_package);
30183022
if (!script.IsNull()) {
30193023
scripts.Add(script);

0 commit comments

Comments
 (0)