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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/liveedit.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/debug-liveedit-double-call.js
diff --git a/test/mjsunit/debug-liveedit-restart-frame.js b/test/mjsunit/debug-liveedit-double-call.js
similarity index 51%
copy from test/mjsunit/debug-liveedit-restart-frame.js
copy to test/mjsunit/debug-liveedit-double-call.js
index d978a9709fb0f7d394b9377d93b65c1fba1109c4..1df806ab75c8c7b13ec83695fbbe11cfe3fbfdd9 100644
--- a/test/mjsunit/debug-liveedit-restart-frame.js
+++ b/test/mjsunit/debug-liveedit-double-call.js
@@ -30,87 +30,85 @@
Debug = debug.Debug
-function FindCallFrame(exec_state, frame_code) {
- var number = Number(frame_code);
- if (number >= 0) {
- return exec_state.frame(number);
- } else {
- for (var i = 0; i < exec_state.frameCount(); i++) {
- var frame = exec_state.frame(i);
- var func_mirror = frame.func();
- if (frame_code == func_mirror.name()) {
- return frame;
- }
- }
- }
- throw new Error("Failed to find function name " + function_name);
-}
function TestCase(test_scenario, expected_output) {
// Global variable, accessed from eval'd script.
test_output = "";
- function TestCode() {
- function A() {
- // Extra stack variable. To make function not slim.
- // Restarter doesn't work on slim function when stopped on 'debugger'
- // statement. (There is no padding for 'debugger' statement).
- var o = {};
- test_output += 'A';
- test_output += '=';
- debugger;
- return 'Capybara';
- }
- function B(p1, p2) {
- test_output += 'B';
- return A();
- }
- function C() {
- test_output += 'C';
- // Function call with argument adaptor is intentional.
- return B();
- }
- function D() {
- test_output += 'D';
- // Function call with argument adaptor is intentional.
- return C(1, 2);
- }
- function E() {
- test_output += 'E';
- return D();
- }
- function F() {
- test_output += 'F';
- return E();
- }
- return F();
- }
+ var script_text_generator = (function() {
+ var variables = { a: 1, b: 1, c: 1, d: 1, e: 1, f: 1 };
+
+ return {
+ get: function() {
+ return "(function() {\n " +
+ " function A() {\n " +
+ " test_output += 'a' + " + variables.a + ";\n " +
+ " test_output += '=';\n " +
+ " debugger;\n " +
+ " return 'Capybara';\n " +
+ " }\n " +
+ " function B(p1, p2) {\n " +
+ " test_output += 'b' + " + variables.b + ";\n " +
+ " return A();\n " +
+ " }\n " +
+ " function C() {\n " +
+ " test_output += 'c' + " + variables.c + ";\n " +
+ " // Function call with argument adaptor is intentional.\n " +
+ " return B();\n " +
+ " }\n " +
+ " function D() {\n " +
+ " test_output += 'd' + " + variables.d + ";\n " +
+ " // Function call with argument adaptor is intentional.\n " +
+ " return C(1, 2);\n " +
+ " }\n " +
+ " function E() {\n " +
+ " test_output += 'e' + " + variables.e + ";\n " +
+ " return D();\n " +
+ " }\n " +
+ " function F() {\n " +
+ " test_output += 'f' + " + variables.f + ";\n " +
+ " return E();\n " +
+ " }\n " +
+ " return F();\n " +
+ "})\n";
+ },
+ change: function(var_name) {
+ variables[var_name]++;
+ }
+ };
+ })();
+
+ var test_fun = eval(script_text_generator.get());
+
+ var script = Debug.findScript(test_fun);
var scenario_pos = 0;
- function DebuggerStatementHandler(exec_state) {
+ function DebuggerStatementHandler() {
while (true) {
assertTrue(scenario_pos < test_scenario.length);
- var change_code = test_scenario[scenario_pos++];
- if (change_code == '=') {
+ var change_var = test_scenario[scenario_pos++];
+ if (change_var == '=') {
// Continue.
return;
}
- var frame = FindCallFrame(exec_state, change_code);
- // Throws if fails.
- Debug.LiveEdit.RestartFrame(frame);
+ script_text_generator.change(change_var);
+ try {
+ Debug.LiveEdit.SetScriptSource(script, script_text_generator.get(),
+ false, []);
+ } catch (e) {
+ print("LiveEdit exception: " + e);
+ throw e;
+ }
}
}
var saved_exception = null;
function listener(event, exec_state, event_data, data) {
- if (saved_exception != null) {
- return;
- }
if (event == Debug.DebugEvent.Break) {
try {
- DebuggerStatementHandler(exec_state);
+ DebuggerStatementHandler();
} catch (e) {
saved_exception = e;
}
@@ -120,12 +118,11 @@ function TestCase(test_scenario, expected_output) {
}
Debug.setListener(listener);
- assertEquals("Capybara", TestCode());
+ assertEquals("Capybara", test_fun());
Debug.setListener(null);
if (saved_exception) {
print("Exception: " + saved_exception);
- print("Stack: " + saved_exception.stack);
assertUnreachable();
}
@@ -134,20 +131,12 @@ function TestCase(test_scenario, expected_output) {
assertEquals(expected_output, test_output);
}
-TestCase('0==', "FEDCBA=A=");
-TestCase('1==', "FEDCBA=BA=");
-TestCase('2==', "FEDCBA=CBA=");
-TestCase('3==', "FEDCBA=DCBA=");
-TestCase('4==', "FEDCBA=EDCBA=");
-TestCase('5==', "FEDCBA=FEDCBA=");
+TestCase(['='], "f1e1d1c1b1a1=");
-TestCase('=', "FEDCBA=");
+TestCase(['c', '=', '='], "f1e1d1c1b1a1=c2b1a1=");
-TestCase('C==', "FEDCBA=CBA=");
+TestCase(['b', 'c', 'd', 'e', '=', '='], "f1e1d1c1b1a1=e2d2c2b2a1=");
-TestCase('B=C=A=D==', "FEDCBA=BA=CBA=A=DCBA=");
+TestCase(['b', 'c', '=', 'b', 'c', 'd', 'e', '=', '='], "f1e1d1c1b1a1=c2b2a1=e2d2c3b3a1=");
-// Successive restarts don't work now and require additional fix.
-//TestCase('BCDE==', "FEDCBA=EDCBA=");
-//TestCase('BC=BCDE==', "FEDCBA=CBA=EDCBA=");
-//TestCase('EF==', "FEDCBA=FEDCBA=");
+TestCase(['e', 'f', '=', '='], "f1e1d1c1b1a1=f2e2d1c1b1a1=");
« 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