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

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

Issue 3167037: Fix a bug in the handling of debug break in CallIC... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 4 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/x64/debug-x64.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 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 862
863 // Perform a garbage collection when break point is hit and continue. Based 863 // Perform a garbage collection when break point is hit and continue. Based
864 // on the number of break points hit either scavenge or mark compact 864 // on the number of break points hit either scavenge or mark compact
865 // collector is used. 865 // collector is used.
866 if (event == v8::Break) { 866 if (event == v8::Break) {
867 break_point_hit_count++; 867 break_point_hit_count++;
868 if (break_point_hit_count % 2 == 0) { 868 if (break_point_hit_count % 2 == 0) {
869 // Scavenge. 869 // Scavenge.
870 Heap::CollectGarbage(0, v8::internal::NEW_SPACE); 870 Heap::CollectGarbage(0, v8::internal::NEW_SPACE);
871 } else { 871 } else {
872 // Mark sweep (and perhaps compact). 872 // Mark sweep compact.
873 Heap::CollectAllGarbage(false); 873 Heap::CollectAllGarbage(true);
874 } 874 }
875 } 875 }
876 } 876 }
877 877
878 878
879 // Debug event handler which re-issues a debug break and calls the garbage 879 // Debug event handler which re-issues a debug break and calls the garbage
880 // collector to have the heap verified. 880 // collector to have the heap verified.
881 static void DebugEventBreak(v8::DebugEvent event, 881 static void DebugEventBreak(v8::DebugEvent event,
882 v8::Handle<v8::Object> exec_state, 882 v8::Handle<v8::Object> exec_state,
883 v8::Handle<v8::Object> event_data, 883 v8::Handle<v8::Object> event_data,
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 v8::Undefined()); 1120 v8::Undefined());
1121 v8::Script::Compile(v8::String::New("function bar(){}"))->Run(); 1121 v8::Script::Compile(v8::String::New("function bar(){}"))->Run();
1122 v8::Script::Compile(v8::String::New("function foo(){bar();}"))->Run(); 1122 v8::Script::Compile(v8::String::New("function foo(){bar();}"))->Run();
1123 v8::Local<v8::Function> foo = 1123 v8::Local<v8::Function> foo =
1124 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo"))); 1124 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
1125 1125
1126 // Run without breakpoints. 1126 // Run without breakpoints.
1127 foo->Call(env->Global(), 0, NULL); 1127 foo->Call(env->Global(), 0, NULL);
1128 CHECK_EQ(0, break_point_hit_count); 1128 CHECK_EQ(0, break_point_hit_count);
1129 1129
1130 // Run with breakpoint 1130 // Run with breakpoint.
1131 int bp = SetBreakPoint(foo, 0); 1131 int bp = SetBreakPoint(foo, 0);
1132 foo->Call(env->Global(), 0, NULL); 1132 foo->Call(env->Global(), 0, NULL);
1133 CHECK_EQ(1, break_point_hit_count); 1133 CHECK_EQ(1, break_point_hit_count);
1134 foo->Call(env->Global(), 0, NULL); 1134 foo->Call(env->Global(), 0, NULL);
1135 CHECK_EQ(2, break_point_hit_count); 1135 CHECK_EQ(2, break_point_hit_count);
1136 1136
1137 // Run without breakpoints. 1137 // Run without breakpoints.
1138 ClearBreakPoint(bp); 1138 ClearBreakPoint(bp);
1139 foo->Call(env->Global(), 0, NULL); 1139 foo->Call(env->Global(), 0, NULL);
1140 CHECK_EQ(2, break_point_hit_count); 1140 CHECK_EQ(2, break_point_hit_count);
1141 1141
1142 v8::Debug::SetDebugEventListener(NULL); 1142 v8::Debug::SetDebugEventListener(NULL);
1143 CheckDebuggerUnloaded(); 1143 CheckDebuggerUnloaded();
1144 } 1144 }
1145 1145
1146 1146
1147 // Test that a break point can be set at an IC call location and survive a GC.
1148 TEST(BreakPointICCallWithGC) {
1149 break_point_hit_count = 0;
1150 v8::HandleScope scope;
1151 DebugLocalContext env;
1152 v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage,
1153 v8::Undefined());
1154 v8::Script::Compile(v8::String::New("function bar(){return 1;}"))->Run();
1155 v8::Script::Compile(v8::String::New("function foo(){return bar();}"))->Run();
1156 v8::Local<v8::Function> foo =
1157 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
1158
1159 // Run without breakpoints.
1160 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value());
1161 CHECK_EQ(0, break_point_hit_count);
1162
1163 // Run with breakpoint.
1164 int bp = SetBreakPoint(foo, 0);
1165 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value());
1166 CHECK_EQ(1, break_point_hit_count);
1167 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value());
1168 CHECK_EQ(2, break_point_hit_count);
1169
1170 // Run without breakpoints.
1171 ClearBreakPoint(bp);
1172 foo->Call(env->Global(), 0, NULL);
1173 CHECK_EQ(2, break_point_hit_count);
1174
1175 v8::Debug::SetDebugEventListener(NULL);
1176 CheckDebuggerUnloaded();
1177 }
1178
1179
1147 // Test that a break point can be set at a return store location. 1180 // Test that a break point can be set at a return store location.
1148 TEST(BreakPointReturn) { 1181 TEST(BreakPointReturn) {
1149 break_point_hit_count = 0; 1182 break_point_hit_count = 0;
1150 v8::HandleScope scope; 1183 v8::HandleScope scope;
1151 DebugLocalContext env; 1184 DebugLocalContext env;
1152 1185
1153 // Create a functions for checking the source line and column when hitting 1186 // Create a functions for checking the source line and column when hitting
1154 // a break point. 1187 // a break point.
1155 frame_source_line = CompileFunction(&env, 1188 frame_source_line = CompileFunction(&env,
1156 frame_source_line_source, 1189 frame_source_line_source,
(...skipping 5647 matching lines...) Expand 10 before | Expand all | Expand 10 after
6804 6837
6805 CHECK_EQ(2, TestClientData::constructor_call_counter); 6838 CHECK_EQ(2, TestClientData::constructor_call_counter);
6806 CHECK_EQ(TestClientData::constructor_call_counter, 6839 CHECK_EQ(TestClientData::constructor_call_counter,
6807 TestClientData::destructor_call_counter); 6840 TestClientData::destructor_call_counter);
6808 6841
6809 v8::Debug::SetDebugEventListener(NULL); 6842 v8::Debug::SetDebugEventListener(NULL);
6810 CheckDebuggerUnloaded(); 6843 CheckDebuggerUnloaded();
6811 } 6844 }
6812 6845
6813 #endif // ENABLE_DEBUGGER_SUPPORT 6846 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « src/x64/debug-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698