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

Side by Side Diff: test/mjsunit/debug-liveedit-double-call.js

Issue 10637003: Correctly support several consecutive stack modifications. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: follow codereview Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/liveedit.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 12 matching lines...) Expand all
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 30
31 Debug = debug.Debug 31 Debug = debug.Debug
32 32
33 function FindCallFrame(exec_state, frame_code) {
34 var number = Number(frame_code);
35 if (number >= 0) {
36 return exec_state.frame(number);
37 } else {
38 for (var i = 0; i < exec_state.frameCount(); i++) {
39 var frame = exec_state.frame(i);
40 var func_mirror = frame.func();
41 if (frame_code == func_mirror.name()) {
42 return frame;
43 }
44 }
45 }
46 throw new Error("Failed to find function name " + function_name);
47 }
48 33
49 function TestCase(test_scenario, expected_output) { 34 function TestCase(test_scenario, expected_output) {
50 // Global variable, accessed from eval'd script. 35 // Global variable, accessed from eval'd script.
51 test_output = ""; 36 test_output = "";
52 37
53 function TestCode() { 38 var script_text_generator = (function() {
54 function A() { 39 var variables = { a: 1, b: 1, c: 1, d: 1, e: 1, f: 1 };
55 // Extra stack variable. To make function not slim. 40
56 // Restarter doesn't work on slim function when stopped on 'debugger' 41 return {
57 // statement. (There is no padding for 'debugger' statement). 42 get: function() {
58 var o = {}; 43 return "(function() {\n " +
59 test_output += 'A'; 44 " function A() {\n " +
60 test_output += '='; 45 " test_output += 'a' + " + variables.a + ";\n " +
61 debugger; 46 " test_output += '=';\n " +
62 return 'Capybara'; 47 " debugger;\n " +
63 } 48 " return 'Capybara';\n " +
64 function B(p1, p2) { 49 " }\n " +
65 test_output += 'B'; 50 " function B(p1, p2) {\n " +
66 return A(); 51 " test_output += 'b' + " + variables.b + ";\n " +
67 } 52 " return A();\n " +
68 function C() { 53 " }\n " +
69 test_output += 'C'; 54 " function C() {\n " +
70 // Function call with argument adaptor is intentional. 55 " test_output += 'c' + " + variables.c + ";\n " +
71 return B(); 56 " // Function call with argument adaptor is intentional.\n " +
72 } 57 " return B();\n " +
73 function D() { 58 " }\n " +
74 test_output += 'D'; 59 " function D() {\n " +
75 // Function call with argument adaptor is intentional. 60 " test_output += 'd' + " + variables.d + ";\n " +
76 return C(1, 2); 61 " // Function call with argument adaptor is intentional.\n " +
77 } 62 " return C(1, 2);\n " +
78 function E() { 63 " }\n " +
79 test_output += 'E'; 64 " function E() {\n " +
80 return D(); 65 " test_output += 'e' + " + variables.e + ";\n " +
81 } 66 " return D();\n " +
82 function F() { 67 " }\n " +
83 test_output += 'F'; 68 " function F() {\n " +
84 return E(); 69 " test_output += 'f' + " + variables.f + ";\n " +
85 } 70 " return E();\n " +
86 return F(); 71 " }\n " +
87 } 72 " return F();\n " +
73 "})\n";
74 },
75 change: function(var_name) {
76 variables[var_name]++;
77 }
78 };
79 })();
80
81 var test_fun = eval(script_text_generator.get());
82
83 var script = Debug.findScript(test_fun);
88 84
89 var scenario_pos = 0; 85 var scenario_pos = 0;
90 86
91 function DebuggerStatementHandler(exec_state) { 87 function DebuggerStatementHandler() {
92 while (true) { 88 while (true) {
93 assertTrue(scenario_pos < test_scenario.length); 89 assertTrue(scenario_pos < test_scenario.length);
94 var change_code = test_scenario[scenario_pos++]; 90 var change_var = test_scenario[scenario_pos++];
95 if (change_code == '=') { 91 if (change_var == '=') {
96 // Continue. 92 // Continue.
97 return; 93 return;
98 } 94 }
99 var frame = FindCallFrame(exec_state, change_code); 95 script_text_generator.change(change_var);
100 // Throws if fails. 96 try {
101 Debug.LiveEdit.RestartFrame(frame); 97 Debug.LiveEdit.SetScriptSource(script, script_text_generator.get(),
98 false, []);
99 } catch (e) {
100 print("LiveEdit exception: " + e);
101 throw e;
102 }
102 } 103 }
103 } 104 }
104 105
105 var saved_exception = null; 106 var saved_exception = null;
106 107
107 function listener(event, exec_state, event_data, data) { 108 function listener(event, exec_state, event_data, data) {
108 if (saved_exception != null) {
109 return;
110 }
111 if (event == Debug.DebugEvent.Break) { 109 if (event == Debug.DebugEvent.Break) {
112 try { 110 try {
113 DebuggerStatementHandler(exec_state); 111 DebuggerStatementHandler();
114 } catch (e) { 112 } catch (e) {
115 saved_exception = e; 113 saved_exception = e;
116 } 114 }
117 } else { 115 } else {
118 print("Other: " + event); 116 print("Other: " + event);
119 } 117 }
120 } 118 }
121 119
122 Debug.setListener(listener); 120 Debug.setListener(listener);
123 assertEquals("Capybara", TestCode()); 121 assertEquals("Capybara", test_fun());
124 Debug.setListener(null); 122 Debug.setListener(null);
125 123
126 if (saved_exception) { 124 if (saved_exception) {
127 print("Exception: " + saved_exception); 125 print("Exception: " + saved_exception);
128 print("Stack: " + saved_exception.stack);
129 assertUnreachable(); 126 assertUnreachable();
130 } 127 }
131 128
132 print(test_output); 129 print(test_output);
133 130
134 assertEquals(expected_output, test_output); 131 assertEquals(expected_output, test_output);
135 } 132 }
136 133
137 TestCase('0==', "FEDCBA=A="); 134 TestCase(['='], "f1e1d1c1b1a1=");
138 TestCase('1==', "FEDCBA=BA=");
139 TestCase('2==', "FEDCBA=CBA=");
140 TestCase('3==', "FEDCBA=DCBA=");
141 TestCase('4==', "FEDCBA=EDCBA=");
142 TestCase('5==', "FEDCBA=FEDCBA=");
143 135
144 TestCase('=', "FEDCBA="); 136 TestCase(['c', '=', '='], "f1e1d1c1b1a1=c2b1a1=");
145 137
146 TestCase('C==', "FEDCBA=CBA="); 138 TestCase(['b', 'c', 'd', 'e', '=', '='], "f1e1d1c1b1a1=e2d2c2b2a1=");
147 139
148 TestCase('B=C=A=D==', "FEDCBA=BA=CBA=A=DCBA="); 140 TestCase(['b', 'c', '=', 'b', 'c', 'd', 'e', '=', '='], "f1e1d1c1b1a1=c2b2a1=e2d 2c3b3a1=");
149 141
150 // Successive restarts don't work now and require additional fix. 142 TestCase(['e', 'f', '=', '='], "f1e1d1c1b1a1=f2e2d1c1b1a1=");
151 //TestCase('BCDE==', "FEDCBA=EDCBA=");
152 //TestCase('BC=BCDE==', "FEDCBA=CBA=EDCBA=");
153 //TestCase('EF==', "FEDCBA=FEDCBA=");
OLDNEW
« no previous file with comments | « src/liveedit.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698