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

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

Issue 713813002: Revert "Fix stepping in for-loops." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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/x87/full-codegen-x87.cc ('k') | test/mjsunit/debug-step.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2842 matching lines...) Expand 10 before | Expand all | Expand 10 after
2853 v8::Handle<v8::Value> args[kArgc] = { a }; 2853 v8::Handle<v8::Value> args[kArgc] = { a };
2854 foo->Call(env->Global(), kArgc, args); 2854 foo->Call(env->Global(), kArgc, args);
2855 2855
2856 // Set up break point and step through the function. 2856 // Set up break point and step through the function.
2857 SetBreakPoint(foo, 3); 2857 SetBreakPoint(foo, 3);
2858 step_action = StepNext; 2858 step_action = StepNext;
2859 break_point_hit_count = 0; 2859 break_point_hit_count = 0;
2860 foo->Call(env->Global(), kArgc, args); 2860 foo->Call(env->Global(), kArgc, args);
2861 2861
2862 // With stepping all break locations are hit. 2862 // With stepping all break locations are hit.
2863 CHECK_EQ(45, break_point_hit_count); 2863 CHECK_EQ(35, break_point_hit_count);
2864 2864
2865 v8::Debug::SetDebugEventListener(NULL); 2865 v8::Debug::SetDebugEventListener(NULL);
2866 CheckDebuggerUnloaded(); 2866 CheckDebuggerUnloaded();
2867 } 2867 }
2868 2868
2869 2869
2870 // Test of the stepping mechanism for keyed store in a loop. 2870 // Test of the stepping mechanism for keyed store in a loop.
2871 TEST(DebugStepKeyedStoreLoop) { 2871 TEST(DebugStepKeyedStoreLoop) {
2872 DebugLocalContext env; 2872 DebugLocalContext env;
2873 v8::HandleScope scope(env->GetIsolate()); 2873 v8::HandleScope scope(env->GetIsolate());
(...skipping 27 matching lines...) Expand all
2901 v8::Handle<v8::Value> args[kArgc] = { a }; 2901 v8::Handle<v8::Value> args[kArgc] = { a };
2902 foo->Call(env->Global(), kArgc, args); 2902 foo->Call(env->Global(), kArgc, args);
2903 2903
2904 // Set up break point and step through the function. 2904 // Set up break point and step through the function.
2905 SetBreakPoint(foo, 3); 2905 SetBreakPoint(foo, 3);
2906 step_action = StepNext; 2906 step_action = StepNext;
2907 break_point_hit_count = 0; 2907 break_point_hit_count = 0;
2908 foo->Call(env->Global(), kArgc, args); 2908 foo->Call(env->Global(), kArgc, args);
2909 2909
2910 // With stepping all break locations are hit. 2910 // With stepping all break locations are hit.
2911 CHECK_EQ(44, break_point_hit_count); 2911 CHECK_EQ(34, break_point_hit_count);
2912 2912
2913 v8::Debug::SetDebugEventListener(NULL); 2913 v8::Debug::SetDebugEventListener(NULL);
2914 CheckDebuggerUnloaded(); 2914 CheckDebuggerUnloaded();
2915 } 2915 }
2916 2916
2917 2917
2918 // Test of the stepping mechanism for named load in a loop. 2918 // Test of the stepping mechanism for named load in a loop.
2919 TEST(DebugStepNamedLoadLoop) { 2919 TEST(DebugStepNamedLoadLoop) {
2920 DebugLocalContext env; 2920 DebugLocalContext env;
2921 v8::HandleScope scope(env->GetIsolate()); 2921 v8::HandleScope scope(env->GetIsolate());
(...skipping 23 matching lines...) Expand all
2945 // Call function without any break points to ensure inlining is in place. 2945 // Call function without any break points to ensure inlining is in place.
2946 foo->Call(env->Global(), 0, NULL); 2946 foo->Call(env->Global(), 0, NULL);
2947 2947
2948 // Set up break point and step through the function. 2948 // Set up break point and step through the function.
2949 SetBreakPoint(foo, 4); 2949 SetBreakPoint(foo, 4);
2950 step_action = StepNext; 2950 step_action = StepNext;
2951 break_point_hit_count = 0; 2951 break_point_hit_count = 0;
2952 foo->Call(env->Global(), 0, NULL); 2952 foo->Call(env->Global(), 0, NULL);
2953 2953
2954 // With stepping all break locations are hit. 2954 // With stepping all break locations are hit.
2955 CHECK_EQ(65, break_point_hit_count); 2955 CHECK_EQ(55, break_point_hit_count);
2956 2956
2957 v8::Debug::SetDebugEventListener(NULL); 2957 v8::Debug::SetDebugEventListener(NULL);
2958 CheckDebuggerUnloaded(); 2958 CheckDebuggerUnloaded();
2959 } 2959 }
2960 2960
2961 2961
2962 static void DoDebugStepNamedStoreLoop(int expected) { 2962 static void DoDebugStepNamedStoreLoop(int expected) {
2963 DebugLocalContext env; 2963 DebugLocalContext env;
2964 v8::HandleScope scope(env->GetIsolate()); 2964 v8::HandleScope scope(env->GetIsolate());
2965 2965
(...skipping 22 matching lines...) Expand all
2988 2988
2989 // With stepping all expected break locations are hit. 2989 // With stepping all expected break locations are hit.
2990 CHECK_EQ(expected, break_point_hit_count); 2990 CHECK_EQ(expected, break_point_hit_count);
2991 2991
2992 v8::Debug::SetDebugEventListener(NULL); 2992 v8::Debug::SetDebugEventListener(NULL);
2993 CheckDebuggerUnloaded(); 2993 CheckDebuggerUnloaded();
2994 } 2994 }
2995 2995
2996 2996
2997 // Test of the stepping mechanism for named load in a loop. 2997 // Test of the stepping mechanism for named load in a loop.
2998 TEST(DebugStepNamedStoreLoop) { DoDebugStepNamedStoreLoop(34); } 2998 TEST(DebugStepNamedStoreLoop) {
2999 DoDebugStepNamedStoreLoop(24);
3000 }
2999 3001
3000 3002
3001 // Test the stepping mechanism with different ICs. 3003 // Test the stepping mechanism with different ICs.
3002 TEST(DebugStepLinearMixedICs) { 3004 TEST(DebugStepLinearMixedICs) {
3003 DebugLocalContext env; 3005 DebugLocalContext env;
3004 v8::HandleScope scope(env->GetIsolate()); 3006 v8::HandleScope scope(env->GetIsolate());
3005 3007
3006 // Register a debug event listener which steps and counts. 3008 // Register a debug event listener which steps and counts.
3007 v8::Debug::SetDebugEventListener(DebugEventStep); 3009 v8::Debug::SetDebugEventListener(DebugEventStep);
3008 3010
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
3321 "a=0; b=0; i=0; foo()"; 3323 "a=0; b=0; i=0; foo()";
3322 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3324 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3323 3325
3324 SetBreakPoint(foo, 8); // "a = 1;" 3326 SetBreakPoint(foo, 8); // "a = 1;"
3325 3327
3326 // Looping 10 times. 3328 // Looping 10 times.
3327 step_action = StepIn; 3329 step_action = StepIn;
3328 break_point_hit_count = 0; 3330 break_point_hit_count = 0;
3329 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) }; 3331 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
3330 foo->Call(env->Global(), argc, argv_10); 3332 foo->Call(env->Global(), argc, argv_10);
3331 CHECK_EQ(45, break_point_hit_count); 3333 CHECK_EQ(23, break_point_hit_count);
3332 3334
3333 // Looping 100 times. 3335 // Looping 100 times.
3334 step_action = StepIn; 3336 step_action = StepIn;
3335 break_point_hit_count = 0; 3337 break_point_hit_count = 0;
3336 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) }; 3338 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
3337 foo->Call(env->Global(), argc, argv_100); 3339 foo->Call(env->Global(), argc, argv_100);
3338 CHECK_EQ(405, break_point_hit_count); 3340 CHECK_EQ(203, break_point_hit_count);
3339 3341
3340 // Get rid of the debug event listener. 3342 // Get rid of the debug event listener.
3341 v8::Debug::SetDebugEventListener(NULL); 3343 v8::Debug::SetDebugEventListener(NULL);
3342 CheckDebuggerUnloaded(); 3344 CheckDebuggerUnloaded();
3343 } 3345 }
3344 3346
3345 3347
3346 TEST(DebugStepForContinue) { 3348 TEST(DebugStepForContinue) {
3347 DebugLocalContext env; 3349 DebugLocalContext env;
3348 v8::Isolate* isolate = env->GetIsolate(); 3350 v8::Isolate* isolate = env->GetIsolate();
(...skipping 23 matching lines...) Expand all
3372 SetBreakPoint(foo, 8); // "var a = 0;" 3374 SetBreakPoint(foo, 8); // "var a = 0;"
3373 3375
3374 // Each loop generates 4 or 5 steps depending on whether a is equal. 3376 // Each loop generates 4 or 5 steps depending on whether a is equal.
3375 3377
3376 // Looping 10 times. 3378 // Looping 10 times.
3377 step_action = StepIn; 3379 step_action = StepIn;
3378 break_point_hit_count = 0; 3380 break_point_hit_count = 0;
3379 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) }; 3381 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
3380 result = foo->Call(env->Global(), argc, argv_10); 3382 result = foo->Call(env->Global(), argc, argv_10);
3381 CHECK_EQ(5, result->Int32Value()); 3383 CHECK_EQ(5, result->Int32Value());
3382 CHECK_EQ(62, break_point_hit_count); 3384 CHECK_EQ(52, break_point_hit_count);
3383 3385
3384 // Looping 100 times. 3386 // Looping 100 times.
3385 step_action = StepIn; 3387 step_action = StepIn;
3386 break_point_hit_count = 0; 3388 break_point_hit_count = 0;
3387 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) }; 3389 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
3388 result = foo->Call(env->Global(), argc, argv_100); 3390 result = foo->Call(env->Global(), argc, argv_100);
3389 CHECK_EQ(50, result->Int32Value()); 3391 CHECK_EQ(50, result->Int32Value());
3390 CHECK_EQ(557, break_point_hit_count); 3392 CHECK_EQ(457, break_point_hit_count);
3391 3393
3392 // Get rid of the debug event listener. 3394 // Get rid of the debug event listener.
3393 v8::Debug::SetDebugEventListener(NULL); 3395 v8::Debug::SetDebugEventListener(NULL);
3394 CheckDebuggerUnloaded(); 3396 CheckDebuggerUnloaded();
3395 } 3397 }
3396 3398
3397 3399
3398 TEST(DebugStepForBreak) { 3400 TEST(DebugStepForBreak) {
3399 DebugLocalContext env; 3401 DebugLocalContext env;
3400 v8::Isolate* isolate = env->GetIsolate(); 3402 v8::Isolate* isolate = env->GetIsolate();
(...skipping 24 matching lines...) Expand all
3425 3427
3426 // Each loop generates 5 steps except for the last (when break is executed) 3428 // Each loop generates 5 steps except for the last (when break is executed)
3427 // which only generates 4. 3429 // which only generates 4.
3428 3430
3429 // Looping 10 times. 3431 // Looping 10 times.
3430 step_action = StepIn; 3432 step_action = StepIn;
3431 break_point_hit_count = 0; 3433 break_point_hit_count = 0;
3432 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) }; 3434 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
3433 result = foo->Call(env->Global(), argc, argv_10); 3435 result = foo->Call(env->Global(), argc, argv_10);
3434 CHECK_EQ(9, result->Int32Value()); 3436 CHECK_EQ(9, result->Int32Value());
3435 CHECK_EQ(64, break_point_hit_count); 3437 CHECK_EQ(55, break_point_hit_count);
3436 3438
3437 // Looping 100 times. 3439 // Looping 100 times.
3438 step_action = StepIn; 3440 step_action = StepIn;
3439 break_point_hit_count = 0; 3441 break_point_hit_count = 0;
3440 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) }; 3442 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
3441 result = foo->Call(env->Global(), argc, argv_100); 3443 result = foo->Call(env->Global(), argc, argv_100);
3442 CHECK_EQ(99, result->Int32Value()); 3444 CHECK_EQ(99, result->Int32Value());
3443 CHECK_EQ(604, break_point_hit_count); 3445 CHECK_EQ(505, break_point_hit_count);
3444 3446
3445 // Get rid of the debug event listener. 3447 // Get rid of the debug event listener.
3446 v8::Debug::SetDebugEventListener(NULL); 3448 v8::Debug::SetDebugEventListener(NULL);
3447 CheckDebuggerUnloaded(); 3449 CheckDebuggerUnloaded();
3448 } 3450 }
3449 3451
3450 3452
3451 TEST(DebugStepForIn) { 3453 TEST(DebugStepForIn) {
3452 DebugLocalContext env; 3454 DebugLocalContext env;
3453 v8::HandleScope scope(env->GetIsolate()); 3455 v8::HandleScope scope(env->GetIsolate());
(...skipping 10 matching lines...) Expand all
3464 " b = 0;" 3466 " b = 0;"
3465 " }" 3467 " }"
3466 "}" 3468 "}"
3467 "foo()"; 3469 "foo()";
3468 foo = CompileFunction(&env, src_1, "foo"); 3470 foo = CompileFunction(&env, src_1, "foo");
3469 SetBreakPoint(foo, 0); // "var a = ..." 3471 SetBreakPoint(foo, 0); // "var a = ..."
3470 3472
3471 step_action = StepIn; 3473 step_action = StepIn;
3472 break_point_hit_count = 0; 3474 break_point_hit_count = 0;
3473 foo->Call(env->Global(), 0, NULL); 3475 foo->Call(env->Global(), 0, NULL);
3474 CHECK_EQ(7, break_point_hit_count); 3476 CHECK_EQ(6, break_point_hit_count);
3475 3477
3476 // Create a function for testing stepping. Run it to allow it to get 3478 // Create a function for testing stepping. Run it to allow it to get
3477 // optimized. 3479 // optimized.
3478 const char* src_2 = "function foo() { " 3480 const char* src_2 = "function foo() { "
3479 " var a = {a:[1, 2, 3]};" 3481 " var a = {a:[1, 2, 3]};"
3480 " for (x in a.a) {" 3482 " for (x in a.a) {"
3481 " b = 0;" 3483 " b = 0;"
3482 " }" 3484 " }"
3483 "}" 3485 "}"
3484 "foo()"; 3486 "foo()";
3485 foo = CompileFunction(&env, src_2, "foo"); 3487 foo = CompileFunction(&env, src_2, "foo");
3486 SetBreakPoint(foo, 0); // "var a = ..." 3488 SetBreakPoint(foo, 0); // "var a = ..."
3487 3489
3488 step_action = StepIn; 3490 step_action = StepIn;
3489 break_point_hit_count = 0; 3491 break_point_hit_count = 0;
3490 foo->Call(env->Global(), 0, NULL); 3492 foo->Call(env->Global(), 0, NULL);
3491 CHECK_EQ(9, break_point_hit_count); 3493 CHECK_EQ(8, break_point_hit_count);
3492 3494
3493 // Get rid of the debug event listener. 3495 // Get rid of the debug event listener.
3494 v8::Debug::SetDebugEventListener(NULL); 3496 v8::Debug::SetDebugEventListener(NULL);
3495 CheckDebuggerUnloaded(); 3497 CheckDebuggerUnloaded();
3496 } 3498 }
3497 3499
3498 3500
3499 TEST(DebugStepWith) { 3501 TEST(DebugStepWith) {
3500 DebugLocalContext env; 3502 DebugLocalContext env;
3501 v8::HandleScope scope(env->GetIsolate()); 3503 v8::HandleScope scope(env->GetIsolate());
(...skipping 4109 matching lines...) Expand 10 before | Expand all | Expand 10 after
7611 "var obj = {};" 7613 "var obj = {};"
7612 "var callbackRan = false;" 7614 "var callbackRan = false;"
7613 "Object.observe(obj, function() {" 7615 "Object.observe(obj, function() {"
7614 " callbackRan = true;" 7616 " callbackRan = true;"
7615 " throw Error('foo');" 7617 " throw Error('foo');"
7616 "});" 7618 "});"
7617 "obj.prop = 1"); 7619 "obj.prop = 1");
7618 CHECK(CompileRun("callbackRan")->BooleanValue()); 7620 CHECK(CompileRun("callbackRan")->BooleanValue());
7619 CHECK_EQ(1, exception_event_counter); 7621 CHECK_EQ(1, exception_event_counter);
7620 } 7622 }
OLDNEW
« no previous file with comments | « src/x87/full-codegen-x87.cc ('k') | test/mjsunit/debug-step.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698