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

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

Issue 682413004: 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(35, break_point_hit_count); 2863 CHECK_EQ(45, 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(34, break_point_hit_count); 2911 CHECK_EQ(44, 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(55, break_point_hit_count); 2955 CHECK_EQ(65, 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) { 2998 TEST(DebugStepNamedStoreLoop) { DoDebugStepNamedStoreLoop(34); }
2999 DoDebugStepNamedStoreLoop(24);
3000 }
3001 2999
3002 3000
3003 // Test the stepping mechanism with different ICs. 3001 // Test the stepping mechanism with different ICs.
3004 TEST(DebugStepLinearMixedICs) { 3002 TEST(DebugStepLinearMixedICs) {
3005 DebugLocalContext env; 3003 DebugLocalContext env;
3006 v8::HandleScope scope(env->GetIsolate()); 3004 v8::HandleScope scope(env->GetIsolate());
3007 3005
3008 // Register a debug event listener which steps and counts. 3006 // Register a debug event listener which steps and counts.
3009 v8::Debug::SetDebugEventListener(DebugEventStep); 3007 v8::Debug::SetDebugEventListener(DebugEventStep);
3010 3008
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
3323 "a=0; b=0; i=0; foo()"; 3321 "a=0; b=0; i=0; foo()";
3324 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3322 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3325 3323
3326 SetBreakPoint(foo, 8); // "a = 1;" 3324 SetBreakPoint(foo, 8); // "a = 1;"
3327 3325
3328 // Looping 10 times. 3326 // Looping 10 times.
3329 step_action = StepIn; 3327 step_action = StepIn;
3330 break_point_hit_count = 0; 3328 break_point_hit_count = 0;
3331 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) }; 3329 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
3332 foo->Call(env->Global(), argc, argv_10); 3330 foo->Call(env->Global(), argc, argv_10);
3333 CHECK_EQ(23, break_point_hit_count); 3331 CHECK_EQ(45, break_point_hit_count);
3334 3332
3335 // Looping 100 times. 3333 // Looping 100 times.
3336 step_action = StepIn; 3334 step_action = StepIn;
3337 break_point_hit_count = 0; 3335 break_point_hit_count = 0;
3338 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) }; 3336 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
3339 foo->Call(env->Global(), argc, argv_100); 3337 foo->Call(env->Global(), argc, argv_100);
3340 CHECK_EQ(203, break_point_hit_count); 3338 CHECK_EQ(405, break_point_hit_count);
3341 3339
3342 // Get rid of the debug event listener. 3340 // Get rid of the debug event listener.
3343 v8::Debug::SetDebugEventListener(NULL); 3341 v8::Debug::SetDebugEventListener(NULL);
3344 CheckDebuggerUnloaded(); 3342 CheckDebuggerUnloaded();
3345 } 3343 }
3346 3344
3347 3345
3348 TEST(DebugStepForContinue) { 3346 TEST(DebugStepForContinue) {
3349 DebugLocalContext env; 3347 DebugLocalContext env;
3350 v8::Isolate* isolate = env->GetIsolate(); 3348 v8::Isolate* isolate = env->GetIsolate();
(...skipping 23 matching lines...) Expand all
3374 SetBreakPoint(foo, 8); // "var a = 0;" 3372 SetBreakPoint(foo, 8); // "var a = 0;"
3375 3373
3376 // Each loop generates 4 or 5 steps depending on whether a is equal. 3374 // Each loop generates 4 or 5 steps depending on whether a is equal.
3377 3375
3378 // Looping 10 times. 3376 // Looping 10 times.
3379 step_action = StepIn; 3377 step_action = StepIn;
3380 break_point_hit_count = 0; 3378 break_point_hit_count = 0;
3381 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) }; 3379 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
3382 result = foo->Call(env->Global(), argc, argv_10); 3380 result = foo->Call(env->Global(), argc, argv_10);
3383 CHECK_EQ(5, result->Int32Value()); 3381 CHECK_EQ(5, result->Int32Value());
3384 CHECK_EQ(52, break_point_hit_count); 3382 CHECK_EQ(62, break_point_hit_count);
3385 3383
3386 // Looping 100 times. 3384 // Looping 100 times.
3387 step_action = StepIn; 3385 step_action = StepIn;
3388 break_point_hit_count = 0; 3386 break_point_hit_count = 0;
3389 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) }; 3387 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
3390 result = foo->Call(env->Global(), argc, argv_100); 3388 result = foo->Call(env->Global(), argc, argv_100);
3391 CHECK_EQ(50, result->Int32Value()); 3389 CHECK_EQ(50, result->Int32Value());
3392 CHECK_EQ(457, break_point_hit_count); 3390 CHECK_EQ(557, break_point_hit_count);
3393 3391
3394 // Get rid of the debug event listener. 3392 // Get rid of the debug event listener.
3395 v8::Debug::SetDebugEventListener(NULL); 3393 v8::Debug::SetDebugEventListener(NULL);
3396 CheckDebuggerUnloaded(); 3394 CheckDebuggerUnloaded();
3397 } 3395 }
3398 3396
3399 3397
3400 TEST(DebugStepForBreak) { 3398 TEST(DebugStepForBreak) {
3401 DebugLocalContext env; 3399 DebugLocalContext env;
3402 v8::Isolate* isolate = env->GetIsolate(); 3400 v8::Isolate* isolate = env->GetIsolate();
(...skipping 24 matching lines...) Expand all
3427 3425
3428 // Each loop generates 5 steps except for the last (when break is executed) 3426 // Each loop generates 5 steps except for the last (when break is executed)
3429 // which only generates 4. 3427 // which only generates 4.
3430 3428
3431 // Looping 10 times. 3429 // Looping 10 times.
3432 step_action = StepIn; 3430 step_action = StepIn;
3433 break_point_hit_count = 0; 3431 break_point_hit_count = 0;
3434 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) }; 3432 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
3435 result = foo->Call(env->Global(), argc, argv_10); 3433 result = foo->Call(env->Global(), argc, argv_10);
3436 CHECK_EQ(9, result->Int32Value()); 3434 CHECK_EQ(9, result->Int32Value());
3437 CHECK_EQ(55, break_point_hit_count); 3435 CHECK_EQ(64, break_point_hit_count);
3438 3436
3439 // Looping 100 times. 3437 // Looping 100 times.
3440 step_action = StepIn; 3438 step_action = StepIn;
3441 break_point_hit_count = 0; 3439 break_point_hit_count = 0;
3442 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) }; 3440 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
3443 result = foo->Call(env->Global(), argc, argv_100); 3441 result = foo->Call(env->Global(), argc, argv_100);
3444 CHECK_EQ(99, result->Int32Value()); 3442 CHECK_EQ(99, result->Int32Value());
3445 CHECK_EQ(505, break_point_hit_count); 3443 CHECK_EQ(604, break_point_hit_count);
3446 3444
3447 // Get rid of the debug event listener. 3445 // Get rid of the debug event listener.
3448 v8::Debug::SetDebugEventListener(NULL); 3446 v8::Debug::SetDebugEventListener(NULL);
3449 CheckDebuggerUnloaded(); 3447 CheckDebuggerUnloaded();
3450 } 3448 }
3451 3449
3452 3450
3453 TEST(DebugStepForIn) { 3451 TEST(DebugStepForIn) {
3454 DebugLocalContext env; 3452 DebugLocalContext env;
3455 v8::HandleScope scope(env->GetIsolate()); 3453 v8::HandleScope scope(env->GetIsolate());
(...skipping 10 matching lines...) Expand all
3466 " b = 0;" 3464 " b = 0;"
3467 " }" 3465 " }"
3468 "}" 3466 "}"
3469 "foo()"; 3467 "foo()";
3470 foo = CompileFunction(&env, src_1, "foo"); 3468 foo = CompileFunction(&env, src_1, "foo");
3471 SetBreakPoint(foo, 0); // "var a = ..." 3469 SetBreakPoint(foo, 0); // "var a = ..."
3472 3470
3473 step_action = StepIn; 3471 step_action = StepIn;
3474 break_point_hit_count = 0; 3472 break_point_hit_count = 0;
3475 foo->Call(env->Global(), 0, NULL); 3473 foo->Call(env->Global(), 0, NULL);
3476 CHECK_EQ(6, break_point_hit_count); 3474 CHECK_EQ(7, break_point_hit_count);
3477 3475
3478 // Create a function for testing stepping. Run it to allow it to get 3476 // Create a function for testing stepping. Run it to allow it to get
3479 // optimized. 3477 // optimized.
3480 const char* src_2 = "function foo() { " 3478 const char* src_2 = "function foo() { "
3481 " var a = {a:[1, 2, 3]};" 3479 " var a = {a:[1, 2, 3]};"
3482 " for (x in a.a) {" 3480 " for (x in a.a) {"
3483 " b = 0;" 3481 " b = 0;"
3484 " }" 3482 " }"
3485 "}" 3483 "}"
3486 "foo()"; 3484 "foo()";
3487 foo = CompileFunction(&env, src_2, "foo"); 3485 foo = CompileFunction(&env, src_2, "foo");
3488 SetBreakPoint(foo, 0); // "var a = ..." 3486 SetBreakPoint(foo, 0); // "var a = ..."
3489 3487
3490 step_action = StepIn; 3488 step_action = StepIn;
3491 break_point_hit_count = 0; 3489 break_point_hit_count = 0;
3492 foo->Call(env->Global(), 0, NULL); 3490 foo->Call(env->Global(), 0, NULL);
3493 CHECK_EQ(8, break_point_hit_count); 3491 CHECK_EQ(9, break_point_hit_count);
3494 3492
3495 // Get rid of the debug event listener. 3493 // Get rid of the debug event listener.
3496 v8::Debug::SetDebugEventListener(NULL); 3494 v8::Debug::SetDebugEventListener(NULL);
3497 CheckDebuggerUnloaded(); 3495 CheckDebuggerUnloaded();
3498 } 3496 }
3499 3497
3500 3498
3501 TEST(DebugStepWith) { 3499 TEST(DebugStepWith) {
3502 DebugLocalContext env; 3500 DebugLocalContext env;
3503 v8::HandleScope scope(env->GetIsolate()); 3501 v8::HandleScope scope(env->GetIsolate());
(...skipping 4109 matching lines...) Expand 10 before | Expand all | Expand 10 after
7613 "var obj = {};" 7611 "var obj = {};"
7614 "var callbackRan = false;" 7612 "var callbackRan = false;"
7615 "Object.observe(obj, function() {" 7613 "Object.observe(obj, function() {"
7616 " callbackRan = true;" 7614 " callbackRan = true;"
7617 " throw Error('foo');" 7615 " throw Error('foo');"
7618 "});" 7616 "});"
7619 "obj.prop = 1"); 7617 "obj.prop = 1");
7620 CHECK(CompileRun("callbackRan")->BooleanValue()); 7618 CHECK(CompileRun("callbackRan")->BooleanValue());
7621 CHECK_EQ(1, exception_event_counter); 7619 CHECK_EQ(1, exception_event_counter);
7622 } 7620 }
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