OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Flags: --expose-debug-as debug | |
29 // Get the Debug object exposed from the debug context global object. | |
30 Debug = debug.Debug | 28 Debug = debug.Debug |
31 | 29 |
32 // Simple debug event handler which just counts the number of break points hit. | 30 // Simple debug event handler which just counts the number of break points hit. |
33 var break_point_hit_count; | 31 var break_point_hit_count; |
34 | 32 |
35 function listener(event, exec_state, event_data, data) { | 33 function listener(event, exec_state, event_data, data) { |
36 if (event == Debug.DebugEvent.Break) { | 34 if (event == Debug.DebugEvent.Break) { |
37 break_point_hit_count++; | 35 break_point_hit_count++; |
38 } | 36 } |
39 }; | 37 }; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 bp = Debug.setBreakPoint(f, 0, 0, '"a" == "a"'); | 72 bp = Debug.setBreakPoint(f, 0, 0, '"a" == "a"'); |
75 f(); | 73 f(); |
76 assertEquals(1, break_point_hit_count); | 74 assertEquals(1, break_point_hit_count); |
77 Debug.clearBreakPoint(bp); | 75 Debug.clearBreakPoint(bp); |
78 break_point_hit_count = 0; | 76 break_point_hit_count = 0; |
79 bp = Debug.setBreakPoint(f, 0, 0, "'a' == 'a'"); | 77 bp = Debug.setBreakPoint(f, 0, 0, "'a' == 'a'"); |
80 f(); | 78 f(); |
81 assertEquals(1, break_point_hit_count); | 79 assertEquals(1, break_point_hit_count); |
82 Debug.clearBreakPoint(bp); | 80 Debug.clearBreakPoint(bp); |
83 | 81 |
84 // Changing condition. | |
85 break_point_hit_count = 0; | |
86 bp = Debug.setBreakPoint(f, 0, 0, '"ab".indexOf("b") > 0'); | |
87 f(); | |
88 assertEquals(1, break_point_hit_count); | |
89 Debug.changeBreakPointCondition(bp, 'Math.sin(Math.PI/2) > 1'); | |
90 f(); | |
91 assertEquals(1, break_point_hit_count); | |
92 Debug.changeBreakPointCondition(bp, '1==1'); | |
93 f(); | |
94 assertEquals(2, break_point_hit_count); | |
95 Debug.clearBreakPoint(bp); | |
96 | |
97 // Conditional breakpoint which checks global variable. | 82 // Conditional breakpoint which checks global variable. |
98 break_point_hit_count = 0; | 83 break_point_hit_count = 0; |
99 bp = Debug.setBreakPoint(f, 0, 0, 'x==1'); | 84 bp = Debug.setBreakPoint(f, 0, 0, 'x==1'); |
100 f(); | 85 f(); |
101 assertEquals(0, break_point_hit_count); | 86 assertEquals(0, break_point_hit_count); |
102 x=1; | 87 x=1; |
103 f(); | 88 f(); |
104 assertEquals(1, break_point_hit_count); | 89 assertEquals(1, break_point_hit_count); |
105 Debug.clearBreakPoint(bp); | 90 Debug.clearBreakPoint(bp); |
106 | 91 |
(...skipping 20 matching lines...) Expand all Loading... |
127 bp = Debug.setBreakPoint(h, 0, 22, 'a % 2 == 0'); | 112 bp = Debug.setBreakPoint(h, 0, 22, 'a % 2 == 0'); |
128 for (var i = 0; i < 10; i++) { | 113 for (var i = 0; i < 10; i++) { |
129 g(); | 114 g(); |
130 } | 115 } |
131 assertEquals(5, break_point_hit_count); | 116 assertEquals(5, break_point_hit_count); |
132 Debug.clearBreakPoint(bp); | 117 Debug.clearBreakPoint(bp); |
133 | 118 |
134 // Multiple conditional breakpoint which the same condition. | 119 // Multiple conditional breakpoint which the same condition. |
135 break_point_hit_count = 0; | 120 break_point_hit_count = 0; |
136 bp1 = Debug.setBreakPoint(h, 0, 22, 'a % 2 == 0'); | 121 bp1 = Debug.setBreakPoint(h, 0, 22, 'a % 2 == 0'); |
137 bp2 = Debug.setBreakPoint(h, 0, 22, 'a % 2 == 0'); | 122 assertThrows(() => Debug.setBreakPoint(h, 0, 22, 'a % 2 == 0')); |
138 for (var i = 0; i < 10; i++) { | 123 for (var i = 0; i < 10; i++) { |
139 g(); | 124 g(); |
140 } | 125 } |
141 assertEquals(5, break_point_hit_count); | 126 assertEquals(5, break_point_hit_count); |
142 Debug.clearBreakPoint(bp1); | 127 Debug.clearBreakPoint(bp1); |
143 Debug.clearBreakPoint(bp2); | |
144 | 128 |
145 // Multiple conditional breakpoint which different conditions. | 129 // Multiple conditional breakpoint which different conditions. |
146 break_point_hit_count = 0; | 130 break_point_hit_count = 0; |
147 bp1 = Debug.setBreakPoint(h, 0, 22, 'a % 2 == 0'); | 131 bp1 = Debug.setBreakPoint(h, 0, 22, 'a % 2 == 0'); |
148 bp2 = Debug.setBreakPoint(h, 0, 22, '(a + 1) % 2 == 0'); | 132 assertThrows(() => Debug.setBreakPoint(h, 0, 22, '(a + 1) % 2 == 0')); |
149 for (var i = 0; i < 10; i++) { | 133 for (var i = 0; i < 10; i++) { |
150 g(); | 134 g(); |
151 } | 135 } |
152 assertEquals(10, break_point_hit_count); | 136 assertEquals(5, break_point_hit_count); |
153 Debug.clearBreakPoint(bp1); | 137 Debug.clearBreakPoint(bp1); |
154 Debug.clearBreakPoint(bp2); | |
OLD | NEW |