| 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 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 | 28 // Flags: --expose-debug-as debug |
| 29 // Get the Debug object exposed from the debug context global object. | 29 // Get the Debug object exposed from the debug context global object. |
| 30 Debug = debug.Debug | 30 Debug = debug.Debug |
| 31 | 31 |
| 32 function f() {a=1;b=2}; | 32 function f() {a=1;b=2} |
| 33 function g() { | 33 function g() { |
| 34 a=1; | 34 a=1; |
| 35 b=2; | 35 b=2; |
| 36 } | 36 } |
| 37 | 37 |
| 38 bp = Debug.setBreakPoint(f, 0, 0); | 38 bp = Debug.setBreakPoint(f, 0, 0); |
| 39 assertEquals("() {[B0]a=1;b=2}", Debug.showBreakPoints(f)); | 39 assertEquals("() {[B0]a=1;b=2}", Debug.showBreakPoints(f)); |
| 40 Debug.clearBreakPoint(bp); | 40 Debug.clearBreakPoint(bp); |
| 41 assertEquals("() {a=1;b=2}", Debug.showBreakPoints(f)); | 41 assertEquals("() {a=1;b=2}", Debug.showBreakPoints(f)); |
| 42 bp1 = Debug.setBreakPoint(f, 0, 8); | 42 bp1 = Debug.setBreakPoint(f, 0, 8); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 assertTrue(Debug.showBreakPoints(g).indexOf("[B1]") < 0); | 114 assertTrue(Debug.showBreakPoints(g).indexOf("[B1]") < 0); |
| 115 Debug.clearBreakPoint(bp3); | 115 Debug.clearBreakPoint(bp3); |
| 116 // function g() { | 116 // function g() { |
| 117 // a=1; | 117 // a=1; |
| 118 // b=2; | 118 // b=2; |
| 119 // } | 119 // } |
| 120 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]") < 0); | 120 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]") < 0); |
| 121 | 121 |
| 122 | 122 |
| 123 // Tests for setting break points by script id and position. | 123 // Tests for setting break points by script id and position. |
| 124 function setBreakpointByPosition(f, position) | 124 function setBreakpointByPosition(f, position, opt_position_alignment) |
| 125 { | 125 { |
| 126 var break_point = Debug.setBreakPointByScriptIdAndPosition( | 126 var break_point = Debug.setBreakPointByScriptIdAndPosition( |
| 127 Debug.findScript(f).id, | 127 Debug.findScript(f).id, |
| 128 position + Debug.sourcePosition(f), | 128 position + Debug.sourcePosition(f), |
| 129 "", | 129 "", |
| 130 true); | 130 true, opt_position_alignment); |
| 131 return break_point.number(); | 131 return break_point.number(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 bp = setBreakpointByPosition(f, 0); | 134 bp = setBreakpointByPosition(f, 0); |
| 135 assertEquals("() {[B0]a=1;b=2}", Debug.showBreakPoints(f)); | 135 assertEquals("() {[B0]a=1;b=2}", Debug.showBreakPoints(f)); |
| 136 Debug.clearBreakPoint(bp); | 136 Debug.clearBreakPoint(bp); |
| 137 assertEquals("() {a=1;b=2}", Debug.showBreakPoints(f)); | 137 assertEquals("() {a=1;b=2}", Debug.showBreakPoints(f)); |
| 138 bp1 = setBreakpointByPosition(f, 8); | 138 bp1 = setBreakpointByPosition(f, 8); |
| 139 assertEquals("() {a=1;[B0]b=2}", Debug.showBreakPoints(f)); | 139 assertEquals("() {a=1;[B0]b=2}", Debug.showBreakPoints(f)); |
| 140 bp2 = setBreakpointByPosition(f, 4); | 140 bp2 = setBreakpointByPosition(f, 4); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 //b=2; | 197 //b=2; |
| 198 //}[B0] | 198 //}[B0] |
| 199 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]}") > 0); | 199 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]}") > 0); |
| 200 assertTrue(Debug.showBreakPoints(g).indexOf("[B1]") < 0); | 200 assertTrue(Debug.showBreakPoints(g).indexOf("[B1]") < 0); |
| 201 Debug.clearBreakPoint(bp3); | 201 Debug.clearBreakPoint(bp3); |
| 202 //function g() { | 202 //function g() { |
| 203 //a=1; | 203 //a=1; |
| 204 //b=2; | 204 //b=2; |
| 205 //} | 205 //} |
| 206 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]") < 0); | 206 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]") < 0); |
| 207 |
| 208 // Tests for setting break points without statement aligment. |
| 209 // (This may be sensitive to compiler break position map generation). |
| 210 function h() {a=f(f2(1,2),f3())+f3();b=f3();} |
| 211 var scenario = [ |
| 212 [5, "{a[B0]=f"], |
| 213 [6, "{a=[B0]f("], |
| 214 [7, "{a=f([B0]f2("], |
| 215 [16, "f2(1,2),[B0]f3()"], |
| 216 [22, "+[B0]f3()"] |
| 217 ]; |
| 218 for(var i = 0; i < scenario.length; i++) { |
| 219 bp1 = setBreakpointByPosition(h, scenario[i][0], |
| 220 Debug.BreakPositionAlignment.BreakPosition); |
| 221 assertTrue(Debug.showBreakPoints(h, undefined, |
| 222 Debug.BreakPositionAlignment.BreakPosition).indexOf(scenario[i][1]) > 0); |
| 223 Debug.clearBreakPoint(bp1); |
| 224 } |
| 225 |
| OLD | NEW |