| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2910 // Run functions to allow them to get optimized. | 2910 // Run functions to allow them to get optimized. |
| 2911 CompileRun("a=0; b=0; bar(); foo();"); | 2911 CompileRun("a=0; b=0; bar(); foo();"); |
| 2912 | 2912 |
| 2913 SetBreakPoint(foo, 0); | 2913 SetBreakPoint(foo, 0); |
| 2914 | 2914 |
| 2915 step_action = StepIn; | 2915 step_action = StepIn; |
| 2916 break_point_hit_count = 0; | 2916 break_point_hit_count = 0; |
| 2917 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 2917 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 2918 | 2918 |
| 2919 // With stepping all break locations are hit. | 2919 // With stepping all break locations are hit. |
| 2920 CHECK_EQ(11, break_point_hit_count); | 2920 CHECK_EQ(10, break_point_hit_count); |
| 2921 | 2921 |
| 2922 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 2922 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
| 2923 CheckDebuggerUnloaded(env->GetIsolate()); | 2923 CheckDebuggerUnloaded(env->GetIsolate()); |
| 2924 | 2924 |
| 2925 // Register a debug event listener which just counts. | 2925 // Register a debug event listener which just counts. |
| 2926 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 2926 v8::Debug::SetDebugEventListener(env->GetIsolate(), |
| 2927 DebugEventBreakPointHitCount); | 2927 DebugEventBreakPointHitCount); |
| 2928 | 2928 |
| 2929 SetBreakPoint(foo, 0); | 2929 SetBreakPoint(foo, 0); |
| 2930 break_point_hit_count = 0; | 2930 break_point_hit_count = 0; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2957 "}" | 2957 "}" |
| 2958 "foo()"; | 2958 "foo()"; |
| 2959 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); | 2959 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); |
| 2960 | 2960 |
| 2961 SetBreakPoint(foo, 0); | 2961 SetBreakPoint(foo, 0); |
| 2962 | 2962 |
| 2963 // Stepping through the declarations. | 2963 // Stepping through the declarations. |
| 2964 step_action = StepIn; | 2964 step_action = StepIn; |
| 2965 break_point_hit_count = 0; | 2965 break_point_hit_count = 0; |
| 2966 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 2966 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 2967 CHECK_EQ(6, break_point_hit_count); | 2967 CHECK_EQ(5, break_point_hit_count); |
| 2968 | 2968 |
| 2969 // Get rid of the debug event listener. | 2969 // Get rid of the debug event listener. |
| 2970 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 2970 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
| 2971 CheckDebuggerUnloaded(env->GetIsolate()); | 2971 CheckDebuggerUnloaded(env->GetIsolate()); |
| 2972 } | 2972 } |
| 2973 | 2973 |
| 2974 | 2974 |
| 2975 TEST(DebugStepLocals) { | 2975 TEST(DebugStepLocals) { |
| 2976 DebugLocalContext env; | 2976 DebugLocalContext env; |
| 2977 v8::HandleScope scope(env->GetIsolate()); | 2977 v8::HandleScope scope(env->GetIsolate()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2991 "}" | 2991 "}" |
| 2992 "foo()"; | 2992 "foo()"; |
| 2993 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); | 2993 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); |
| 2994 | 2994 |
| 2995 SetBreakPoint(foo, 0); | 2995 SetBreakPoint(foo, 0); |
| 2996 | 2996 |
| 2997 // Stepping through the declarations. | 2997 // Stepping through the declarations. |
| 2998 step_action = StepIn; | 2998 step_action = StepIn; |
| 2999 break_point_hit_count = 0; | 2999 break_point_hit_count = 0; |
| 3000 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 3000 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 3001 CHECK_EQ(6, break_point_hit_count); | 3001 CHECK_EQ(5, break_point_hit_count); |
| 3002 | 3002 |
| 3003 // Get rid of the debug event listener. | 3003 // Get rid of the debug event listener. |
| 3004 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 3004 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
| 3005 CheckDebuggerUnloaded(env->GetIsolate()); | 3005 CheckDebuggerUnloaded(env->GetIsolate()); |
| 3006 } | 3006 } |
| 3007 | 3007 |
| 3008 | 3008 |
| 3009 TEST(DebugStepIf) { | 3009 TEST(DebugStepIf) { |
| 3010 DebugLocalContext env; | 3010 DebugLocalContext env; |
| 3011 v8::Isolate* isolate = env->GetIsolate(); | 3011 v8::Isolate* isolate = env->GetIsolate(); |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3464 " a = x ? 1 : 2;" | 3464 " a = x ? 1 : 2;" |
| 3465 " return a;" | 3465 " return a;" |
| 3466 "}" | 3466 "}" |
| 3467 "foo()"; | 3467 "foo()"; |
| 3468 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); | 3468 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); |
| 3469 SetBreakPoint(foo, 0); // "var a;" | 3469 SetBreakPoint(foo, 0); // "var a;" |
| 3470 | 3470 |
| 3471 step_action = StepIn; | 3471 step_action = StepIn; |
| 3472 break_point_hit_count = 0; | 3472 break_point_hit_count = 0; |
| 3473 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 3473 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 3474 CHECK_EQ(4, break_point_hit_count); | 3474 CHECK_EQ(3, break_point_hit_count); |
| 3475 | 3475 |
| 3476 step_action = StepIn; | 3476 step_action = StepIn; |
| 3477 break_point_hit_count = 0; | 3477 break_point_hit_count = 0; |
| 3478 const int argc = 1; | 3478 const int argc = 1; |
| 3479 v8::Local<v8::Value> argv_true[argc] = {v8::True(isolate)}; | 3479 v8::Local<v8::Value> argv_true[argc] = {v8::True(isolate)}; |
| 3480 foo->Call(context, env->Global(), argc, argv_true).ToLocalChecked(); | 3480 foo->Call(context, env->Global(), argc, argv_true).ToLocalChecked(); |
| 3481 CHECK_EQ(4, break_point_hit_count); | 3481 CHECK_EQ(3, break_point_hit_count); |
| 3482 | 3482 |
| 3483 // Get rid of the debug event listener. | 3483 // Get rid of the debug event listener. |
| 3484 v8::Debug::SetDebugEventListener(isolate, nullptr); | 3484 v8::Debug::SetDebugEventListener(isolate, nullptr); |
| 3485 CheckDebuggerUnloaded(isolate); | 3485 CheckDebuggerUnloaded(isolate); |
| 3486 } | 3486 } |
| 3487 | 3487 |
| 3488 | 3488 |
| 3489 TEST(StepInOutSimple) { | 3489 TEST(StepInOutSimple) { |
| 3490 DebugLocalContext env; | 3490 DebugLocalContext env; |
| 3491 v8::HandleScope scope(env->GetIsolate()); | 3491 v8::HandleScope scope(env->GetIsolate()); |
| (...skipping 4573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8065 CHECK_EQ(22, iterator->GetBreakLocation().position()); | 8065 CHECK_EQ(22, iterator->GetBreakLocation().position()); |
| 8066 iterator->Next(); | 8066 iterator->Next(); |
| 8067 CHECK(iterator->GetBreakLocation().IsReturn()); | 8067 CHECK(iterator->GetBreakLocation().IsReturn()); |
| 8068 CHECK_EQ(50, iterator->GetBreakLocation().position()); | 8068 CHECK_EQ(50, iterator->GetBreakLocation().position()); |
| 8069 iterator->Next(); | 8069 iterator->Next(); |
| 8070 CHECK(iterator->Done()); | 8070 CHECK(iterator->Done()); |
| 8071 delete iterator; | 8071 delete iterator; |
| 8072 | 8072 |
| 8073 DisableDebugger(isolate); | 8073 DisableDebugger(isolate); |
| 8074 } | 8074 } |
| OLD | NEW |