Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(838)

Side by Side Diff: test/mjsunit/debug-evaluate-recursive.js

Issue 242034: Redo "running" field in debug-delay.js and support "suspend" command (Closed)
Patch Set: do not remove body from backtrace Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/debug-evaluate.js ('k') | test/mjsunit/debug-handle.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 26 matching lines...) Expand all
37 37
38 function safeEval(code) { 38 function safeEval(code) {
39 try { 39 try {
40 return eval('(' + code + ')'); 40 return eval('(' + code + ')');
41 } catch (e) { 41 } catch (e) {
42 assertEquals(void 0, e); 42 assertEquals(void 0, e);
43 return undefined; 43 return undefined;
44 } 44 }
45 } 45 }
46 46
47 function testRequest(dcp, arguments, success, result) { 47 function testRequest(exec_state, arguments, success, result) {
48 // Get the debug command processor in paused state.
49 var dcp = exec_state.debugCommandProcessor(false);
50
48 // Generate request with the supplied arguments. 51 // Generate request with the supplied arguments.
49 var request; 52 var request;
50 if (arguments) { 53 if (arguments) {
51 request = '{' + base_request + ',"arguments":' + arguments + '}'; 54 request = '{' + base_request + ',"arguments":' + arguments + '}';
52 } else { 55 } else {
53 request = '{' + base_request + '}' 56 request = '{' + base_request + '}'
54 } 57 }
55 var response = safeEval(dcp.processDebugJSONRequest(request)); 58 var response = safeEval(dcp.processDebugJSONRequest(request));
56 if (success) { 59 if (success) {
57 assertTrue(response.success, request + ' -> ' + response.message); 60 assertTrue(response.success, request + ' -> ' + response.message);
58 assertEquals(result, response.body.value); 61 assertEquals(result, response.body.value);
59 } else { 62 } else {
60 assertFalse(response.success, request + ' -> ' + response.message); 63 assertFalse(response.success, request + ' -> ' + response.message);
61 } 64 }
62 assertFalse(response.running, request + ' -> expected not running'); 65 assertFalse(response.running, request + ' -> expected not running');
63 } 66 }
64 67
65 68
66 // Event listener which evaluates with break disabled. 69 // Event listener which evaluates with break disabled.
67 function listener(event, exec_state, event_data, data) { 70 function listener(event, exec_state, event_data, data) {
68 try { 71 try {
69 if (event == Debug.DebugEvent.Break) 72 if (event == Debug.DebugEvent.Break)
70 { 73 {
71 // Call functions with break using the FrameMirror directly. 74 // Call functions with break using the FrameMirror directly.
72 assertEquals(1, exec_state.evaluateGlobal('f()', true).value()); 75 assertEquals(1, exec_state.evaluateGlobal('f()', true).value());
73 assertEquals(2, exec_state.evaluateGlobal('g()', true).value()); 76 assertEquals(2, exec_state.evaluateGlobal('g()', true).value());
74 assertEquals(1, exec_state.frame(0).evaluate('f()', true).value()); 77 assertEquals(1, exec_state.frame(0).evaluate('f()', true).value());
75 assertEquals(2, exec_state.frame(0).evaluate('g()', true).value()); 78 assertEquals(2, exec_state.frame(0).evaluate('g()', true).value());
76 79
77 // Get the debug command processor.
78 var dcp = exec_state.debugCommandProcessor();
79
80 // Call functions with break using the JSON protocol. Tests that argument 80 // Call functions with break using the JSON protocol. Tests that argument
81 // disable_break is default true. 81 // disable_break is default true.
82 testRequest(dcp, '{"expression":"f()"}', true, 1); 82 testRequest(exec_state, '{"expression":"f()"}', true, 1);
83 testRequest(dcp, '{"expression":"f()","frame":0}', true, 1); 83 testRequest(exec_state, '{"expression":"f()","frame":0}', true, 1);
84 testRequest(dcp, '{"expression":"g()"}', true, 2); 84 testRequest(exec_state, '{"expression":"g()"}', true, 2);
85 testRequest(dcp, '{"expression":"g()","frame":0}', true, 2); 85 testRequest(exec_state, '{"expression":"g()","frame":0}', true, 2);
86 86
87 // Call functions with break using the JSON protocol. Tests passing 87 // Call functions with break using the JSON protocol. Tests passing
88 // argument disable_break is default true. 88 // argument disable_break is default true.
89 testRequest(dcp, '{"expression":"f()","disable_break":true}', true, 1); 89 testRequest(exec_state, '{"expression":"f()","disable_break":true}', true, 1);
90 testRequest(dcp, '{"expression":"f()","frame":0,"disable_break":true}', 90 testRequest(exec_state, '{"expression":"f()","frame":0,"disable_break":tru e}',
91 true, 1); 91 true, 1);
92 testRequest(dcp, '{"expression":"g()","disable_break":true}', true, 2); 92 testRequest(exec_state, '{"expression":"g()","disable_break":true}', true, 2);
93 testRequest(dcp, '{"expression":"g()","frame":0,"disable_break":true}', 93 testRequest(exec_state, '{"expression":"g()","frame":0,"disable_break":tru e}',
94 true, 2); 94 true, 2);
95 95
96 // Indicate that all was processed. 96 // Indicate that all was processed.
97 listenerComplete = true; 97 listenerComplete = true;
98 } 98 }
99 } catch (e) { 99 } catch (e) {
100 exception = e 100 exception = e
101 }; 101 };
102 }; 102 };
103 103
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 function g() { 139 function g() {
140 debugger; 140 debugger;
141 return 2; 141 return 2;
142 }; 142 };
143 143
144 Debug.setBreakPoint(f, 2, 0); 144 Debug.setBreakPoint(f, 2, 0);
145 145
146 // Cause a debug break event. 146 // Cause a debug break event.
147 debugger; 147 debugger;
148 148
149 assertFalse(exception, "exception in listener")
149 // Make sure that the debug event listener vas invoked. 150 // Make sure that the debug event listener vas invoked.
150 assertTrue(listenerComplete); 151 assertTrue(listenerComplete);
151 assertFalse(exception, "exception in listener")
152 152
153 // Remove the debug event listener. 153 // Remove the debug event listener.
154 Debug.setListener(null); 154 Debug.setListener(null);
155 155
156 // Set debug event listener wich uses recursive breaks. 156 // Set debug event listener wich uses recursive breaks.
157 Debug.setListener(listener_recurse); 157 Debug.setListener(listener_recurse);
158 listenerComplete = false; 158 listenerComplete = false;
159 159
160 Debug.setBreakPoint(f, 2, 0); 160 Debug.setBreakPoint(f, 2, 0);
161 161
162 debugger; 162 debugger;
163 163
164 assertFalse(exception, "exception in listener")
164 // Make sure that the debug event listener vas invoked. 165 // Make sure that the debug event listener vas invoked.
165 assertTrue(listenerComplete); 166 assertTrue(listenerComplete);
166 assertFalse(exception, "exception in listener")
167 assertEquals(2, break_count); 167 assertEquals(2, break_count);
OLDNEW
« no previous file with comments | « test/mjsunit/debug-evaluate.js ('k') | test/mjsunit/debug-handle.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698