Skip to content

Commit 652794d

Browse files
derekxu16Commit Queue
authored andcommitted
[VM/Debugger] Mark the = tokens within assignment statements as locations where breakpoints can be set
TEST=pkg/vm_service/test/break_on_equals_signs_of_assignments_test.dart Fixes: #56932 Change-Id: Id5ed23c645b614586e4bf769dbbea9704035746b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398680 Commit-Queue: Derek Xu <[email protected]> Reviewed-by: Ben Konyi <[email protected]>
1 parent 1c8a226 commit 652794d

File tree

9 files changed

+152
-284
lines changed

9 files changed

+152
-284
lines changed

pkg/vm_service/test/async_star_step_out_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ final tests = <IsolateTest>[
7777
stepOut, // step out of generator.
7878

7979
hasStoppedAtBreakpoint,
80-
stoppedAtLine(LINE_H), // await for.
80+
stoppedAtLineColumn(line: LINE_H, column: 46), // on '{'
8181
stepInto,
8282

8383
hasStoppedAtBreakpoint, // debugger().
@@ -95,7 +95,7 @@ final tests = <IsolateTest>[
9595
stepOut, // step out of generator.
9696

9797
hasStoppedAtBreakpoint,
98-
stoppedAtLine(LINE_H), // await for.
98+
stoppedAtLineColumn(line: LINE_H, column: 46), // on '{'
9999
stepInto,
100100

101101
hasStoppedAtBreakpoint, // debugger().
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// Copyright (c) 2024, 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+
import 'common/service_test_common.dart';
6+
import 'common/test_helper.dart';
7+
8+
const String shortFile = 'break_on_equals_signs_of_assignments_test.dart';
9+
10+
// AUTOGENERATED START
11+
//
12+
// Update these constants by running:
13+
//
14+
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
15+
//
16+
const LINE_A = 38;
17+
const LINE_B = 40;
18+
const LINE_C = 42;
19+
const LINE_D = 44;
20+
const LINE_E = 46;
21+
const LINE_F = 48;
22+
const LINE_G = 51;
23+
// AUTOGENERATED END
24+
25+
class E {
26+
int x = 0;
27+
}
28+
29+
void testeeMain() {
30+
// In https://dartbug.com/56932, it was brought up that requesting a
31+
// breakpoint on line A below used to result in a breakpoint getting set on
32+
// the next line, but after we made some changes to breakpoint resolution
33+
// (https://github.com/dart-lang/sdk/commit/cdacfd80f1f5e2940056dbc32e9a8faaf1928db1),
34+
// requesting a breakpoint line A resulted in no breakpoint getting set. After
35+
// having a discussion on that issue, we decided to mark the `=` tokens within
36+
// assignment statements as locations where breakpoints can be set, and this
37+
// test ensures that the marking is happening correctly.
38+
var a = // LINE_A
39+
123;
40+
late var b = // LINE_B
41+
123;
42+
final c = // LINE_C
43+
123;
44+
late final d = // LINE_D
45+
123;
46+
a = // LINE_E
47+
456;
48+
b = // LINE_F
49+
456;
50+
final e = E();
51+
e.x = // LINE_G
52+
123;
53+
54+
print(a);
55+
print(b);
56+
print(c);
57+
print(d);
58+
print(e);
59+
}
60+
61+
List<String> stops = [];
62+
63+
const List<String> expected = [
64+
'$shortFile:$LINE_A:9', // on '='
65+
'$shortFile:$LINE_B:14', // on '='
66+
'$shortFile:$LINE_C:11', // on '='
67+
'$shortFile:$LINE_D:16', // on '='
68+
// Lines E, F and G contain assignment expressions instead of assignment
69+
// statements, so breakpoints get resolved on the LHS of them instead of on
70+
// the '=' tokens.
71+
'$shortFile:$LINE_E:3', // on 'a'
72+
'$shortFile:$LINE_F:3', // on 'b'
73+
'$shortFile:$LINE_G:5', // on 'x'
74+
];
75+
76+
final tests = <IsolateTest>[
77+
hasPausedAtStart,
78+
setBreakpointAtLine(LINE_A),
79+
setBreakpointAtLine(LINE_B),
80+
setBreakpointAtLine(LINE_C),
81+
setBreakpointAtLine(LINE_D),
82+
setBreakpointAtLine(LINE_E),
83+
setBreakpointAtLine(LINE_F),
84+
setBreakpointAtLine(LINE_G),
85+
resumeProgramRecordingStops(stops, false),
86+
checkRecordedStops(stops, expected),
87+
];
88+
89+
Future<void> main([args = const <String>[]]) => runIsolateTests(
90+
args,
91+
tests,
92+
shortFile,
93+
testeeConcurrent: testeeMain,
94+
pauseOnStart: true,
95+
pauseOnExit: true,
96+
);

pkg/vm_service/test/breakpoints_ignore_late_initialization_error_instructions_test.dart

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,47 +16,49 @@ const String shortFile =
1616
//
1717
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
1818
//
19-
const LINE_A = 33;
20-
const LINE_B = 42;
21-
const LINE_C = 51;
19+
const LINE_A = 34;
20+
const LINE_B = 44;
21+
const LINE_C = 53;
2222
// AUTOGENERATED END
2323

2424
int getThree() => 3;
2525

2626
void testeeMain() {
2727
// ignore: prefer_final_locals
2828
late int x = 1;
29-
// When a late variable is read, the VM performs checks to ensure that the
30-
// variable has been initialized. When a breakpoint is set on the following
31-
// line, it should resolve to the [toDouble] call instruction, not to an
32-
// instruction part of the late variable initialization checks.
33-
final double xd = x.toDouble(); // LINE_A
29+
final double xd =
30+
// When a late variable is read, the VM performs checks to ensure that the
31+
// variable has been initialized. When a breakpoint is set on the
32+
// following line, it should resolve to the [toDouble] call instruction,
33+
// not to an instruction part of the late variable initialization checks.
34+
x.toDouble(); // LINE_A
3435
print(xd);
3536

3637
late final int y = 2;
37-
// When a late final variable is read, the VM performs checks to ensure that
38-
// the variable has been assigned a value exactly once. When a breakpoint is
39-
// set on the following line, it should resolve to the [toDouble] call
40-
// instruction, not to an instruction part of the late variable assignment
41-
// checks.
42-
final double yd = y.toDouble(); // LINE_B
38+
final double yd =
39+
// When a late final variable is read, the VM performs checks to ensure
40+
// that the variable has been assigned a value exactly once. When a
41+
// breakpoint is set on the following line, it should resolve to the
42+
// [toDouble] call instruction, not to an instruction part of the late
43+
// variable assignment checks.
44+
y.toDouble(); // LINE_B
4345
print(yd);
4446

4547
late final int z;
4648
// When a late final variable is assigned a value, the VM performs checks to
4749
// ensure that the variable has not already been initialized. When a
48-
// breakpoint is set on the following line, it should resolve to the
49-
// [getThree] call instruction, not to an instruction part of the late
50-
// variable initialization checks.
50+
// breakpoint is set on the following line, it should resolve on the '='
51+
// token, not to an instruction part of the late variable initialization
52+
// checks.
5153
z = getThree(); // LINE_C
5254
print(z);
5355
}
5456

5557
List<String> stops = [];
5658

5759
const List<String> expected = [
58-
'$shortFile:$LINE_A:23', // on 'toDouble'
59-
'$shortFile:$LINE_B:23', // on 'toDouble'
60+
'$shortFile:$LINE_A:9', // on 'toDouble'
61+
'$shortFile:$LINE_B:9', // on 'toDouble'
6062
'$shortFile:$LINE_C:7', // on 'getThree'
6163
];
6264

pkg/vm_service/test/issue_27238_test.dart

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,54 @@ import 'common/test_helper.dart';
1515
//
1616
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
1717
//
18-
const LINE_0 = 27;
19-
const LINE_A = 28;
20-
const LINE_B = 31;
18+
const LINE_0 = 28;
19+
const LINE_A = 29;
20+
const LINE_B = 30;
2121
const LINE_C = 32;
22-
const LINE_D = 34;
22+
const LINE_D = 33;
2323
const LINE_E = 35;
24+
const LINE_F = 36;
2425
// AUTOGENERATED END
2526

2627
Future<void> testMain() async {
2728
debugger(); // LINE_0.
2829
final future1 = Future.value(); // LINE_A.
29-
final future2 = Future.value();
30+
final future2 = Future.value(); // LINE_B.
3031

31-
await future1; // LINE_B.
32-
await future2; // LINE_C.
32+
await future1; // LINE_C.
33+
await future2; // LINE_D.
3334

34-
print('foo1'); // LINE_D.
35-
print('foo2'); // LINE_E.
35+
print('foo1'); // LINE_E.
36+
print('foo2'); // LINE_F.
3637
}
3738

3839
final tests = <IsolateTest>[
3940
hasStoppedAtBreakpoint,
4041
stoppedAtLine(LINE_0),
4142
stepOver,
4243
hasStoppedAtBreakpoint,
43-
stoppedAtLine(LINE_A),
44+
stoppedAtLineColumn(line: LINE_A, column: 17), // on '='
4445
smartNext,
4546
hasStoppedAtBreakpoint,
47+
stoppedAtLineColumn(line: LINE_A, column: 26), // on 'value'
4648
smartNext,
4749
hasStoppedAtBreakpoint,
48-
stoppedAtLine(LINE_B),
50+
stoppedAtLineColumn(line: LINE_B, column: 17), // on '='
51+
smartNext,
52+
hasStoppedAtBreakpoint,
53+
stoppedAtLineColumn(line: LINE_B, column: 26), // on 'value'
4954
smartNext,
5055
hasStoppedAtBreakpoint,
5156
stoppedAtLine(LINE_C),
5257
smartNext,
5358
hasStoppedAtBreakpoint,
5459
stoppedAtLine(LINE_D),
60+
smartNext,
61+
hasStoppedAtBreakpoint,
62+
stoppedAtLine(LINE_E),
63+
smartNext,
64+
hasStoppedAtBreakpoint,
65+
stoppedAtLine(LINE_F),
5566
resumeIsolate,
5667
];
5768

runtime/observatory/tests/service/async_star_step_out_test.dart

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)