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

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

Issue 4405003: Add a test for debug break while running in an infinite loop... (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/debug.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 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 895
896 // Set the break flag again to come back here as soon as possible. 896 // Set the break flag again to come back here as soon as possible.
897 v8::Debug::DebugBreak(); 897 v8::Debug::DebugBreak();
898 } 898 }
899 } 899 }
900 900
901 901
902 // Debug event handler which re-issues a debug break until a limit has been 902 // Debug event handler which re-issues a debug break until a limit has been
903 // reached. 903 // reached.
904 int max_break_point_hit_count = 0; 904 int max_break_point_hit_count = 0;
905 bool terminate_after_max_break_point_hit = false;
905 static void DebugEventBreakMax(v8::DebugEvent event, 906 static void DebugEventBreakMax(v8::DebugEvent event,
906 v8::Handle<v8::Object> exec_state, 907 v8::Handle<v8::Object> exec_state,
907 v8::Handle<v8::Object> event_data, 908 v8::Handle<v8::Object> event_data,
908 v8::Handle<v8::Value> data) { 909 v8::Handle<v8::Value> data) {
909 // When hitting a debug event listener there must be a break set. 910 // When hitting a debug event listener there must be a break set.
910 CHECK_NE(v8::internal::Debug::break_id(), 0); 911 CHECK_NE(v8::internal::Debug::break_id(), 0);
911 912
912 if (event == v8::Break && break_point_hit_count < max_break_point_hit_count) { 913 if (event == v8::Break) {
913 // Count the number of breaks. 914 if (break_point_hit_count < max_break_point_hit_count) {
914 break_point_hit_count++; 915 // Count the number of breaks.
916 break_point_hit_count++;
915 917
916 // Set the break flag again to come back here as soon as possible. 918 // Set the break flag again to come back here as soon as possible.
917 v8::Debug::DebugBreak(); 919 v8::Debug::DebugBreak();
920 } else if (terminate_after_max_break_point_hit) {
921 // Terminate execution after the last break if requested.
922 v8::V8::TerminateExecution();
923 }
918 } 924 }
919 } 925 }
920 926
921 927
922 // --- M e s s a g e C a l l b a c k 928 // --- M e s s a g e C a l l b a c k
923 929
924 930
925 // Message callback which counts the number of messages. 931 // Message callback which counts the number of messages.
926 int message_callback_count = 0; 932 int message_callback_count = 0;
927 933
(...skipping 5957 matching lines...) Expand 10 before | Expand all | Expand 10 after
6885 CHECK(was_debug_break_called); 6891 CHECK(was_debug_break_called);
6886 6892
6887 CHECK_EQ(2, TestClientData::constructor_call_counter); 6893 CHECK_EQ(2, TestClientData::constructor_call_counter);
6888 CHECK_EQ(TestClientData::constructor_call_counter, 6894 CHECK_EQ(TestClientData::constructor_call_counter,
6889 TestClientData::destructor_call_counter); 6895 TestClientData::destructor_call_counter);
6890 6896
6891 v8::Debug::SetDebugEventListener(NULL); 6897 v8::Debug::SetDebugEventListener(NULL);
6892 CheckDebuggerUnloaded(); 6898 CheckDebuggerUnloaded();
6893 } 6899 }
6894 6900
6901
6902 // Test that setting the terminate execution flag during debug break processing.
6903 TEST(DebugBreakLoop) {
6904 v8::HandleScope scope;
6905 DebugLocalContext env;
6906
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.
6912 v8::Debug::SetDebugEventListener(DebugEventBreakMax);
6913
6914 // Function with infinite loop.
6915 CompileRun("function f() { while (true) { } }");
6916
6917 // Set the debug break to enter the debugger as soon as possible.
6918 v8::Debug::DebugBreak();
6919
6920 // Call function with infinite loop.
6921 CompileRun("f();");
6922 CHECK_EQ(100, break_point_hit_count);
6923
6924 // Get rid of the debug event listener.
6925 v8::Debug::SetDebugEventListener(NULL);
6926 CheckDebuggerUnloaded();
6927 }
6928
6929
6895 #endif // ENABLE_DEBUGGER_SUPPORT 6930 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « src/debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698