OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --expose-debug-as debug |
| 6 |
| 7 function f0() { |
| 8 var v00 = 0; // Break 1 |
| 9 var v01 = 1; |
| 10 // Normal function call in a catch scope. |
| 11 try { |
| 12 throw 1; |
| 13 } catch (e) { |
| 14 try{ |
| 15 f1(); |
| 16 } catch (e) { |
| 17 var v02 = 2; // Break 13 |
| 18 } |
| 19 } |
| 20 var v03 = 3; |
| 21 var v04 = 4; |
| 22 } |
| 23 |
| 24 function f1() { |
| 25 var v10 = 0; // Break 2 |
| 26 var v11 = 1; |
| 27 // Getter call. |
| 28 var v12 = o.get; |
| 29 var v13 = 3 // Break 4 |
| 30 // Setter call. |
| 31 o.set = 2; |
| 32 var v14 = 4; // Break 6 |
| 33 // Function.prototype.call. |
| 34 f2.call(); |
| 35 var v15 = 5; // Break 12 |
| 36 var v16 = 6; |
| 37 // Exit function by throw. |
| 38 throw 1; |
| 39 var v17 = 7; |
| 40 } |
| 41 |
| 42 function get() { |
| 43 var g0 = 0; // Break 3 |
| 44 var g1 = 1; |
| 45 return 3; |
| 46 } |
| 47 |
| 48 function set() { |
| 49 var s0 = 0; // Break 5 |
| 50 return 3; |
| 51 } |
| 52 |
| 53 function f2() { |
| 54 var v20 = 0; // Break 7 |
| 55 // Construct call. |
| 56 var v21 = new c0(); |
| 57 var v22 = 2; // Break 9 |
| 58 // Bound function. |
| 59 b0(); |
| 60 return 2; // Break 11 |
| 61 } |
| 62 |
| 63 function c0() { |
| 64 this.v0 = 0; // Break 8 |
| 65 this.v1 = 1; |
| 66 } |
| 67 |
| 68 function f3() { |
| 69 var v30 = 0; // Break 10 |
| 70 var v31 = 1; |
| 71 return 3; |
| 72 } |
| 73 |
| 74 var b0 = f3.bind(o); |
| 75 |
| 76 var o = {}; |
| 77 Object.defineProperty(o, "get", { get : get }); |
| 78 Object.defineProperty(o, "set", { set : set }); |
| 79 |
| 80 Debug = debug.Debug; |
| 81 var break_count = 0 |
| 82 var exception = null; |
| 83 var step_size; |
| 84 |
| 85 function listener(event, exec_state, event_data, data) { |
| 86 if (event != Debug.DebugEvent.Break) return; |
| 87 try { |
| 88 var line = exec_state.frame(0).sourceLineText(); |
| 89 print(line); |
| 90 var match = line.match(/\/\/ Break (\d+)$/); |
| 91 assertEquals(2, match.length); |
| 92 assertEquals(break_count, parseInt(match[1])); |
| 93 break_count += step_size; |
| 94 exec_state.prepareStep(Debug.StepAction.StepFrame, step_size); |
| 95 } catch (e) { |
| 96 print(e + e.stack); |
| 97 exception = e; |
| 98 } |
| 99 } |
| 100 |
| 101 for (step_size = 1; step_size < 6; step_size++) { |
| 102 print("step size = " + step_size); |
| 103 break_count = 0; |
| 104 Debug.setListener(listener); |
| 105 debugger; // Break 0 |
| 106 f0(); |
| 107 Debug.setListener(null); // Break 14 |
| 108 assertTrue(break_count > 14); |
| 109 } |
| 110 |
| 111 assertNull(exception); |
OLD | NEW |