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 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 f(); | 46 f(); |
47 } | 47 } |
48 } | 48 } |
49 function h() { | 49 function h() { |
50 state = [-1, -1, -1]; | 50 state = [-1, -1, -1]; |
51 for (state[0] = 0; state[0] < 3; state[0]++) { | 51 for (state[0] = 0; state[0] < 3; state[0]++) { |
52 g(); | 52 g(); |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 function TestCase(step_count, expected_final_state) { | 56 function TestCase(expected_final_state) { |
57 print("Test case, step count: " + step_count); | |
58 | |
59 var listener_exception = null; | 57 var listener_exception = null; |
60 var state_snapshot; | 58 var state_snapshot; |
61 var listener_state; | 59 var listener_state; |
62 var bp; | 60 var bp; |
63 | 61 |
64 function listener(event, exec_state, event_data, data) { | 62 function listener(event, exec_state, event_data, data) { |
65 print("Here ("+event+"/"+listener_state+"): " + | 63 print("Here ("+event+"/"+listener_state+"): " + |
66 exec_state.frame(0).sourceLineText()); | 64 exec_state.frame(0).sourceLineText()); |
67 try { | 65 try { |
68 if (event == Debug.DebugEvent.Break) { | 66 if (event == Debug.DebugEvent.Break) { |
69 if (listener_state == 0) { | 67 if (listener_state == 0) { |
70 Debug.clearBreakPoint(bp); | 68 Debug.clearBreakPoint(bp); |
71 exec_state.prepareStep(Debug.StepAction.StepNext, step_count); | 69 exec_state.prepareStep(Debug.StepAction.StepNext); |
72 listener_state = 1; | 70 listener_state = 1; |
73 } else if (listener_state == 1) { | 71 } else if (listener_state == 1) { |
74 state_snapshot = String(state); | 72 state_snapshot = String(state); |
75 print("State: " + state_snapshot); | 73 print("State: " + state_snapshot); |
76 Debug.setListener(null); | 74 Debug.setListener(null); |
77 listener_state = 2; | 75 listener_state = 2; |
78 } | 76 } |
79 } | 77 } |
80 } catch (e) { | 78 } catch (e) { |
81 listener_exception = e; | 79 listener_exception = e; |
(...skipping 13 matching lines...) Expand all Loading... |
95 assertUnreachable(); | 93 assertUnreachable(); |
96 } | 94 } |
97 | 95 |
98 assertEquals(expected_final_state, state_snapshot); | 96 assertEquals(expected_final_state, state_snapshot); |
99 } | 97 } |
100 | 98 |
101 | 99 |
102 // Warm-up -- make sure all is compiled and ready for breakpoint. | 100 // Warm-up -- make sure all is compiled and ready for breakpoint. |
103 h(); | 101 h(); |
104 | 102 |
105 TestCase(0, "0,0,-1"); | 103 TestCase("0,0,-1"); |
106 TestCase(1, "0,0,-1"); | |
107 TestCase(2, "0,0,0"); | |
108 TestCase(5, "0,0,1"); | |
109 TestCase(8, "0,0,2"); | |
OLD | NEW |