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

Side by Side Diff: test/cctest/test-debug.cc

Issue 5184007: Add more tests of breaks in infinite loops... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 1 month 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/full-codegen.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 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-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 6882 matching lines...) Expand 10 before | Expand all | Expand 10 after
6893 CHECK_EQ(2, TestClientData::constructor_call_counter); 6893 CHECK_EQ(2, TestClientData::constructor_call_counter);
6894 CHECK_EQ(TestClientData::constructor_call_counter, 6894 CHECK_EQ(TestClientData::constructor_call_counter,
6895 TestClientData::destructor_call_counter); 6895 TestClientData::destructor_call_counter);
6896 6896
6897 v8::Debug::SetDebugEventListener(NULL); 6897 v8::Debug::SetDebugEventListener(NULL);
6898 CheckDebuggerUnloaded(); 6898 CheckDebuggerUnloaded();
6899 } 6899 }
6900 6900
6901 6901
6902 // Test that setting the terminate execution flag during debug break processing. 6902 // Test that setting the terminate execution flag during debug break processing.
6903 static void TestDebugBreakInLoop(const char* loop_head,
6904 const char** loop_bodies,
6905 const char* loop_tail) {
6906 // Receive 100 breaks for each test and then terminate JavaScript execution.
6907 static int count = 0;
6908
6909 for (int i = 0; loop_bodies[i] != NULL; i++) {
6910 count++;
6911 max_break_point_hit_count = count * 100;
6912 terminate_after_max_break_point_hit = true;
6913
6914 EmbeddedVector<char, 1024> buffer;
6915 OS::SNPrintF(buffer,
6916 "function f() {%s%s%s}",
6917 loop_head, loop_bodies[i], loop_tail);
6918
6919 // Function with infinite loop.
6920 CompileRun(buffer.start());
6921
6922 // Set the debug break to enter the debugger as soon as possible.
6923 v8::Debug::DebugBreak();
6924
6925 // Call function with infinite loop.
6926 CompileRun("f();");
6927 CHECK_EQ(count * 100, break_point_hit_count);
6928
6929 CHECK(!v8::V8::IsExecutionTerminating());
6930 }
6931 }
6932
6933
6903 TEST(DebugBreakLoop) { 6934 TEST(DebugBreakLoop) {
6904 v8::HandleScope scope; 6935 v8::HandleScope scope;
6905 DebugLocalContext env; 6936 DebugLocalContext env;
6906 6937
6907 // Receive 100 breaks and terminate.
6908 max_break_point_hit_count = 100;
6909 terminate_after_max_break_point_hit = true;
6910
6911 // Register a debug event listener which sets the break flag and counts. 6938 // Register a debug event listener which sets the break flag and counts.
6912 v8::Debug::SetDebugEventListener(DebugEventBreakMax); 6939 v8::Debug::SetDebugEventListener(DebugEventBreakMax);
6913 6940
6914 // Function with infinite loop. 6941 CompileRun("var a = 1;");
6915 CompileRun("function f() { while (true) { } }"); 6942 CompileRun("function g() { }");
6943 CompileRun("function h() { }");
6916 6944
6917 // Set the debug break to enter the debugger as soon as possible. 6945 const char* loop_bodies[] = {
6918 v8::Debug::DebugBreak(); 6946 "",
6947 "g()",
6948 "if (a == 0) { g() }",
6949 "if (a == 1) { g() }",
6950 "if (a == 0) { g() } else { h() }",
6951 "if (a == 0) { continue }",
6952 "if (a == 1) { continue }",
6953 "switch (a) { case 1: g(); }",
6954 "switch (a) { case 1: continue; }",
6955 "switch (a) { case 1: g(); break; default: h() }",
6956 "switch (a) { case 1: continue; break; default: h() }",
6957 NULL
6958 };
6919 6959
6920 // Call function with infinite loop. 6960 TestDebugBreakInLoop("while (true) {", loop_bodies, "}");
6921 CompileRun("f();"); 6961 TestDebugBreakInLoop("while (a == 1) {", loop_bodies, "}");
6922 CHECK_EQ(100, break_point_hit_count); 6962
6963 TestDebugBreakInLoop("do {", loop_bodies, "} while (true)");
6964 TestDebugBreakInLoop("do {", loop_bodies, "} while (a == 1)");
6965
6966 TestDebugBreakInLoop("for (;;) {", loop_bodies, "}");
6967 TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}");
6923 6968
6924 // Get rid of the debug event listener. 6969 // Get rid of the debug event listener.
6925 v8::Debug::SetDebugEventListener(NULL); 6970 v8::Debug::SetDebugEventListener(NULL);
6926 CheckDebuggerUnloaded(); 6971 CheckDebuggerUnloaded();
6927 } 6972 }
6928 6973
6929 6974
6930 #endif // ENABLE_DEBUGGER_SUPPORT 6975 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « src/full-codegen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698