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

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

Issue 9625011: Set debug break slot at init of loop variable in a for loop. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 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
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 2727 matching lines...) Expand 10 before | Expand all | Expand 10 after
2738 v8::Handle<v8::Value> args[kArgc] = { a }; 2738 v8::Handle<v8::Value> args[kArgc] = { a };
2739 foo->Call(env->Global(), kArgc, args); 2739 foo->Call(env->Global(), kArgc, args);
2740 2740
2741 // Set up break point and step through the function. 2741 // Set up break point and step through the function.
2742 SetBreakPoint(foo, 3); 2742 SetBreakPoint(foo, 3);
2743 step_action = StepNext; 2743 step_action = StepNext;
2744 break_point_hit_count = 0; 2744 break_point_hit_count = 0;
2745 foo->Call(env->Global(), kArgc, args); 2745 foo->Call(env->Global(), kArgc, args);
2746 2746
2747 // With stepping all break locations are hit. 2747 // With stepping all break locations are hit.
2748 CHECK_EQ(33, break_point_hit_count); 2748 CHECK_EQ(34, break_point_hit_count);
Yang 2012/03/07 18:28:36 We have exactly one debug break more whenever a fo
2749 2749
2750 v8::Debug::SetDebugEventListener(NULL); 2750 v8::Debug::SetDebugEventListener(NULL);
2751 CheckDebuggerUnloaded(); 2751 CheckDebuggerUnloaded();
2752 } 2752 }
2753 2753
2754 2754
2755 // Test of the stepping mechanism for keyed store in a loop. 2755 // Test of the stepping mechanism for keyed store in a loop.
2756 TEST(DebugStepKeyedStoreLoop) { 2756 TEST(DebugStepKeyedStoreLoop) {
2757 v8::HandleScope scope; 2757 v8::HandleScope scope;
2758 DebugLocalContext env; 2758 DebugLocalContext env;
(...skipping 26 matching lines...) Expand all
2785 v8::Handle<v8::Value> args[kArgc] = { a }; 2785 v8::Handle<v8::Value> args[kArgc] = { a };
2786 foo->Call(env->Global(), kArgc, args); 2786 foo->Call(env->Global(), kArgc, args);
2787 2787
2788 // Set up break point and step through the function. 2788 // Set up break point and step through the function.
2789 SetBreakPoint(foo, 3); 2789 SetBreakPoint(foo, 3);
2790 step_action = StepNext; 2790 step_action = StepNext;
2791 break_point_hit_count = 0; 2791 break_point_hit_count = 0;
2792 foo->Call(env->Global(), kArgc, args); 2792 foo->Call(env->Global(), kArgc, args);
2793 2793
2794 // With stepping all break locations are hit. 2794 // With stepping all break locations are hit.
2795 CHECK_EQ(32, break_point_hit_count); 2795 CHECK_EQ(33, break_point_hit_count);
2796 2796
2797 v8::Debug::SetDebugEventListener(NULL); 2797 v8::Debug::SetDebugEventListener(NULL);
2798 CheckDebuggerUnloaded(); 2798 CheckDebuggerUnloaded();
2799 } 2799 }
2800 2800
2801 2801
2802 // Test of the stepping mechanism for named load in a loop. 2802 // Test of the stepping mechanism for named load in a loop.
2803 TEST(DebugStepNamedLoadLoop) { 2803 TEST(DebugStepNamedLoadLoop) {
2804 v8::HandleScope scope; 2804 v8::HandleScope scope;
2805 DebugLocalContext env; 2805 DebugLocalContext env;
(...skipping 23 matching lines...) Expand all
2829 // Call function without any break points to ensure inlining is in place. 2829 // Call function without any break points to ensure inlining is in place.
2830 foo->Call(env->Global(), 0, NULL); 2830 foo->Call(env->Global(), 0, NULL);
2831 2831
2832 // Set up break point and step through the function. 2832 // Set up break point and step through the function.
2833 SetBreakPoint(foo, 4); 2833 SetBreakPoint(foo, 4);
2834 step_action = StepNext; 2834 step_action = StepNext;
2835 break_point_hit_count = 0; 2835 break_point_hit_count = 0;
2836 foo->Call(env->Global(), 0, NULL); 2836 foo->Call(env->Global(), 0, NULL);
2837 2837
2838 // With stepping all break locations are hit. 2838 // With stepping all break locations are hit.
2839 CHECK_EQ(53, break_point_hit_count); 2839 CHECK_EQ(54, break_point_hit_count);
2840 2840
2841 v8::Debug::SetDebugEventListener(NULL); 2841 v8::Debug::SetDebugEventListener(NULL);
2842 CheckDebuggerUnloaded(); 2842 CheckDebuggerUnloaded();
2843 } 2843 }
2844 2844
2845 2845
2846 static void DoDebugStepNamedStoreLoop(int expected) { 2846 static void DoDebugStepNamedStoreLoop(int expected) {
2847 v8::HandleScope scope; 2847 v8::HandleScope scope;
2848 DebugLocalContext env; 2848 DebugLocalContext env;
2849 2849
(...skipping 23 matching lines...) Expand all
2873 // With stepping all expected break locations are hit. 2873 // With stepping all expected break locations are hit.
2874 CHECK_EQ(expected, break_point_hit_count); 2874 CHECK_EQ(expected, break_point_hit_count);
2875 2875
2876 v8::Debug::SetDebugEventListener(NULL); 2876 v8::Debug::SetDebugEventListener(NULL);
2877 CheckDebuggerUnloaded(); 2877 CheckDebuggerUnloaded();
2878 } 2878 }
2879 2879
2880 2880
2881 // Test of the stepping mechanism for named load in a loop. 2881 // Test of the stepping mechanism for named load in a loop.
2882 TEST(DebugStepNamedStoreLoop) { 2882 TEST(DebugStepNamedStoreLoop) {
2883 DoDebugStepNamedStoreLoop(22); 2883 DoDebugStepNamedStoreLoop(23);
2884 } 2884 }
2885 2885
2886 2886
2887 // Test the stepping mechanism with different ICs. 2887 // Test the stepping mechanism with different ICs.
2888 TEST(DebugStepLinearMixedICs) { 2888 TEST(DebugStepLinearMixedICs) {
2889 v8::HandleScope scope; 2889 v8::HandleScope scope;
2890 DebugLocalContext env; 2890 DebugLocalContext env;
2891 2891
2892 // Register a debug event listener which steps and counts. 2892 // Register a debug event listener which steps and counts.
2893 v8::Debug::SetDebugEventListener(DebugEventStep); 2893 v8::Debug::SetDebugEventListener(DebugEventStep);
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
3245 SetBreakPoint(foo, 8); // "var a = 0;" 3245 SetBreakPoint(foo, 8); // "var a = 0;"
3246 3246
3247 // Each loop generates 4 or 5 steps depending on whether a is equal. 3247 // Each loop generates 4 or 5 steps depending on whether a is equal.
3248 3248
3249 // Looping 10 times. 3249 // Looping 10 times.
3250 step_action = StepIn; 3250 step_action = StepIn;
3251 break_point_hit_count = 0; 3251 break_point_hit_count = 0;
3252 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) }; 3252 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
3253 result = foo->Call(env->Global(), argc, argv_10); 3253 result = foo->Call(env->Global(), argc, argv_10);
3254 CHECK_EQ(5, result->Int32Value()); 3254 CHECK_EQ(5, result->Int32Value());
3255 CHECK_EQ(50, break_point_hit_count); 3255 CHECK_EQ(51, break_point_hit_count);
3256 3256
3257 // Looping 100 times. 3257 // Looping 100 times.
3258 step_action = StepIn; 3258 step_action = StepIn;
3259 break_point_hit_count = 0; 3259 break_point_hit_count = 0;
3260 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) }; 3260 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
3261 result = foo->Call(env->Global(), argc, argv_100); 3261 result = foo->Call(env->Global(), argc, argv_100);
3262 CHECK_EQ(50, result->Int32Value()); 3262 CHECK_EQ(50, result->Int32Value());
3263 CHECK_EQ(455, break_point_hit_count); 3263 CHECK_EQ(456, break_point_hit_count);
3264 3264
3265 // Get rid of the debug event listener. 3265 // Get rid of the debug event listener.
3266 v8::Debug::SetDebugEventListener(NULL); 3266 v8::Debug::SetDebugEventListener(NULL);
3267 CheckDebuggerUnloaded(); 3267 CheckDebuggerUnloaded();
3268 } 3268 }
3269 3269
3270 3270
3271 TEST(DebugStepForBreak) { 3271 TEST(DebugStepForBreak) {
3272 v8::HandleScope scope; 3272 v8::HandleScope scope;
3273 DebugLocalContext env; 3273 DebugLocalContext env;
(...skipping 23 matching lines...) Expand all
3297 3297
3298 // Each loop generates 5 steps except for the last (when break is executed) 3298 // Each loop generates 5 steps except for the last (when break is executed)
3299 // which only generates 4. 3299 // which only generates 4.
3300 3300
3301 // Looping 10 times. 3301 // Looping 10 times.
3302 step_action = StepIn; 3302 step_action = StepIn;
3303 break_point_hit_count = 0; 3303 break_point_hit_count = 0;
3304 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) }; 3304 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
3305 result = foo->Call(env->Global(), argc, argv_10); 3305 result = foo->Call(env->Global(), argc, argv_10);
3306 CHECK_EQ(9, result->Int32Value()); 3306 CHECK_EQ(9, result->Int32Value());
3307 CHECK_EQ(53, break_point_hit_count); 3307 CHECK_EQ(54, break_point_hit_count);
3308 3308
3309 // Looping 100 times. 3309 // Looping 100 times.
3310 step_action = StepIn; 3310 step_action = StepIn;
3311 break_point_hit_count = 0; 3311 break_point_hit_count = 0;
3312 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) }; 3312 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
3313 result = foo->Call(env->Global(), argc, argv_100); 3313 result = foo->Call(env->Global(), argc, argv_100);
3314 CHECK_EQ(99, result->Int32Value()); 3314 CHECK_EQ(99, result->Int32Value());
3315 CHECK_EQ(503, break_point_hit_count); 3315 CHECK_EQ(504, break_point_hit_count);
3316 3316
3317 // Get rid of the debug event listener. 3317 // Get rid of the debug event listener.
3318 v8::Debug::SetDebugEventListener(NULL); 3318 v8::Debug::SetDebugEventListener(NULL);
3319 CheckDebuggerUnloaded(); 3319 CheckDebuggerUnloaded();
3320 } 3320 }
3321 3321
3322 3322
3323 TEST(DebugStepForIn) { 3323 TEST(DebugStepForIn) {
3324 v8::HandleScope scope; 3324 v8::HandleScope scope;
3325 DebugLocalContext env; 3325 DebugLocalContext env;
(...skipping 4015 matching lines...) Expand 10 before | Expand all | Expand 10 after
7341 "g(false); \n" 7341 "g(false); \n"
7342 "%OptimizeFunctionOnNextCall(g); \n" 7342 "%OptimizeFunctionOnNextCall(g); \n"
7343 "g(true);"; 7343 "g(true);";
7344 v8::Debug::SetDebugEventListener(DebugBreakInlineListener); 7344 v8::Debug::SetDebugEventListener(DebugBreakInlineListener);
7345 inline_script = v8::Script::Compile(v8::String::New(source)); 7345 inline_script = v8::Script::Compile(v8::String::New(source));
7346 inline_script->Run(); 7346 inline_script->Run();
7347 } 7347 }
7348 7348
7349 7349
7350 #endif // ENABLE_DEBUGGER_SUPPORT 7350 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698