| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 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 --debug-eval-readonly-locals --legacy-const | |
| 29 | |
| 30 Debug = debug.Debug | |
| 31 | |
| 32 listenerComplete = false; | |
| 33 exception = false; | |
| 34 | |
| 35 // var0: init after break point, changed by debug eval. | |
| 36 // const0: init before break point, changed by debug eval. | |
| 37 // const1: init after break point, materialized but untouched by debug eval. | |
| 38 // const2: init after break point, materialized and changed by debug eval. | |
| 39 // const3: context allocated const, init before break point, changed by eval. | |
| 40 function f() { | |
| 41 var var1 = 21; | |
| 42 const const3 = 3; | |
| 43 | |
| 44 function g() { | |
| 45 const const0 = 0; | |
| 46 assertEquals(undefined, const1); | |
| 47 assertEquals(undefined, const2); | |
| 48 assertEquals(3, const3); | |
| 49 assertEquals(21, var1); | |
| 50 | |
| 51 debugger; // Break point. | |
| 52 | |
| 53 assertEquals(undefined, var0); | |
| 54 assertEquals(0, const0); | |
| 55 assertEquals(undefined, const1); | |
| 56 assertEquals(undefined, const2); | |
| 57 var var0 = 20; | |
| 58 const const1 = 1; | |
| 59 const const2 = 2; | |
| 60 assertEquals(20, var0); | |
| 61 assertEquals(1, const1); | |
| 62 assertEquals(2, const2); | |
| 63 } | |
| 64 | |
| 65 g(); | |
| 66 | |
| 67 assertEquals(21, var1); | |
| 68 assertEquals(3, const3); | |
| 69 } | |
| 70 | |
| 71 | |
| 72 function listener(event, exec_state, event_data, data) { | |
| 73 if (event != Debug.DebugEvent.Break) return; | |
| 74 try { | |
| 75 var frame = exec_state.frame(0); | |
| 76 var evaluate = function(something) { | |
| 77 return frame.evaluate(something).value() | |
| 78 } | |
| 79 | |
| 80 var count = frame.localCount(); | |
| 81 assertEquals(4, count); | |
| 82 var expectation = { "const0" : 0, | |
| 83 "const1" : undefined, | |
| 84 "const2" : undefined, | |
| 85 "const3" : 3, | |
| 86 "var0" : undefined, | |
| 87 "var1" : 21 }; | |
| 88 for (var i = 0; i < frame.localCount(); ++i) { | |
| 89 var name = frame.localName(i); | |
| 90 var value = frame.localValue(i).value(); | |
| 91 assertEquals(expectation[name], value); | |
| 92 } | |
| 93 | |
| 94 evaluate('const0 = 10'); | |
| 95 evaluate('const2 = 12'); | |
| 96 evaluate('const3 = 13'); | |
| 97 evaluate('var0 = 30'); | |
| 98 evaluate('var1 = 31'); | |
| 99 | |
| 100 // Indicate that all was processed. | |
| 101 listenerComplete = true; | |
| 102 } catch (e) { | |
| 103 exception = e; | |
| 104 print("Caught something. " + e + " " + e.stack); | |
| 105 }; | |
| 106 }; | |
| 107 | |
| 108 // Run and compile before debugger is active. | |
| 109 try { f(); } catch (e) { } | |
| 110 | |
| 111 Debug.setListener(listener); | |
| 112 | |
| 113 f(); | |
| 114 | |
| 115 Debug.setListener(null); | |
| 116 | |
| 117 assertFalse(exception, "exception in listener") | |
| 118 assertTrue(listenerComplete); | |
| OLD | NEW |