| 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 | 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); |
| 43 assertEquals("() {a=1;[B0]b=2}", Debug.showBreakPoints(f)); | 43 assertEquals("() {a=1;[B0]b=2;}", Debug.showBreakPoints(f)); |
| 44 bp2 = Debug.setBreakPoint(f, 0, 4); | 44 bp2 = Debug.setBreakPoint(f, 0, 4); |
| 45 assertEquals("() {[B0]a=1;[B1]b=2}", Debug.showBreakPoints(f)); | 45 assertEquals("() {[B0]a=1;[B1]b=2;}", Debug.showBreakPoints(f)); |
| 46 bp3 = Debug.setBreakPoint(f, 0, 11); | 46 bp3 = Debug.setBreakPoint(f, 0, 12); |
| 47 assertEquals("() {[B0]a=1;[B1]b=2[B2]}", Debug.showBreakPoints(f)); | 47 assertEquals("() {[B0]a=1;[B1]b=2;[B2]}", Debug.showBreakPoints(f)); |
| 48 Debug.clearBreakPoint(bp1); | 48 Debug.clearBreakPoint(bp1); |
| 49 assertEquals("() {[B0]a=1;b=2[B1]}", Debug.showBreakPoints(f)); | 49 assertEquals("() {[B0]a=1;b=2;[B1]}", Debug.showBreakPoints(f)); |
| 50 Debug.clearBreakPoint(bp2); | 50 Debug.clearBreakPoint(bp2); |
| 51 assertEquals("() {a=1;b=2[B0]}", Debug.showBreakPoints(f)); | 51 assertEquals("() {a=1;b=2;[B0]}", Debug.showBreakPoints(f)); |
| 52 Debug.clearBreakPoint(bp3); | 52 Debug.clearBreakPoint(bp3); |
| 53 assertEquals("() {a=1;b=2}", Debug.showBreakPoints(f)); | 53 assertEquals("() {a=1;b=2;}", Debug.showBreakPoints(f)); |
| 54 | 54 |
| 55 // The following test checks that the Debug.showBreakPoints(g) produces output | 55 // The following test checks that the Debug.showBreakPoints(g) produces output |
| 56 // like follows when changein breakpoints. | 56 // like follows when changein breakpoints. |
| 57 // | 57 // |
| 58 // function g() { | 58 // function g() { |
| 59 // [BX]a=1; | 59 // [BX]a=1; |
| 60 // [BX]b=2; | 60 // [BX]b=2; |
| 61 // }[BX] | 61 // }[BX] |
| 62 | 62 |
| 63 // Test set and clear breakpoint at the first possible location (line 0, | 63 // Test set and clear breakpoint at the first possible location (line 0, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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); |
| 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); |
| 141 assertEquals("() {[B0]a=1;[B1]b=2}", Debug.showBreakPoints(f)); | 141 assertEquals("() {[B0]a=1;[B1]b=2;}", Debug.showBreakPoints(f)); |
| 142 bp3 = setBreakpointByPosition(f, 11); | 142 bp3 = setBreakpointByPosition(f, 11); |
| 143 assertEquals("() {[B0]a=1;[B1]b=2[B2]}", Debug.showBreakPoints(f)); | 143 assertEquals("() {[B0]a=1;[B1]b=2;[B2]}", Debug.showBreakPoints(f)); |
| 144 Debug.clearBreakPoint(bp1); | 144 Debug.clearBreakPoint(bp1); |
| 145 assertEquals("() {[B0]a=1;b=2[B1]}", Debug.showBreakPoints(f)); | 145 assertEquals("() {[B0]a=1;b=2;[B1]}", Debug.showBreakPoints(f)); |
| 146 Debug.clearBreakPoint(bp2); | 146 Debug.clearBreakPoint(bp2); |
| 147 assertEquals("() {a=1;b=2[B0]}", Debug.showBreakPoints(f)); | 147 assertEquals("() {a=1;b=2;[B0]}", Debug.showBreakPoints(f)); |
| 148 Debug.clearBreakPoint(bp3); | 148 Debug.clearBreakPoint(bp3); |
| 149 assertEquals("() {a=1;b=2}", Debug.showBreakPoints(f)); | 149 assertEquals("() {a=1;b=2;}", Debug.showBreakPoints(f)); |
| 150 | 150 |
| 151 bp = setBreakpointByPosition(g, 0); | 151 bp = setBreakpointByPosition(g, 0); |
| 152 //function g() { | 152 //function g() { |
| 153 //[B0]a=1; | 153 //[B0]a=1; |
| 154 //b=2; | 154 //b=2; |
| 155 //} | 155 //} |
| 156 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0); | 156 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0); |
| 157 Debug.clearBreakPoint(bp); | 157 Debug.clearBreakPoint(bp); |
| 158 //function g() { | 158 //function g() { |
| 159 //a=1; | 159 //a=1; |
| (...skipping 37 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); |
| OLD | NEW |