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 14 matching lines...) Expand all Loading... |
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 // The functions used for testing backtraces. They are at the top to make the | 29 // The functions used for testing backtraces. They are at the top to make the |
30 // testing of source line/column easier. | 30 // testing of source line/column easier. |
31 function f(x, y) { | 31 function f(x, y) { |
32 a=1; | 32 a=1; |
33 }; | 33 }; |
34 | 34 |
| 35 var m = function() { |
| 36 new f(1); |
| 37 }; |
| 38 |
35 function g() { | 39 function g() { |
36 new f(1); | 40 m(); |
37 }; | 41 }; |
38 | 42 |
39 | 43 |
40 // Get the Debug object exposed from the debug context global object. | 44 // Get the Debug object exposed from the debug context global object. |
41 Debug = debug.Debug | 45 Debug = debug.Debug |
42 | 46 |
43 listenerCalled = false; | 47 listenerCalled = false; |
44 exception = false; | 48 exception = false; |
45 | 49 |
46 | 50 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 var backtrace; | 87 var backtrace; |
84 var frame; | 88 var frame; |
85 var source; | 89 var source; |
86 | 90 |
87 // Get the debug command processor. | 91 // Get the debug command processor. |
88 var dcp = exec_state.debugCommandProcessor(); | 92 var dcp = exec_state.debugCommandProcessor(); |
89 | 93 |
90 // Get the backtrace. | 94 // Get the backtrace. |
91 var json; | 95 var json; |
92 json = '{"seq":0,"type":"request","command":"backtrace"}' | 96 json = '{"seq":0,"type":"request","command":"backtrace"}' |
93 response = new ParsedResponse(dcp.processDebugJSONRequest(json)); | 97 var resp = dcp.processDebugJSONRequest(json); |
| 98 response = new ParsedResponse(resp); |
94 backtrace = response.body(); | 99 backtrace = response.body(); |
95 assertEquals(0, backtrace.fromFrame); | 100 assertEquals(0, backtrace.fromFrame); |
96 assertEquals(3, backtrace.toFrame); | 101 assertEquals(4, backtrace.toFrame); |
97 assertEquals(3, backtrace.totalFrames); | 102 assertEquals(4, backtrace.totalFrames); |
98 var frames = backtrace.frames; | 103 var frames = backtrace.frames; |
99 assertEquals(3, frames.length); | 104 assertEquals(4, frames.length); |
100 for (var i = 0; i < frames.length; i++) { | 105 for (var i = 0; i < frames.length; i++) { |
101 assertEquals('frame', frames[i].type); | 106 assertEquals('frame', frames[i].type); |
102 } | 107 } |
103 assertEquals(0, frames[0].index); | 108 assertEquals(0, frames[0].index); |
104 assertEquals("f", response.lookup(frames[0].func.ref).name); | 109 assertEquals("f", response.lookup(frames[0].func.ref).name); |
105 assertEquals(1, frames[1].index); | 110 assertEquals(1, frames[1].index); |
106 assertEquals("g", response.lookup(frames[1].func.ref).name); | 111 assertEquals("", response.lookup(frames[1].func.ref).name); |
| 112 assertEquals("m", response.lookup(frames[1].func.ref).inferredName); |
107 assertEquals(2, frames[2].index); | 113 assertEquals(2, frames[2].index); |
108 assertEquals("", response.lookup(frames[2].func.ref).name); | 114 assertEquals("g", response.lookup(frames[2].func.ref).name); |
| 115 assertEquals(3, frames[3].index); |
| 116 assertEquals("", response.lookup(frames[3].func.ref).name); |
109 | 117 |
110 // Get backtrace with two frames. | 118 // Get backtrace with two frames. |
111 json = '{"seq":0,"type":"request","command":"backtrace","arguments":{"fromFr
ame":1,"toFrame":3}}' | 119 json = '{"seq":0,"type":"request","command":"backtrace","arguments":{"fromFr
ame":1,"toFrame":3}}' |
112 response = new ParsedResponse(dcp.processDebugJSONRequest(json)); | 120 response = new ParsedResponse(dcp.processDebugJSONRequest(json)); |
113 backtrace = response.body(); | 121 backtrace = response.body(); |
114 assertEquals(1, backtrace.fromFrame); | 122 assertEquals(1, backtrace.fromFrame); |
115 assertEquals(3, backtrace.toFrame); | 123 assertEquals(3, backtrace.toFrame); |
116 assertEquals(3, backtrace.totalFrames); | 124 assertEquals(4, backtrace.totalFrames); |
117 var frames = backtrace.frames; | 125 var frames = backtrace.frames; |
118 assertEquals(2, frames.length); | 126 assertEquals(2, frames.length); |
119 for (var i = 0; i < frames.length; i++) { | 127 for (var i = 0; i < frames.length; i++) { |
120 assertEquals('frame', frames[i].type); | 128 assertEquals('frame', frames[i].type); |
121 } | 129 } |
122 assertEquals(1, frames[0].index); | 130 assertEquals(1, frames[0].index); |
123 assertEquals("g", response.lookup(frames[0].func.ref).name); | 131 assertEquals("", response.lookup(frames[0].func.ref).name); |
| 132 assertEquals("m", response.lookup(frames[0].func.ref).inferredName); |
124 assertEquals(2, frames[1].index); | 133 assertEquals(2, frames[1].index); |
125 assertEquals("", response.lookup(frames[1].func.ref).name); | 134 assertEquals("g", response.lookup(frames[1].func.ref).name); |
126 | 135 |
127 // Get the individual frames. | 136 // Get the individual frames. |
128 json = '{"seq":0,"type":"request","command":"frame"}' | 137 json = '{"seq":0,"type":"request","command":"frame"}' |
129 response = new ParsedResponse(dcp.processDebugJSONRequest(json)); | 138 response = new ParsedResponse(dcp.processDebugJSONRequest(json)); |
130 frame = response.body(); | 139 frame = response.body(); |
131 assertEquals(0, frame.index); | 140 assertEquals(0, frame.index); |
132 assertEquals("f", response.lookup(frame.func.ref).name); | 141 assertEquals("f", response.lookup(frame.func.ref).name); |
133 assertTrue(frame.constructCall); | 142 assertTrue(frame.constructCall); |
134 assertEquals(31, frame.line); | 143 assertEquals(31, frame.line); |
135 assertEquals(3, frame.column); | 144 assertEquals(3, frame.column); |
(...skipping 15 matching lines...) Expand all Loading... |
151 assertEquals('x', frame.arguments[0].name); | 160 assertEquals('x', frame.arguments[0].name); |
152 assertEquals('number', response.lookup(frame.arguments[0].value.ref).type); | 161 assertEquals('number', response.lookup(frame.arguments[0].value.ref).type); |
153 assertEquals(1, response.lookup(frame.arguments[0].value.ref).value); | 162 assertEquals(1, response.lookup(frame.arguments[0].value.ref).value); |
154 assertEquals('y', frame.arguments[1].name); | 163 assertEquals('y', frame.arguments[1].name); |
155 assertEquals('undefined', response.lookup(frame.arguments[1].value.ref).type
); | 164 assertEquals('undefined', response.lookup(frame.arguments[1].value.ref).type
); |
156 | 165 |
157 json = '{"seq":0,"type":"request","command":"frame","arguments":{"number":1}
}' | 166 json = '{"seq":0,"type":"request","command":"frame","arguments":{"number":1}
}' |
158 response = new ParsedResponse(dcp.processDebugJSONRequest(json)); | 167 response = new ParsedResponse(dcp.processDebugJSONRequest(json)); |
159 frame = response.body(); | 168 frame = response.body(); |
160 assertEquals(1, frame.index); | 169 assertEquals(1, frame.index); |
161 assertEquals("g", response.lookup(frame.func.ref).name); | 170 assertEquals("", response.lookup(frame.func.ref).name); |
| 171 assertEquals("m", response.lookup(frame.func.ref).inferredName); |
162 assertFalse(frame.constructCall); | 172 assertFalse(frame.constructCall); |
163 assertEquals(35, frame.line); | 173 assertEquals(35, frame.line); |
164 assertEquals(2, frame.column); | 174 assertEquals(2, frame.column); |
165 assertEquals(0, frame.arguments.length); | 175 assertEquals(0, frame.arguments.length); |
166 | 176 |
167 json = '{"seq":0,"type":"request","command":"frame","arguments":{"number":2}
}' | 177 json = '{"seq":0,"type":"request","command":"frame","arguments":{"number":3}
}' |
168 response = new ParsedResponse(dcp.processDebugJSONRequest(json)); | 178 response = new ParsedResponse(dcp.processDebugJSONRequest(json)); |
169 frame = response.body(); | 179 frame = response.body(); |
170 assertEquals(2, frame.index); | 180 assertEquals(3, frame.index); |
171 assertEquals("", response.lookup(frame.func.ref).name); | 181 assertEquals("", response.lookup(frame.func.ref).name); |
172 | 182 |
173 // Source slices for the individual frames (they all refer to this script). | 183 // Source slices for the individual frames (they all refer to this script). |
174 json = '{"seq":0,"type":"request","command":"source",' + | 184 json = '{"seq":0,"type":"request","command":"source",' + |
175 '"arguments":{"frame":0,"fromLine":30,"toLine":32}}' | 185 '"arguments":{"frame":0,"fromLine":30,"toLine":32}}' |
176 response = new ParsedResponse(dcp.processDebugJSONRequest(json)); | 186 response = new ParsedResponse(dcp.processDebugJSONRequest(json)); |
177 source = response.body(); | 187 source = response.body(); |
178 assertEquals("function f(x, y) {", source.source.substring(0, 18)); | 188 assertEquals("function f(x, y) {", source.source.substring(0, 18)); |
179 assertEquals(30, source.fromLine); | 189 assertEquals(30, source.fromLine); |
180 assertEquals(32, source.toLine); | 190 assertEquals(32, source.toLine); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 Debug.setListener(listener); | 228 Debug.setListener(listener); |
219 | 229 |
220 // Set a break point and call to invoke the debug event listener. | 230 // Set a break point and call to invoke the debug event listener. |
221 Debug.setBreakPoint(f, 0, 0); | 231 Debug.setBreakPoint(f, 0, 0); |
222 g(); | 232 g(); |
223 | 233 |
224 // Make sure that the debug event listener vas invoked. | 234 // Make sure that the debug event listener vas invoked. |
225 assertFalse(exception, "exception in listener"); | 235 assertFalse(exception, "exception in listener"); |
226 assertTrue(listenerCalled); | 236 assertTrue(listenerCalled); |
227 | 237 |
OLD | NEW |