| OLD | NEW |
| 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 2729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2740 v8::Local<v8::Value> args[kArgc] = {a}; | 2740 v8::Local<v8::Value> args[kArgc] = {a}; |
| 2741 foo->Call(context, env->Global(), kArgc, args).ToLocalChecked(); | 2741 foo->Call(context, env->Global(), kArgc, args).ToLocalChecked(); |
| 2742 | 2742 |
| 2743 // Set up break point and step through the function. | 2743 // Set up break point and step through the function. |
| 2744 SetBreakPoint(foo, 3); | 2744 SetBreakPoint(foo, 3); |
| 2745 step_action = StepNext; | 2745 step_action = StepNext; |
| 2746 break_point_hit_count = 0; | 2746 break_point_hit_count = 0; |
| 2747 foo->Call(context, env->Global(), kArgc, args).ToLocalChecked(); | 2747 foo->Call(context, env->Global(), kArgc, args).ToLocalChecked(); |
| 2748 | 2748 |
| 2749 // With stepping all break locations are hit. | 2749 // With stepping all break locations are hit. |
| 2750 CHECK_EQ(45, break_point_hit_count); | 2750 CHECK_EQ(44, break_point_hit_count); |
| 2751 | 2751 |
| 2752 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 2752 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
| 2753 CheckDebuggerUnloaded(env->GetIsolate()); | 2753 CheckDebuggerUnloaded(env->GetIsolate()); |
| 2754 } | 2754 } |
| 2755 | 2755 |
| 2756 | 2756 |
| 2757 // Test of the stepping mechanism for keyed store in a loop. | 2757 // Test of the stepping mechanism for keyed store in a loop. |
| 2758 TEST(DebugStepKeyedStoreLoop) { | 2758 TEST(DebugStepKeyedStoreLoop) { |
| 2759 DebugLocalContext env; | 2759 DebugLocalContext env; |
| 2760 v8::HandleScope scope(env->GetIsolate()); | 2760 v8::HandleScope scope(env->GetIsolate()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2790 v8::Local<v8::Value> args[kArgc] = {a}; | 2790 v8::Local<v8::Value> args[kArgc] = {a}; |
| 2791 foo->Call(context, env->Global(), kArgc, args).ToLocalChecked(); | 2791 foo->Call(context, env->Global(), kArgc, args).ToLocalChecked(); |
| 2792 | 2792 |
| 2793 // Set up break point and step through the function. | 2793 // Set up break point and step through the function. |
| 2794 SetBreakPoint(foo, 3); | 2794 SetBreakPoint(foo, 3); |
| 2795 step_action = StepNext; | 2795 step_action = StepNext; |
| 2796 break_point_hit_count = 0; | 2796 break_point_hit_count = 0; |
| 2797 foo->Call(context, env->Global(), kArgc, args).ToLocalChecked(); | 2797 foo->Call(context, env->Global(), kArgc, args).ToLocalChecked(); |
| 2798 | 2798 |
| 2799 // With stepping all break locations are hit. | 2799 // With stepping all break locations are hit. |
| 2800 CHECK_EQ(45, break_point_hit_count); | 2800 CHECK_EQ(44, break_point_hit_count); |
| 2801 | 2801 |
| 2802 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 2802 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
| 2803 CheckDebuggerUnloaded(env->GetIsolate()); | 2803 CheckDebuggerUnloaded(env->GetIsolate()); |
| 2804 } | 2804 } |
| 2805 | 2805 |
| 2806 | 2806 |
| 2807 // Test of the stepping mechanism for named load in a loop. | 2807 // Test of the stepping mechanism for named load in a loop. |
| 2808 TEST(DebugStepNamedLoadLoop) { | 2808 TEST(DebugStepNamedLoadLoop) { |
| 2809 DebugLocalContext env; | 2809 DebugLocalContext env; |
| 2810 v8::HandleScope scope(env->GetIsolate()); | 2810 v8::HandleScope scope(env->GetIsolate()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2835 // Call function without any break points to ensure inlining is in place. | 2835 // Call function without any break points to ensure inlining is in place. |
| 2836 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 2836 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 2837 | 2837 |
| 2838 // Set up break point and step through the function. | 2838 // Set up break point and step through the function. |
| 2839 SetBreakPoint(foo, 4); | 2839 SetBreakPoint(foo, 4); |
| 2840 step_action = StepNext; | 2840 step_action = StepNext; |
| 2841 break_point_hit_count = 0; | 2841 break_point_hit_count = 0; |
| 2842 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 2842 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 2843 | 2843 |
| 2844 // With stepping all break locations are hit. | 2844 // With stepping all break locations are hit. |
| 2845 CHECK_EQ(66, break_point_hit_count); | 2845 CHECK_EQ(65, break_point_hit_count); |
| 2846 | 2846 |
| 2847 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 2847 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
| 2848 CheckDebuggerUnloaded(env->GetIsolate()); | 2848 CheckDebuggerUnloaded(env->GetIsolate()); |
| 2849 } | 2849 } |
| 2850 | 2850 |
| 2851 | 2851 |
| 2852 static void DoDebugStepNamedStoreLoop(int expected) { | 2852 static void DoDebugStepNamedStoreLoop(int expected) { |
| 2853 DebugLocalContext env; | 2853 DebugLocalContext env; |
| 2854 v8::HandleScope scope(env->GetIsolate()); | 2854 v8::HandleScope scope(env->GetIsolate()); |
| 2855 | 2855 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2879 | 2879 |
| 2880 // With stepping all expected break locations are hit. | 2880 // With stepping all expected break locations are hit. |
| 2881 CHECK_EQ(expected, break_point_hit_count); | 2881 CHECK_EQ(expected, break_point_hit_count); |
| 2882 | 2882 |
| 2883 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 2883 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
| 2884 CheckDebuggerUnloaded(env->GetIsolate()); | 2884 CheckDebuggerUnloaded(env->GetIsolate()); |
| 2885 } | 2885 } |
| 2886 | 2886 |
| 2887 | 2887 |
| 2888 // Test of the stepping mechanism for named load in a loop. | 2888 // Test of the stepping mechanism for named load in a loop. |
| 2889 TEST(DebugStepNamedStoreLoop) { DoDebugStepNamedStoreLoop(35); } | 2889 TEST(DebugStepNamedStoreLoop) { DoDebugStepNamedStoreLoop(34); } |
| 2890 | 2890 |
| 2891 // Test the stepping mechanism with different ICs. | 2891 // Test the stepping mechanism with different ICs. |
| 2892 TEST(DebugStepLinearMixedICs) { | 2892 TEST(DebugStepLinearMixedICs) { |
| 2893 DebugLocalContext env; | 2893 DebugLocalContext env; |
| 2894 v8::HandleScope scope(env->GetIsolate()); | 2894 v8::HandleScope scope(env->GetIsolate()); |
| 2895 | 2895 |
| 2896 // Register a debug event listener which steps and counts. | 2896 // Register a debug event listener which steps and counts. |
| 2897 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep); | 2897 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep); |
| 2898 | 2898 |
| 2899 v8::Local<v8::Context> context = env.context(); | 2899 v8::Local<v8::Context> context = env.context(); |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3286 SetBreakPoint(foo, 8); // "var a = 0;" | 3286 SetBreakPoint(foo, 8); // "var a = 0;" |
| 3287 | 3287 |
| 3288 // Each loop generates 4 or 5 steps depending on whether a is equal. | 3288 // Each loop generates 4 or 5 steps depending on whether a is equal. |
| 3289 | 3289 |
| 3290 // Looping 10 times. | 3290 // Looping 10 times. |
| 3291 step_action = StepIn; | 3291 step_action = StepIn; |
| 3292 break_point_hit_count = 0; | 3292 break_point_hit_count = 0; |
| 3293 v8::Local<v8::Value> argv_10[argc] = {v8::Number::New(isolate, 10)}; | 3293 v8::Local<v8::Value> argv_10[argc] = {v8::Number::New(isolate, 10)}; |
| 3294 result = foo->Call(context, env->Global(), argc, argv_10).ToLocalChecked(); | 3294 result = foo->Call(context, env->Global(), argc, argv_10).ToLocalChecked(); |
| 3295 CHECK_EQ(5, result->Int32Value(context).FromJust()); | 3295 CHECK_EQ(5, result->Int32Value(context).FromJust()); |
| 3296 CHECK_EQ(63, break_point_hit_count); | 3296 CHECK_EQ(62, break_point_hit_count); |
| 3297 | 3297 |
| 3298 // Looping 100 times. | 3298 // Looping 100 times. |
| 3299 step_action = StepIn; | 3299 step_action = StepIn; |
| 3300 break_point_hit_count = 0; | 3300 break_point_hit_count = 0; |
| 3301 v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)}; | 3301 v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)}; |
| 3302 result = foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked(); | 3302 result = foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked(); |
| 3303 CHECK_EQ(50, result->Int32Value(context).FromJust()); | 3303 CHECK_EQ(50, result->Int32Value(context).FromJust()); |
| 3304 CHECK_EQ(558, break_point_hit_count); | 3304 CHECK_EQ(557, break_point_hit_count); |
| 3305 | 3305 |
| 3306 // Get rid of the debug event listener. | 3306 // Get rid of the debug event listener. |
| 3307 v8::Debug::SetDebugEventListener(isolate, nullptr); | 3307 v8::Debug::SetDebugEventListener(isolate, nullptr); |
| 3308 CheckDebuggerUnloaded(isolate); | 3308 CheckDebuggerUnloaded(isolate); |
| 3309 } | 3309 } |
| 3310 | 3310 |
| 3311 | 3311 |
| 3312 TEST(DebugStepForBreak) { | 3312 TEST(DebugStepForBreak) { |
| 3313 DebugLocalContext env; | 3313 DebugLocalContext env; |
| 3314 v8::Isolate* isolate = env->GetIsolate(); | 3314 v8::Isolate* isolate = env->GetIsolate(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3340 | 3340 |
| 3341 // Each loop generates 5 steps except for the last (when break is executed) | 3341 // Each loop generates 5 steps except for the last (when break is executed) |
| 3342 // which only generates 4. | 3342 // which only generates 4. |
| 3343 | 3343 |
| 3344 // Looping 10 times. | 3344 // Looping 10 times. |
| 3345 step_action = StepIn; | 3345 step_action = StepIn; |
| 3346 break_point_hit_count = 0; | 3346 break_point_hit_count = 0; |
| 3347 v8::Local<v8::Value> argv_10[argc] = {v8::Number::New(isolate, 10)}; | 3347 v8::Local<v8::Value> argv_10[argc] = {v8::Number::New(isolate, 10)}; |
| 3348 result = foo->Call(context, env->Global(), argc, argv_10).ToLocalChecked(); | 3348 result = foo->Call(context, env->Global(), argc, argv_10).ToLocalChecked(); |
| 3349 CHECK_EQ(9, result->Int32Value(context).FromJust()); | 3349 CHECK_EQ(9, result->Int32Value(context).FromJust()); |
| 3350 CHECK_EQ(65, break_point_hit_count); | 3350 CHECK_EQ(64, break_point_hit_count); |
| 3351 | 3351 |
| 3352 // Looping 100 times. | 3352 // Looping 100 times. |
| 3353 step_action = StepIn; | 3353 step_action = StepIn; |
| 3354 break_point_hit_count = 0; | 3354 break_point_hit_count = 0; |
| 3355 v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)}; | 3355 v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)}; |
| 3356 result = foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked(); | 3356 result = foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked(); |
| 3357 CHECK_EQ(99, result->Int32Value(context).FromJust()); | 3357 CHECK_EQ(99, result->Int32Value(context).FromJust()); |
| 3358 CHECK_EQ(605, break_point_hit_count); | 3358 CHECK_EQ(604, break_point_hit_count); |
| 3359 | 3359 |
| 3360 // Get rid of the debug event listener. | 3360 // Get rid of the debug event listener. |
| 3361 v8::Debug::SetDebugEventListener(isolate, nullptr); | 3361 v8::Debug::SetDebugEventListener(isolate, nullptr); |
| 3362 CheckDebuggerUnloaded(isolate); | 3362 CheckDebuggerUnloaded(isolate); |
| 3363 } | 3363 } |
| 3364 | 3364 |
| 3365 | 3365 |
| 3366 TEST(DebugStepForIn) { | 3366 TEST(DebugStepForIn) { |
| 3367 DebugLocalContext env; | 3367 DebugLocalContext env; |
| 3368 v8::HandleScope scope(env->GetIsolate()); | 3368 v8::HandleScope scope(env->GetIsolate()); |
| (...skipping 4695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8064 CHECK_EQ(22, iterator->GetBreakLocation().position()); | 8064 CHECK_EQ(22, iterator->GetBreakLocation().position()); |
| 8065 iterator->Next(); | 8065 iterator->Next(); |
| 8066 CHECK(iterator->GetBreakLocation().IsReturn()); | 8066 CHECK(iterator->GetBreakLocation().IsReturn()); |
| 8067 CHECK_EQ(50, iterator->GetBreakLocation().position()); | 8067 CHECK_EQ(50, iterator->GetBreakLocation().position()); |
| 8068 iterator->Next(); | 8068 iterator->Next(); |
| 8069 CHECK(iterator->Done()); | 8069 CHECK(iterator->Done()); |
| 8070 delete iterator; | 8070 delete iterator; |
| 8071 | 8071 |
| 8072 DisableDebugger(isolate); | 8072 DisableDebugger(isolate); |
| 8073 } | 8073 } |
| OLD | NEW |