| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 } | 96 } |
| 97 break; | 97 break; |
| 98 default: | 98 default: |
| 99 fail("Unexpected"); | 99 fail("Unexpected"); |
| 100 } | 100 } |
| 101 exec_state.prepareStep(Debug.StepAction.StepIn, 1); | 101 exec_state.prepareStep(Debug.StepAction.StepIn, 1); |
| 102 } else { | 102 } else { |
| 103 // Position at the end of the function. | 103 // Position at the end of the function. |
| 104 assertEquals(debugger_source_position + 50, | 104 assertEquals(debugger_source_position + 50, |
| 105 exec_state.frame(0).sourcePosition()); | 105 exec_state.frame(0).sourcePosition()); |
| 106 | 106 |
| 107 // Just about to return from the function. | 107 // Just about to return from the function. |
| 108 assertTrue(exec_state.frame(0).isAtReturn()) | 108 assertTrue(exec_state.frame(0).isAtReturn()) |
| 109 assertEquals(expected_return_value, | 109 assertEquals(expected_return_value, |
| 110 exec_state.frame(0).returnValue().value()); | 110 exec_state.frame(0).returnValue().value()); |
| 111 | 111 |
| 112 // Check the same using the JSON commands. | 112 // Check the same using the JSON commands. |
| 113 var dcp = exec_state.debugCommandProcessor(false); | 113 var dcp = exec_state.debugCommandProcessor(false); |
| 114 var request = '{"seq":0,"type":"request","command":"backtrace"}'; | 114 var request = '{"seq":0,"type":"request","command":"backtrace"}'; |
| 115 var resp = dcp.processDebugJSONRequest(request); | 115 var resp = dcp.processDebugJSONRequest(request); |
| 116 response = new ParsedResponse(resp); | 116 response = new ParsedResponse(resp); |
| 117 frames = response.body().frames; | 117 frames = response.body().frames; |
| 118 assertTrue(frames[0].atReturn); | 118 assertTrue(frames[0].atReturn); |
| 119 assertEquals(expected_return_value, | 119 assertEquals(expected_return_value, |
| 120 response.lookup(frames[0].returnValue.ref).value); | 120 response.lookup(frames[0].returnValue.ref).value); |
| 121 | 121 |
| 122 listener_complete = true; | 122 listener_complete = true; |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 } catch (e) { | 125 } catch (e) { |
| 126 exception = e | 126 exception = e |
| 127 }; | 127 }; |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 // Add the debug event listener. | 130 // Add the debug event listener. |
| 131 Debug.setListener(listener); | 131 Debug.setListener(listener); |
| 132 | 132 |
| 133 // Four steps from the debugger statement in this function will position us at | 133 // Four steps from the debugger statement in this function will position us at |
| 134 // the function return. | 134 // the function return. |
| 135 // 0 1 2 3 4 5 | 135 // 0 1 2 3 4 5 |
| 136 // 0123456789012345678901234567890123456789012345678901 | 136 // 0123456789012345678901234567890123456789012345678901 |
| 137 | 137 |
| 138 function f(x) {debugger; if (x) { return 1; } else { return 2; } }; | 138 function f(x) {debugger; if (x) { return 1; } else { return 2; } }; |
| 139 | 139 |
| 140 // Call f expecting different return values. | 140 // Call f expecting different return values. |
| 141 break_count = 0; | 141 break_count = 0; |
| 142 expected_return_value = 2; | 142 expected_return_value = 2; |
| 143 listener_complete = false; | 143 listener_complete = false; |
| 144 f(); | 144 f(); |
| 145 assertFalse(exception, "exception in listener") | 145 assertFalse(exception, "exception in listener") |
| 146 assertTrue(listener_complete); | 146 assertTrue(listener_complete); |
| 147 assertEquals(4, break_count); | 147 assertEquals(4, break_count); |
| 148 | 148 |
| 149 break_count = 0; | 149 break_count = 0; |
| 150 expected_return_value = 1; | 150 expected_return_value = 1; |
| 151 listener_complete = false; | 151 listener_complete = false; |
| 152 f(true); | 152 f(true); |
| 153 assertFalse(exception, "exception in listener") | 153 assertFalse(exception, "exception in listener") |
| 154 assertTrue(listener_complete); | 154 assertTrue(listener_complete); |
| 155 assertEquals(4, break_count); | 155 assertEquals(4, break_count); |
| 156 | 156 |
| 157 break_count = 0; | 157 break_count = 0; |
| 158 expected_return_value = 2; | 158 expected_return_value = 2; |
| 159 listener_complete = false; | 159 listener_complete = false; |
| 160 f(false); | 160 f(false); |
| 161 assertFalse(exception, "exception in listener") | 161 assertFalse(exception, "exception in listener") |
| 162 assertTrue(listener_complete); | 162 assertTrue(listener_complete); |
| 163 assertEquals(4, break_count); | 163 assertEquals(4, break_count); |
| OLD | NEW |