OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 11 matching lines...) Expand all Loading... |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
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 // Get the Debug object exposed from the debug context global object. | 29 // Get the Debug object exposed from the debug context global object. |
30 Debug = debug.Debug | 30 Debug = debug.Debug |
31 | 31 |
32 | |
33 function ParsedResponse(json) { | |
34 this.response_ = eval('(' + json + ')'); | |
35 this.refs_ = []; | |
36 if (this.response_.refs) { | |
37 for (var i = 0; i < this.response_.refs.length; i++) { | |
38 this.refs_[this.response_.refs[i].handle] = this.response_.refs[i]; | |
39 } | |
40 } | |
41 } | |
42 | |
43 | |
44 ParsedResponse.prototype.response = function() { | |
45 return this.response_; | |
46 } | |
47 | |
48 | |
49 ParsedResponse.prototype.body = function() { | |
50 return this.response_.body; | |
51 } | |
52 | |
53 | |
54 ParsedResponse.prototype.running = function() { | |
55 return this.response_.running; | |
56 } | |
57 | |
58 | |
59 ParsedResponse.prototype.lookup = function(handle) { | |
60 return this.refs_[handle]; | |
61 } | |
62 | |
63 | |
64 listener_complete = false; | 32 listener_complete = false; |
65 exception = false; | 33 exception = false; |
66 break_count = 0; | 34 break_count = 0; |
67 expected_return_value = 0; | 35 expected_return_value = 0; |
68 debugger_source_position = 0; | 36 debugger_source_position = 0; |
69 | 37 |
70 // Listener which expects to do four steps to reach returning from the function. | 38 // Listener which expects to do four steps to reach returning from the function. |
71 function listener(event, exec_state, event_data, data) { | 39 function listener(event, exec_state, event_data, data) { |
72 try { | 40 try { |
73 if (event == Debug.DebugEvent.Break) | 41 if (event == Debug.DebugEvent.Break) |
(...skipping 28 matching lines...) Expand all Loading... |
102 } else { | 70 } else { |
103 // Position at the end of the function. | 71 // Position at the end of the function. |
104 assertEquals(debugger_source_position + 50, | 72 assertEquals(debugger_source_position + 50, |
105 exec_state.frame(0).sourcePosition()); | 73 exec_state.frame(0).sourcePosition()); |
106 | 74 |
107 // Just about to return from the function. | 75 // Just about to return from the function. |
108 assertTrue(exec_state.frame(0).isAtReturn()) | 76 assertTrue(exec_state.frame(0).isAtReturn()) |
109 assertEquals(expected_return_value, | 77 assertEquals(expected_return_value, |
110 exec_state.frame(0).returnValue().value()); | 78 exec_state.frame(0).returnValue().value()); |
111 | 79 |
112 // Check the same using the JSON commands. | |
113 var dcp = exec_state.debugCommandProcessor(false); | |
114 var request = '{"seq":0,"type":"request","command":"backtrace"}'; | |
115 var resp = dcp.processDebugJSONRequest(request); | |
116 response = new ParsedResponse(resp); | |
117 frames = response.body().frames; | |
118 assertTrue(frames[0].atReturn); | |
119 assertEquals(expected_return_value, | |
120 response.lookup(frames[0].returnValue.ref).value); | |
121 | |
122 listener_complete = true; | 80 listener_complete = true; |
123 } | 81 } |
124 } | 82 } |
125 } catch (e) { | 83 } catch (e) { |
126 exception = e | 84 exception = e |
127 print(e + e.stack) | 85 print(e + e.stack) |
128 }; | 86 }; |
129 }; | 87 }; |
130 | 88 |
131 // Add the debug event listener. | 89 // Add the debug event listener. |
(...skipping 23 matching lines...) Expand all Loading... |
155 assertTrue(listener_complete); | 113 assertTrue(listener_complete); |
156 assertEquals(4, break_count); | 114 assertEquals(4, break_count); |
157 | 115 |
158 break_count = 0; | 116 break_count = 0; |
159 expected_return_value = 2; | 117 expected_return_value = 2; |
160 listener_complete = false; | 118 listener_complete = false; |
161 f(false); | 119 f(false); |
162 assertFalse(exception, "exception in listener") | 120 assertFalse(exception, "exception in listener") |
163 assertTrue(listener_complete); | 121 assertTrue(listener_complete); |
164 assertEquals(4, break_count); | 122 assertEquals(4, break_count); |
OLD | NEW |