OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // VMOptions=--error_on_bad_type --error_on_bad_override | 4 // VMOptions=--error_on_bad_type --error_on_bad_override |
5 | 5 |
6 import 'dart:developer'; | 6 import 'dart:developer'; |
7 import 'package:observatory/service_io.dart'; | 7 import 'package:observatory/service_io.dart'; |
8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
9 import 'service_test_common.dart'; | 9 import 'service_test_common.dart'; |
10 import 'test_helper.dart'; | 10 import 'test_helper.dart'; |
(...skipping 14 matching lines...) Expand all Loading... |
25 try { | 25 try { |
26 for (int i = 0; i < x; i++) { | 26 for (int i = 0; i < x; i++) { |
27 sum += x; | 27 sum += x; |
28 } | 28 } |
29 } catch (e) { | 29 } catch (e) { |
30 print("caught $e"); | 30 print("caught $e"); |
31 } | 31 } |
32 if (global >= 100) { | 32 if (global >= 100) { |
33 debugger(); | 33 debugger(); |
34 } | 34 } |
35 global = global + 1; // Line A | 35 global = global + 1; // Line A |
36 return sum; | 36 return sum; |
37 } | 37 } |
38 | 38 |
39 @alwaysInline | 39 @alwaysInline |
40 b2(x) => b3(x); // Line B | 40 b2(x) => b3(x); // Line B |
41 | 41 |
42 @alwaysInline | 42 @alwaysInline |
43 b1(x) => b2(x); // Line C | 43 b1(x) => b2(x); // Line C |
44 | 44 |
45 test() { | 45 test() { |
46 while (true) { | 46 while (true) { |
47 b1(10000); // Line D | 47 b1(10000); // Line D |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 var tests = [ | 51 var tests = [ |
52 hasStoppedAtBreakpoint, | 52 hasStoppedAtBreakpoint, |
53 stoppedAtLine(LINE_A), | 53 stoppedAtLine(LINE_A), |
| 54 |
54 (Isolate isolate) async { | 55 (Isolate isolate) async { |
55 // We are not able to rewind frame 0. | 56 // We are not able to rewind frame 0. |
56 bool caughtException; | 57 bool caughtException; |
57 try { | 58 try { |
58 await isolate.rewind(0); | 59 await isolate.rewind(0); |
59 expect(false, isTrue, reason: 'Unreachable'); | 60 expect(false, isTrue, reason:'Unreachable'); |
60 } on ServerRpcException catch (e) { | 61 } on ServerRpcException catch(e) { |
61 caughtException = true; | 62 caughtException = true; |
62 expect(e.code, equals(ServerRpcException.kCannotResume)); | 63 expect(e.code, equals(ServerRpcException.kCannotResume)); |
63 expect(e.message, 'Frame must be in bounds [1..9]: saw 0'); | 64 expect(e.message, 'Frame must be in bounds [1..9]: saw 0'); |
64 } | 65 } |
65 expect(caughtException, isTrue); | 66 expect(caughtException, isTrue); |
66 }, | 67 }, |
| 68 |
67 (Isolate isolate) async { | 69 (Isolate isolate) async { |
68 // We are not able to rewind frame 10. | 70 // We are not able to rewind frame 10. |
69 bool caughtException; | 71 bool caughtException; |
70 try { | 72 try { |
71 await isolate.rewind(10); | 73 await isolate.rewind(10); |
72 expect(false, isTrue, reason: 'Unreachable'); | 74 expect(false, isTrue, reason:'Unreachable'); |
73 } on ServerRpcException catch (e) { | 75 } on ServerRpcException catch(e) { |
74 caughtException = true; | 76 caughtException = true; |
75 expect(e.code, equals(ServerRpcException.kCannotResume)); | 77 expect(e.code, equals(ServerRpcException.kCannotResume)); |
76 expect(e.message, 'Frame must be in bounds [1..9]: saw 10'); | 78 expect(e.message, 'Frame must be in bounds [1..9]: saw 10'); |
77 } | 79 } |
78 expect(caughtException, isTrue); | 80 expect(caughtException, isTrue); |
79 }, | 81 }, |
| 82 |
80 (Isolate isolate) async { | 83 (Isolate isolate) async { |
81 // We are at our breakpoint with global=100. | 84 // We are at our breakpoint with global=100. |
82 var result = await isolate.rootLibrary.evaluate('global'); | 85 var result = await isolate.rootLibrary.evaluate('global'); |
83 print('global is $result'); | 86 print('global is $result'); |
84 expect(result.type, equals('Instance')); | 87 expect(result.type, equals('Instance')); |
85 expect(result.valueAsString, equals('100')); | 88 expect(result.valueAsString, equals('100')); |
86 | 89 |
87 // Rewind the top stack frame. | 90 // Rewind the top stack frame. |
88 result = await isolate.rewind(1); | 91 result = await isolate.rewind(1); |
89 expect(result['type'], equals('Success')); | 92 expect(result['type'], equals('Success')); |
90 }, | 93 }, |
| 94 |
91 hasStoppedAtBreakpoint, | 95 hasStoppedAtBreakpoint, |
92 stoppedAtLine(LINE_B), | 96 stoppedAtLine(LINE_B), |
| 97 |
93 (Isolate isolate) async { | 98 (Isolate isolate) async { |
94 var result = await isolate.resume(); | 99 var result = await isolate.resume(); |
95 expect(result['type'], equals('Success')); | 100 expect(result['type'], equals('Success')); |
96 }, | 101 }, |
| 102 |
97 hasStoppedAtBreakpoint, | 103 hasStoppedAtBreakpoint, |
98 stoppedAtLine(LINE_A), | 104 stoppedAtLine(LINE_A), |
| 105 |
99 (Isolate isolate) async { | 106 (Isolate isolate) async { |
100 // global still is equal to 100. We did not execute "global++". | 107 // global still is equal to 100. We did not execute "global++". |
101 var result = await isolate.rootLibrary.evaluate('global'); | 108 var result = await isolate.rootLibrary.evaluate('global'); |
102 print('global is $result'); | 109 print('global is $result'); |
103 expect(result.type, equals('Instance')); | 110 expect(result.type, equals('Instance')); |
104 expect(result.valueAsString, equals('100')); | 111 expect(result.valueAsString, equals('100')); |
105 | 112 |
106 // Resume again, for fun. | 113 // Resume again, for fun. |
107 result = await isolate.resume(); | 114 result = await isolate.resume(); |
108 expect(result['type'], equals('Success')); | 115 expect(result['type'], equals('Success')); |
109 }, | 116 }, |
| 117 |
110 hasStoppedAtBreakpoint, | 118 hasStoppedAtBreakpoint, |
111 stoppedAtLine(LINE_A), | 119 stoppedAtLine(LINE_A), |
| 120 |
112 (Isolate isolate) async { | 121 (Isolate isolate) async { |
113 // global is now 101. | 122 // global is now 101. |
114 var result = await isolate.rootLibrary.evaluate('global'); | 123 var result = await isolate.rootLibrary.evaluate('global'); |
115 print('global is $result'); | 124 print('global is $result'); |
116 expect(result.type, equals('Instance')); | 125 expect(result.type, equals('Instance')); |
117 expect(result.valueAsString, equals('101')); | 126 expect(result.valueAsString, equals('101')); |
118 | 127 |
119 // Rewind up to 'test'/ | 128 // Rewind up to 'test'/ |
120 result = await isolate.rewind(3); | 129 result = await isolate.rewind(3); |
121 expect(result['type'], equals('Success')); | 130 expect(result['type'], equals('Success')); |
122 }, | 131 }, |
| 132 |
123 hasStoppedAtBreakpoint, | 133 hasStoppedAtBreakpoint, |
124 stoppedAtLine(LINE_D), | 134 stoppedAtLine(LINE_D), |
| 135 |
125 (Isolate isolate) async { | 136 (Isolate isolate) async { |
126 // Reset global to 0 and start again. | 137 // Reset global to 0 and start again. |
127 var result = await isolate.rootLibrary.evaluate('global=0'); | 138 var result = await isolate.rootLibrary.evaluate('global=0'); |
128 print('set global to $result'); | 139 print('set global to $result'); |
129 expect(result.type, equals('Instance')); | 140 expect(result.type, equals('Instance')); |
130 expect(result.valueAsString, equals('0')); | 141 expect(result.valueAsString, equals('0')); |
131 | 142 |
132 result = await isolate.resume(); | 143 result = await isolate.resume(); |
133 expect(result['type'], equals('Success')); | 144 expect(result['type'], equals('Success')); |
134 }, | 145 }, |
| 146 |
135 hasStoppedAtBreakpoint, | 147 hasStoppedAtBreakpoint, |
136 stoppedAtLine(LINE_A), | 148 stoppedAtLine(LINE_A), |
| 149 |
137 (Isolate isolate) async { | 150 (Isolate isolate) async { |
138 // We are at our breakpoint with global=100. | 151 // We are at our breakpoint with global=100. |
139 var result = await isolate.rootLibrary.evaluate('global'); | 152 var result = await isolate.rootLibrary.evaluate('global'); |
140 print('global is $result'); | 153 print('global is $result'); |
141 expect(result.type, equals('Instance')); | 154 expect(result.type, equals('Instance')); |
142 expect(result.valueAsString, equals('100')); | 155 expect(result.valueAsString, equals('100')); |
143 | 156 |
144 // Rewind the top 2 stack frames. | 157 // Rewind the top 2 stack frames. |
145 result = await isolate.rewind(2); | 158 result = await isolate.rewind(2); |
146 expect(result['type'], equals('Success')); | 159 expect(result['type'], equals('Success')); |
147 }, | 160 }, |
| 161 |
148 hasStoppedAtBreakpoint, | 162 hasStoppedAtBreakpoint, |
149 stoppedAtLine(LINE_C), | 163 stoppedAtLine(LINE_C), |
150 ]; | 164 ]; |
151 | 165 |
152 main(args) => runIsolateTests(args, tests, testeeConcurrent: test, extraArgs: [ | 166 |
153 '--trace-rewind', | 167 main(args) => runIsolateTests(args, tests, testeeConcurrent: test, |
154 '--no-prune-dead-locals', | 168 extraArgs: |
155 '--enable-inlining-annotations', | 169 ['--trace-rewind', |
156 '--no-background-compilation', | 170 '--no-prune-dead-locals', |
157 '--optimization-counter-threshold=10' | 171 '--enable-inlining-annotations', |
158 ]); | 172 '--no-background-compilation', |
| 173 '--optimization-counter-threshold=10']); |
OLD | NEW |