| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 13 matching lines...) Expand all Loading... |
| 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 | 29 |
| 30 // This test tests that full code compiled without debug break slots | 30 // This test tests that full code compiled without debug break slots |
| 31 // is recompiled with debug break slots when debugging is started. | 31 // is recompiled with debug break slots when debugging is started. |
| 32 | 32 |
| 33 // Get the Debug object exposed from the debug context global object. | 33 // Get the Debug object exposed from the debug context global object. |
| 34 Debug = debug.Debug | 34 Debug = debug.Debug; |
| 35 | 35 |
| 36 var bp; | 36 var bp; |
| 37 var done = false; | 37 var done = false; |
| 38 var step_count = 0; | 38 var step_count = 0; |
| 39 var set_bp = false | 39 var set_bp = false; |
| 40 | 40 |
| 41 // Debug event listener which steps until the global variable done is true. | 41 // Debug event listener which steps until the global variable done is true. |
| 42 function listener(event, exec_state, event_data, data) { | 42 function listener(event, exec_state, event_data, data) { |
| 43 if (event == Debug.DebugEvent.Break) { | 43 if (event == Debug.DebugEvent.Break) { |
| 44 if (!done) exec_state.prepareStep(Debug.StepAction.StepNext); | 44 if (!done) exec_state.prepareStep(Debug.StepAction.StepNext); |
| 45 step_count++; | 45 step_count++; |
| 46 } | 46 } |
| 47 }; | 47 } |
| 48 | 48 |
| 49 // Set the global variables state to prpare the stepping test. | 49 // Set the global variables state to prpare the stepping test. |
| 50 function prepare_step_test() { | 50 function prepare_step_test() { |
| 51 done = false; | 51 done = false; |
| 52 step_count = 0; | 52 step_count = 0; |
| 53 } | 53 } |
| 54 | 54 |
| 55 // Test function to step through. | 55 // Test function to step through. |
| 56 function f() { | 56 function f() { |
| 57 var a = 0; | 57 var a = 0; |
| 58 if (set_bp) { bp = Debug.setBreakPoint(f, 3); } | 58 if (set_bp) { bp = Debug.setBreakPoint(f, 3); } |
| 59 var i = 1; | 59 var i = 1; |
| 60 var j = 2; | 60 var j = 2; |
| 61 done = true; | 61 done = true; |
| 62 }; | 62 } |
| 63 | 63 |
| 64 prepare_step_test(); | 64 prepare_step_test(); |
| 65 f(); | 65 f(); |
| 66 | 66 |
| 67 // Add the debug event listener. | 67 // Add the debug event listener. |
| 68 Debug.setListener(listener); | 68 Debug.setListener(listener); |
| 69 | 69 |
| 70 // Make f set a breakpoint with an activation on the stack. | 70 // Make f set a breakpoint with an activation on the stack. |
| 71 prepare_step_test(); | 71 prepare_step_test(); |
| 72 set_bp = true; | 72 set_bp = true; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 85 assertEquals(4, step_count); | 85 assertEquals(4, step_count); |
| 86 | 86 |
| 87 // Clear the breakpoint and check that no stepping happens. | 87 // Clear the breakpoint and check that no stepping happens. |
| 88 Debug.clearBreakPoint(bp); | 88 Debug.clearBreakPoint(bp); |
| 89 prepare_step_test(); | 89 prepare_step_test(); |
| 90 f(); | 90 f(); |
| 91 assertEquals(0, step_count); | 91 assertEquals(0, step_count); |
| 92 | 92 |
| 93 // Get rid of the debug event listener. | 93 // Get rid of the debug event listener. |
| 94 Debug.setListener(null); | 94 Debug.setListener(null); |
| OLD | NEW |