OLD | NEW |
(Empty) | |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are |
| 4 // met: |
| 5 // |
| 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. |
| 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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. |
| 27 |
| 28 // Flags: --expose-debug-as debug |
| 29 // Get the Debug object exposed from the debug context global object. |
| 30 |
| 31 Debug = debug.Debug |
| 32 |
| 33 var function_z_text = |
| 34 " function Z() {\n" |
| 35 + " return 'Z';\n" // Breakpoint line ( #6 ) |
| 36 + " }\n"; |
| 37 |
| 38 eval( |
| 39 "function F25() {\n" |
| 40 + " return 25;\n" // Breakpoint line ( #1 ) |
| 41 + "}\n" |
| 42 + "function F26 () {\n" |
| 43 + " var x = 20;\n" |
| 44 + function_z_text // function takes exactly 3 lines |
| 45 // // Breakpoint line ( #6 ) |
| 46 // |
| 47 + " var y = 6;\n" |
| 48 + " return x + y;\n" |
| 49 + "}\n" |
| 50 + "function Nested() {\n" |
| 51 + " var a = 30;\n" |
| 52 + " return function F27() {\n" |
| 53 + " var b = 3;\n" // Breakpoint line ( #14 ) |
| 54 + " return a - b;\n" |
| 55 + " }\n" |
| 56 + "}\n" |
| 57 ); |
| 58 |
| 59 |
| 60 assertEquals(25, F25()); |
| 61 assertEquals(26, F26()); |
| 62 |
| 63 var script = Debug.findScript(F25); |
| 64 |
| 65 Debug.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, script.id, 1, 1,
"true || false || false"); |
| 66 Debug.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, script.id, 6, 1,
"true || false || false"); |
| 67 Debug.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, script.id, 14, 1,
"true || false || false"); |
| 68 |
| 69 assertEquals(3, Debug.scriptBreakPoints().length); |
| 70 |
| 71 var new_source = script.source.replace(function_z_text, ""); |
| 72 print("new source: " + new_source); |
| 73 |
| 74 var change_log = new Array(); |
| 75 Debug.LiveEdit.SetScriptSource(script, new_source, change_log); |
| 76 print("Change log: " + JSON.stringify(change_log) + "\n"); |
| 77 |
| 78 var breaks = Debug.scriptBreakPoints(); |
| 79 |
| 80 // One breakpoint gets duplicated in a old version of script. |
| 81 assertTrue(breaks.length > 3 + 1); |
| 82 |
| 83 var breakpoints_in_script = 0; |
| 84 var break_position_map = {}; |
| 85 for (var i = 0; i < breaks.length; i++) { |
| 86 if (breaks[i].script_id() == script.id) { |
| 87 break_position_map[breaks[i].line()] = true; |
| 88 breakpoints_in_script++; |
| 89 } |
| 90 } |
| 91 |
| 92 assertEquals(3, breakpoints_in_script); |
| 93 |
| 94 // Check 2 breakpoints. The one in deleted function should have been moved somew
here. |
| 95 assertTrue(break_position_map[1]); |
| 96 assertTrue(break_position_map[11]); |
| 97 |
OLD | NEW |