| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 133 } |
| 134 | 134 |
| 135 | 135 |
| 136 // Compile and run the supplied source and return the requested function. | 136 // Compile and run the supplied source and return the requested function. |
| 137 static v8::Local<v8::Function> CompileFunction(DebugLocalContext* env, | 137 static v8::Local<v8::Function> CompileFunction(DebugLocalContext* env, |
| 138 const char* source, | 138 const char* source, |
| 139 const char* function_name) { | 139 const char* function_name) { |
| 140 return CompileFunction(env->GetIsolate(), source, function_name); | 140 return CompileFunction(env->GetIsolate(), source, function_name); |
| 141 } | 141 } |
| 142 | 142 |
| 143 static void SetDebugEventListener( |
| 144 v8::Isolate* isolate, v8::Debug::EventCallback that, |
| 145 v8::Local<v8::Value> data = v8::Local<v8::Value>()) { |
| 146 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 147 i::HandleScope scope(i_isolate); |
| 148 if (that == nullptr) { |
| 149 i_isolate->debug()->SetDebugDelegate(nullptr, false); |
| 150 } else { |
| 151 i::Handle<i::Object> i_data = i_isolate->factory()->undefined_value(); |
| 152 if (!data.IsEmpty()) i_data = v8::Utils::OpenHandle(*data); |
| 153 i::NativeDebugDelegate* delegate = |
| 154 new i::NativeDebugDelegate(i_isolate, that, i_data); |
| 155 i_isolate->debug()->SetDebugDelegate(delegate, true); |
| 156 } |
| 157 } |
| 143 | 158 |
| 144 // Is there any debug info for the function? | 159 // Is there any debug info for the function? |
| 145 static bool HasDebugInfo(v8::Local<v8::Function> fun) { | 160 static bool HasDebugInfo(v8::Local<v8::Function> fun) { |
| 146 Handle<v8::internal::JSFunction> f = | 161 Handle<v8::internal::JSFunction> f = |
| 147 Handle<v8::internal::JSFunction>::cast(v8::Utils::OpenHandle(*fun)); | 162 Handle<v8::internal::JSFunction>::cast(v8::Utils::OpenHandle(*fun)); |
| 148 Handle<v8::internal::SharedFunctionInfo> shared(f->shared()); | 163 Handle<v8::internal::SharedFunctionInfo> shared(f->shared()); |
| 149 return shared->HasDebugInfo(); | 164 return shared->HasDebugInfo(); |
| 150 } | 165 } |
| 151 | 166 |
| 152 // Set a break point in a function with a position relative to function start, | 167 // Set a break point in a function with a position relative to function start, |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 | 829 |
| 815 if (event == v8::Break) { | 830 if (event == v8::Break) { |
| 816 // Count the number of breaks. | 831 // Count the number of breaks. |
| 817 break_point_hit_count++; | 832 break_point_hit_count++; |
| 818 | 833 |
| 819 // Run the garbage collector to enforce heap verification if option | 834 // Run the garbage collector to enforce heap verification if option |
| 820 // --verify-heap is set. | 835 // --verify-heap is set. |
| 821 CcTest::CollectGarbage(v8::internal::NEW_SPACE); | 836 CcTest::CollectGarbage(v8::internal::NEW_SPACE); |
| 822 | 837 |
| 823 // Set the break flag again to come back here as soon as possible. | 838 // Set the break flag again to come back here as soon as possible. |
| 824 v8::Debug::DebugBreak(CcTest::isolate()); | 839 v8::debug::DebugBreak(CcTest::isolate()); |
| 825 } | 840 } |
| 826 } | 841 } |
| 827 | 842 |
| 828 | 843 |
| 829 // Debug event handler which re-issues a debug break until a limit has been | 844 // Debug event handler which re-issues a debug break until a limit has been |
| 830 // reached. | 845 // reached. |
| 831 int max_break_point_hit_count = 0; | 846 int max_break_point_hit_count = 0; |
| 832 bool terminate_after_max_break_point_hit = false; | 847 bool terminate_after_max_break_point_hit = false; |
| 833 static void DebugEventBreakMax( | 848 static void DebugEventBreakMax( |
| 834 const v8::Debug::EventDetails& event_details) { | 849 const v8::Debug::EventDetails& event_details) { |
| 835 v8::DebugEvent event = event_details.GetEvent(); | 850 v8::DebugEvent event = event_details.GetEvent(); |
| 836 v8::Isolate* v8_isolate = CcTest::isolate(); | 851 v8::Isolate* v8_isolate = CcTest::isolate(); |
| 837 v8::internal::Isolate* isolate = CcTest::i_isolate(); | 852 v8::internal::Isolate* isolate = CcTest::i_isolate(); |
| 838 v8::internal::Debug* debug = isolate->debug(); | 853 v8::internal::Debug* debug = isolate->debug(); |
| 839 // When hitting a debug event listener there must be a break set. | 854 // When hitting a debug event listener there must be a break set. |
| 840 CHECK_NE(debug->break_id(), 0); | 855 CHECK_NE(debug->break_id(), 0); |
| 841 | 856 |
| 842 if (event == v8::Break) { | 857 if (event == v8::Break) { |
| 843 if (break_point_hit_count < max_break_point_hit_count) { | 858 if (break_point_hit_count < max_break_point_hit_count) { |
| 844 // Count the number of breaks. | 859 // Count the number of breaks. |
| 845 break_point_hit_count++; | 860 break_point_hit_count++; |
| 846 | 861 |
| 847 // Set the break flag again to come back here as soon as possible. | 862 // Set the break flag again to come back here as soon as possible. |
| 848 v8::Debug::DebugBreak(v8_isolate); | 863 v8::debug::DebugBreak(v8_isolate); |
| 849 | 864 |
| 850 } else if (terminate_after_max_break_point_hit) { | 865 } else if (terminate_after_max_break_point_hit) { |
| 851 // Terminate execution after the last break if requested. | 866 // Terminate execution after the last break if requested. |
| 852 v8_isolate->TerminateExecution(); | 867 v8_isolate->TerminateExecution(); |
| 853 } | 868 } |
| 854 | 869 |
| 855 // Perform a full deoptimization when the specified number of | 870 // Perform a full deoptimization when the specified number of |
| 856 // breaks have been hit. | 871 // breaks have been hit. |
| 857 if (break_point_hit_count == break_point_hit_count_deoptimize) { | 872 if (break_point_hit_count == break_point_hit_count_deoptimize) { |
| 858 i::Deoptimizer::DeoptimizeAll(isolate); | 873 i::Deoptimizer::DeoptimizeAll(isolate); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 CHECK(!HasDebugInfo(bar)); | 932 CHECK(!HasDebugInfo(bar)); |
| 918 } | 933 } |
| 919 | 934 |
| 920 | 935 |
| 921 // Test that a break point can be set at an IC store location. | 936 // Test that a break point can be set at an IC store location. |
| 922 TEST(BreakPointICStore) { | 937 TEST(BreakPointICStore) { |
| 923 break_point_hit_count = 0; | 938 break_point_hit_count = 0; |
| 924 DebugLocalContext env; | 939 DebugLocalContext env; |
| 925 v8::HandleScope scope(env->GetIsolate()); | 940 v8::HandleScope scope(env->GetIsolate()); |
| 926 | 941 |
| 927 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 942 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount); |
| 928 DebugEventBreakPointHitCount); | |
| 929 v8::Local<v8::Function> foo = | 943 v8::Local<v8::Function> foo = |
| 930 CompileFunction(&env, "function foo(){bar=0;}", "foo"); | 944 CompileFunction(&env, "function foo(){bar=0;}", "foo"); |
| 931 | 945 |
| 932 // Run without breakpoints. | 946 // Run without breakpoints. |
| 933 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); | 947 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); |
| 934 CHECK_EQ(0, break_point_hit_count); | 948 CHECK_EQ(0, break_point_hit_count); |
| 935 | 949 |
| 936 // Run with breakpoint | 950 // Run with breakpoint |
| 937 int bp = SetBreakPoint(foo, 0); | 951 int bp = SetBreakPoint(foo, 0); |
| 938 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); | 952 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); |
| 939 CHECK_EQ(1, break_point_hit_count); | 953 CHECK_EQ(1, break_point_hit_count); |
| 940 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); | 954 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); |
| 941 CHECK_EQ(2, break_point_hit_count); | 955 CHECK_EQ(2, break_point_hit_count); |
| 942 | 956 |
| 943 // Run without breakpoints. | 957 // Run without breakpoints. |
| 944 ClearBreakPoint(bp); | 958 ClearBreakPoint(bp); |
| 945 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); | 959 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); |
| 946 CHECK_EQ(2, break_point_hit_count); | 960 CHECK_EQ(2, break_point_hit_count); |
| 947 | 961 |
| 948 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 962 SetDebugEventListener(env->GetIsolate(), nullptr); |
| 949 CheckDebuggerUnloaded(env->GetIsolate()); | 963 CheckDebuggerUnloaded(env->GetIsolate()); |
| 950 } | 964 } |
| 951 | 965 |
| 952 | 966 |
| 953 // Test that a break point can be set at an IC load location. | 967 // Test that a break point can be set at an IC load location. |
| 954 TEST(BreakPointICLoad) { | 968 TEST(BreakPointICLoad) { |
| 955 break_point_hit_count = 0; | 969 break_point_hit_count = 0; |
| 956 DebugLocalContext env; | 970 DebugLocalContext env; |
| 957 v8::HandleScope scope(env->GetIsolate()); | 971 v8::HandleScope scope(env->GetIsolate()); |
| 958 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 972 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount); |
| 959 DebugEventBreakPointHitCount); | |
| 960 | 973 |
| 961 CompileRunChecked(env->GetIsolate(), "bar=1"); | 974 CompileRunChecked(env->GetIsolate(), "bar=1"); |
| 962 v8::Local<v8::Function> foo = | 975 v8::Local<v8::Function> foo = |
| 963 CompileFunction(&env, "function foo(){var x=bar;}", "foo"); | 976 CompileFunction(&env, "function foo(){var x=bar;}", "foo"); |
| 964 | 977 |
| 965 // Run without breakpoints. | 978 // Run without breakpoints. |
| 966 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); | 979 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); |
| 967 CHECK_EQ(0, break_point_hit_count); | 980 CHECK_EQ(0, break_point_hit_count); |
| 968 | 981 |
| 969 // Run with breakpoint. | 982 // Run with breakpoint. |
| 970 int bp = SetBreakPoint(foo, 0); | 983 int bp = SetBreakPoint(foo, 0); |
| 971 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); | 984 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); |
| 972 CHECK_EQ(1, break_point_hit_count); | 985 CHECK_EQ(1, break_point_hit_count); |
| 973 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); | 986 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); |
| 974 CHECK_EQ(2, break_point_hit_count); | 987 CHECK_EQ(2, break_point_hit_count); |
| 975 | 988 |
| 976 // Run without breakpoints. | 989 // Run without breakpoints. |
| 977 ClearBreakPoint(bp); | 990 ClearBreakPoint(bp); |
| 978 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); | 991 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); |
| 979 CHECK_EQ(2, break_point_hit_count); | 992 CHECK_EQ(2, break_point_hit_count); |
| 980 | 993 |
| 981 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 994 SetDebugEventListener(env->GetIsolate(), nullptr); |
| 982 CheckDebuggerUnloaded(env->GetIsolate()); | 995 CheckDebuggerUnloaded(env->GetIsolate()); |
| 983 } | 996 } |
| 984 | 997 |
| 985 | 998 |
| 986 // Test that a break point can be set at an IC call location. | 999 // Test that a break point can be set at an IC call location. |
| 987 TEST(BreakPointICCall) { | 1000 TEST(BreakPointICCall) { |
| 988 break_point_hit_count = 0; | 1001 break_point_hit_count = 0; |
| 989 DebugLocalContext env; | 1002 DebugLocalContext env; |
| 990 v8::HandleScope scope(env->GetIsolate()); | 1003 v8::HandleScope scope(env->GetIsolate()); |
| 991 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 1004 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount); |
| 992 DebugEventBreakPointHitCount); | |
| 993 CompileRunChecked(env->GetIsolate(), "function bar(){}"); | 1005 CompileRunChecked(env->GetIsolate(), "function bar(){}"); |
| 994 v8::Local<v8::Function> foo = | 1006 v8::Local<v8::Function> foo = |
| 995 CompileFunction(&env, "function foo(){bar();}", "foo"); | 1007 CompileFunction(&env, "function foo(){bar();}", "foo"); |
| 996 | 1008 |
| 997 // Run without breakpoints. | 1009 // Run without breakpoints. |
| 998 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); | 1010 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); |
| 999 CHECK_EQ(0, break_point_hit_count); | 1011 CHECK_EQ(0, break_point_hit_count); |
| 1000 | 1012 |
| 1001 // Run with breakpoint | 1013 // Run with breakpoint |
| 1002 int bp = SetBreakPoint(foo, 0); | 1014 int bp = SetBreakPoint(foo, 0); |
| 1003 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); | 1015 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); |
| 1004 CHECK_EQ(1, break_point_hit_count); | 1016 CHECK_EQ(1, break_point_hit_count); |
| 1005 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); | 1017 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); |
| 1006 CHECK_EQ(2, break_point_hit_count); | 1018 CHECK_EQ(2, break_point_hit_count); |
| 1007 | 1019 |
| 1008 // Run without breakpoints. | 1020 // Run without breakpoints. |
| 1009 ClearBreakPoint(bp); | 1021 ClearBreakPoint(bp); |
| 1010 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); | 1022 foo->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); |
| 1011 CHECK_EQ(2, break_point_hit_count); | 1023 CHECK_EQ(2, break_point_hit_count); |
| 1012 | 1024 |
| 1013 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 1025 SetDebugEventListener(env->GetIsolate(), nullptr); |
| 1014 CheckDebuggerUnloaded(env->GetIsolate()); | 1026 CheckDebuggerUnloaded(env->GetIsolate()); |
| 1015 } | 1027 } |
| 1016 | 1028 |
| 1017 | 1029 |
| 1018 // Test that a break point can be set at an IC call location and survive a GC. | 1030 // Test that a break point can be set at an IC call location and survive a GC. |
| 1019 TEST(BreakPointICCallWithGC) { | 1031 TEST(BreakPointICCallWithGC) { |
| 1020 break_point_hit_count = 0; | 1032 break_point_hit_count = 0; |
| 1021 DebugLocalContext env; | 1033 DebugLocalContext env; |
| 1022 v8::HandleScope scope(env->GetIsolate()); | 1034 v8::HandleScope scope(env->GetIsolate()); |
| 1023 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 1035 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointCollectGarbage); |
| 1024 DebugEventBreakPointCollectGarbage); | |
| 1025 CompileRunChecked(env->GetIsolate(), "function bar(){return 1;}"); | 1036 CompileRunChecked(env->GetIsolate(), "function bar(){return 1;}"); |
| 1026 v8::Local<v8::Function> foo = | 1037 v8::Local<v8::Function> foo = |
| 1027 CompileFunction(&env, "function foo(){return bar();}", "foo"); | 1038 CompileFunction(&env, "function foo(){return bar();}", "foo"); |
| 1028 v8::Local<v8::Context> context = env.context(); | 1039 v8::Local<v8::Context> context = env.context(); |
| 1029 | 1040 |
| 1030 // Run without breakpoints. | 1041 // Run without breakpoints. |
| 1031 CHECK_EQ(1, foo->Call(context, env->Global(), 0, NULL) | 1042 CHECK_EQ(1, foo->Call(context, env->Global(), 0, NULL) |
| 1032 .ToLocalChecked() | 1043 .ToLocalChecked() |
| 1033 ->Int32Value(context) | 1044 ->Int32Value(context) |
| 1034 .FromJust()); | 1045 .FromJust()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1045 .ToLocalChecked() | 1056 .ToLocalChecked() |
| 1046 ->Int32Value(context) | 1057 ->Int32Value(context) |
| 1047 .FromJust()); | 1058 .FromJust()); |
| 1048 CHECK_EQ(2, break_point_hit_count); | 1059 CHECK_EQ(2, break_point_hit_count); |
| 1049 | 1060 |
| 1050 // Run without breakpoints. | 1061 // Run without breakpoints. |
| 1051 ClearBreakPoint(bp); | 1062 ClearBreakPoint(bp); |
| 1052 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 1063 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 1053 CHECK_EQ(2, break_point_hit_count); | 1064 CHECK_EQ(2, break_point_hit_count); |
| 1054 | 1065 |
| 1055 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 1066 SetDebugEventListener(env->GetIsolate(), nullptr); |
| 1056 CheckDebuggerUnloaded(env->GetIsolate()); | 1067 CheckDebuggerUnloaded(env->GetIsolate()); |
| 1057 } | 1068 } |
| 1058 | 1069 |
| 1059 | 1070 |
| 1060 // Test that a break point can be set at an IC call location and survive a GC. | 1071 // Test that a break point can be set at an IC call location and survive a GC. |
| 1061 TEST(BreakPointConstructCallWithGC) { | 1072 TEST(BreakPointConstructCallWithGC) { |
| 1062 break_point_hit_count = 0; | 1073 break_point_hit_count = 0; |
| 1063 DebugLocalContext env; | 1074 DebugLocalContext env; |
| 1064 v8::HandleScope scope(env->GetIsolate()); | 1075 v8::HandleScope scope(env->GetIsolate()); |
| 1065 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 1076 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointCollectGarbage); |
| 1066 DebugEventBreakPointCollectGarbage); | |
| 1067 CompileRunChecked(env->GetIsolate(), "function bar(){ this.x = 1;}"); | 1077 CompileRunChecked(env->GetIsolate(), "function bar(){ this.x = 1;}"); |
| 1068 v8::Local<v8::Function> foo = | 1078 v8::Local<v8::Function> foo = |
| 1069 CompileFunction(&env, "function foo(){return new bar(1).x;}", "foo"); | 1079 CompileFunction(&env, "function foo(){return new bar(1).x;}", "foo"); |
| 1070 v8::Local<v8::Context> context = env.context(); | 1080 v8::Local<v8::Context> context = env.context(); |
| 1071 | 1081 |
| 1072 // Run without breakpoints. | 1082 // Run without breakpoints. |
| 1073 CHECK_EQ(1, foo->Call(context, env->Global(), 0, NULL) | 1083 CHECK_EQ(1, foo->Call(context, env->Global(), 0, NULL) |
| 1074 .ToLocalChecked() | 1084 .ToLocalChecked() |
| 1075 ->Int32Value(context) | 1085 ->Int32Value(context) |
| 1076 .FromJust()); | 1086 .FromJust()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1087 .ToLocalChecked() | 1097 .ToLocalChecked() |
| 1088 ->Int32Value(context) | 1098 ->Int32Value(context) |
| 1089 .FromJust()); | 1099 .FromJust()); |
| 1090 CHECK_EQ(2, break_point_hit_count); | 1100 CHECK_EQ(2, break_point_hit_count); |
| 1091 | 1101 |
| 1092 // Run without breakpoints. | 1102 // Run without breakpoints. |
| 1093 ClearBreakPoint(bp); | 1103 ClearBreakPoint(bp); |
| 1094 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 1104 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 1095 CHECK_EQ(2, break_point_hit_count); | 1105 CHECK_EQ(2, break_point_hit_count); |
| 1096 | 1106 |
| 1097 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 1107 SetDebugEventListener(env->GetIsolate(), nullptr); |
| 1098 CheckDebuggerUnloaded(env->GetIsolate()); | 1108 CheckDebuggerUnloaded(env->GetIsolate()); |
| 1099 } | 1109 } |
| 1100 | 1110 |
| 1101 | 1111 |
| 1102 // Test that a break point can be set at a return store location. | 1112 // Test that a break point can be set at a return store location. |
| 1103 TEST(BreakPointReturn) { | 1113 TEST(BreakPointReturn) { |
| 1104 break_point_hit_count = 0; | 1114 break_point_hit_count = 0; |
| 1105 DebugLocalContext env; | 1115 DebugLocalContext env; |
| 1106 v8::HandleScope scope(env->GetIsolate()); | 1116 v8::HandleScope scope(env->GetIsolate()); |
| 1107 | 1117 |
| 1108 // Create a functions for checking the source line and column when hitting | 1118 // Create a functions for checking the source line and column when hitting |
| 1109 // a break point. | 1119 // a break point. |
| 1110 frame_source_line = CompileFunction(&env, | 1120 frame_source_line = CompileFunction(&env, |
| 1111 frame_source_line_source, | 1121 frame_source_line_source, |
| 1112 "frame_source_line"); | 1122 "frame_source_line"); |
| 1113 frame_source_column = CompileFunction(&env, | 1123 frame_source_column = CompileFunction(&env, |
| 1114 frame_source_column_source, | 1124 frame_source_column_source, |
| 1115 "frame_source_column"); | 1125 "frame_source_column"); |
| 1116 | 1126 |
| 1117 | 1127 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount); |
| 1118 v8::Debug::SetDebugEventListener(env->GetIsolate(), | |
| 1119 DebugEventBreakPointHitCount); | |
| 1120 v8::Local<v8::Function> foo = | 1128 v8::Local<v8::Function> foo = |
| 1121 CompileFunction(&env, "function foo(){}", "foo"); | 1129 CompileFunction(&env, "function foo(){}", "foo"); |
| 1122 v8::Local<v8::Context> context = env.context(); | 1130 v8::Local<v8::Context> context = env.context(); |
| 1123 | 1131 |
| 1124 // Run without breakpoints. | 1132 // Run without breakpoints. |
| 1125 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 1133 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 1126 CHECK_EQ(0, break_point_hit_count); | 1134 CHECK_EQ(0, break_point_hit_count); |
| 1127 | 1135 |
| 1128 // Run with breakpoint | 1136 // Run with breakpoint |
| 1129 int bp = SetBreakPoint(foo, 0); | 1137 int bp = SetBreakPoint(foo, 0); |
| 1130 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 1138 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 1131 CHECK_EQ(1, break_point_hit_count); | 1139 CHECK_EQ(1, break_point_hit_count); |
| 1132 CHECK_EQ(0, last_source_line); | 1140 CHECK_EQ(0, last_source_line); |
| 1133 CHECK_EQ(15, last_source_column); | 1141 CHECK_EQ(15, last_source_column); |
| 1134 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 1142 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 1135 CHECK_EQ(2, break_point_hit_count); | 1143 CHECK_EQ(2, break_point_hit_count); |
| 1136 CHECK_EQ(0, last_source_line); | 1144 CHECK_EQ(0, last_source_line); |
| 1137 CHECK_EQ(15, last_source_column); | 1145 CHECK_EQ(15, last_source_column); |
| 1138 | 1146 |
| 1139 // Run without breakpoints. | 1147 // Run without breakpoints. |
| 1140 ClearBreakPoint(bp); | 1148 ClearBreakPoint(bp); |
| 1141 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 1149 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 1142 CHECK_EQ(2, break_point_hit_count); | 1150 CHECK_EQ(2, break_point_hit_count); |
| 1143 | 1151 |
| 1144 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 1152 SetDebugEventListener(env->GetIsolate(), nullptr); |
| 1145 CheckDebuggerUnloaded(env->GetIsolate()); | 1153 CheckDebuggerUnloaded(env->GetIsolate()); |
| 1146 } | 1154 } |
| 1147 | 1155 |
| 1148 | 1156 |
| 1149 static void CallWithBreakPoints(v8::Local<v8::Context> context, | 1157 static void CallWithBreakPoints(v8::Local<v8::Context> context, |
| 1150 v8::Local<v8::Object> recv, | 1158 v8::Local<v8::Object> recv, |
| 1151 v8::Local<v8::Function> f, | 1159 v8::Local<v8::Function> f, |
| 1152 int break_point_count, int call_count) { | 1160 int break_point_count, int call_count) { |
| 1153 break_point_hit_count = 0; | 1161 break_point_hit_count = 0; |
| 1154 for (int i = 0; i < call_count; i++) { | 1162 for (int i = 0; i < call_count; i++) { |
| 1155 f->Call(context, recv, 0, NULL).ToLocalChecked(); | 1163 f->Call(context, recv, 0, NULL).ToLocalChecked(); |
| 1156 CHECK_EQ((i + 1) * break_point_count, break_point_hit_count); | 1164 CHECK_EQ((i + 1) * break_point_count, break_point_hit_count); |
| 1157 } | 1165 } |
| 1158 } | 1166 } |
| 1159 | 1167 |
| 1160 | 1168 |
| 1161 // Test GC during break point processing. | 1169 // Test GC during break point processing. |
| 1162 TEST(GCDuringBreakPointProcessing) { | 1170 TEST(GCDuringBreakPointProcessing) { |
| 1163 break_point_hit_count = 0; | 1171 break_point_hit_count = 0; |
| 1164 DebugLocalContext env; | 1172 DebugLocalContext env; |
| 1165 v8::HandleScope scope(env->GetIsolate()); | 1173 v8::HandleScope scope(env->GetIsolate()); |
| 1166 v8::Local<v8::Context> context = env.context(); | 1174 v8::Local<v8::Context> context = env.context(); |
| 1167 | 1175 |
| 1168 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 1176 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointCollectGarbage); |
| 1169 DebugEventBreakPointCollectGarbage); | |
| 1170 v8::Local<v8::Function> foo; | 1177 v8::Local<v8::Function> foo; |
| 1171 | 1178 |
| 1172 // Test IC store break point with garbage collection. | 1179 // Test IC store break point with garbage collection. |
| 1173 foo = CompileFunction(&env, "function foo(){bar=0;}", "foo"); | 1180 foo = CompileFunction(&env, "function foo(){bar=0;}", "foo"); |
| 1174 SetBreakPoint(foo, 0); | 1181 SetBreakPoint(foo, 0); |
| 1175 CallWithBreakPoints(context, env->Global(), foo, 1, 10); | 1182 CallWithBreakPoints(context, env->Global(), foo, 1, 10); |
| 1176 | 1183 |
| 1177 // Test IC load break point with garbage collection. | 1184 // Test IC load break point with garbage collection. |
| 1178 foo = CompileFunction(&env, "bar=1;function foo(){var x=bar;}", "foo"); | 1185 foo = CompileFunction(&env, "bar=1;function foo(){var x=bar;}", "foo"); |
| 1179 SetBreakPoint(foo, 0); | 1186 SetBreakPoint(foo, 0); |
| 1180 CallWithBreakPoints(context, env->Global(), foo, 1, 10); | 1187 CallWithBreakPoints(context, env->Global(), foo, 1, 10); |
| 1181 | 1188 |
| 1182 // Test IC call break point with garbage collection. | 1189 // Test IC call break point with garbage collection. |
| 1183 foo = CompileFunction(&env, "function bar(){};function foo(){bar();}", "foo"); | 1190 foo = CompileFunction(&env, "function bar(){};function foo(){bar();}", "foo"); |
| 1184 SetBreakPoint(foo, 0); | 1191 SetBreakPoint(foo, 0); |
| 1185 CallWithBreakPoints(context, env->Global(), foo, 1, 10); | 1192 CallWithBreakPoints(context, env->Global(), foo, 1, 10); |
| 1186 | 1193 |
| 1187 // Test return break point with garbage collection. | 1194 // Test return break point with garbage collection. |
| 1188 foo = CompileFunction(&env, "function foo(){}", "foo"); | 1195 foo = CompileFunction(&env, "function foo(){}", "foo"); |
| 1189 SetBreakPoint(foo, 0); | 1196 SetBreakPoint(foo, 0); |
| 1190 CallWithBreakPoints(context, env->Global(), foo, 1, 25); | 1197 CallWithBreakPoints(context, env->Global(), foo, 1, 25); |
| 1191 | 1198 |
| 1192 // Test debug break slot break point with garbage collection. | 1199 // Test debug break slot break point with garbage collection. |
| 1193 foo = CompileFunction(&env, "function foo(){var a;}", "foo"); | 1200 foo = CompileFunction(&env, "function foo(){var a;}", "foo"); |
| 1194 SetBreakPoint(foo, 0); | 1201 SetBreakPoint(foo, 0); |
| 1195 CallWithBreakPoints(context, env->Global(), foo, 1, 25); | 1202 CallWithBreakPoints(context, env->Global(), foo, 1, 25); |
| 1196 | 1203 |
| 1197 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 1204 SetDebugEventListener(env->GetIsolate(), nullptr); |
| 1198 CheckDebuggerUnloaded(env->GetIsolate()); | 1205 CheckDebuggerUnloaded(env->GetIsolate()); |
| 1199 } | 1206 } |
| 1200 | 1207 |
| 1201 | 1208 |
| 1202 // Call the function three times with different garbage collections in between | 1209 // Call the function three times with different garbage collections in between |
| 1203 // and make sure that the break point survives. | 1210 // and make sure that the break point survives. |
| 1204 static void CallAndGC(v8::Local<v8::Context> context, | 1211 static void CallAndGC(v8::Local<v8::Context> context, |
| 1205 v8::Local<v8::Object> recv, v8::Local<v8::Function> f) { | 1212 v8::Local<v8::Object> recv, v8::Local<v8::Function> f) { |
| 1206 break_point_hit_count = 0; | 1213 break_point_hit_count = 0; |
| 1207 | 1214 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1223 } | 1230 } |
| 1224 | 1231 |
| 1225 | 1232 |
| 1226 // Test that a break point can be set at a return store location. | 1233 // Test that a break point can be set at a return store location. |
| 1227 TEST(BreakPointSurviveGC) { | 1234 TEST(BreakPointSurviveGC) { |
| 1228 break_point_hit_count = 0; | 1235 break_point_hit_count = 0; |
| 1229 DebugLocalContext env; | 1236 DebugLocalContext env; |
| 1230 v8::HandleScope scope(env->GetIsolate()); | 1237 v8::HandleScope scope(env->GetIsolate()); |
| 1231 v8::Local<v8::Context> context = env.context(); | 1238 v8::Local<v8::Context> context = env.context(); |
| 1232 | 1239 |
| 1233 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 1240 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount); |
| 1234 DebugEventBreakPointHitCount); | |
| 1235 v8::Local<v8::Function> foo; | 1241 v8::Local<v8::Function> foo; |
| 1236 | 1242 |
| 1237 // Test IC store break point with garbage collection. | 1243 // Test IC store break point with garbage collection. |
| 1238 { | 1244 { |
| 1239 CompileFunction(&env, "function foo(){}", "foo"); | 1245 CompileFunction(&env, "function foo(){}", "foo"); |
| 1240 foo = CompileFunction(&env, "function foo(){bar=0;}", "foo"); | 1246 foo = CompileFunction(&env, "function foo(){bar=0;}", "foo"); |
| 1241 SetBreakPoint(foo, 0); | 1247 SetBreakPoint(foo, 0); |
| 1242 } | 1248 } |
| 1243 CallAndGC(context, env->Global(), foo); | 1249 CallAndGC(context, env->Global(), foo); |
| 1244 | 1250 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1269 CallAndGC(context, env->Global(), foo); | 1275 CallAndGC(context, env->Global(), foo); |
| 1270 | 1276 |
| 1271 // Test non IC break point with garbage collection. | 1277 // Test non IC break point with garbage collection. |
| 1272 { | 1278 { |
| 1273 CompileFunction(&env, "function foo(){}", "foo"); | 1279 CompileFunction(&env, "function foo(){}", "foo"); |
| 1274 foo = CompileFunction(&env, "function foo(){var bar=0;}", "foo"); | 1280 foo = CompileFunction(&env, "function foo(){var bar=0;}", "foo"); |
| 1275 SetBreakPoint(foo, 0); | 1281 SetBreakPoint(foo, 0); |
| 1276 } | 1282 } |
| 1277 CallAndGC(context, env->Global(), foo); | 1283 CallAndGC(context, env->Global(), foo); |
| 1278 | 1284 |
| 1279 | 1285 SetDebugEventListener(env->GetIsolate(), nullptr); |
| 1280 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | |
| 1281 CheckDebuggerUnloaded(env->GetIsolate()); | 1286 CheckDebuggerUnloaded(env->GetIsolate()); |
| 1282 } | 1287 } |
| 1283 | 1288 |
| 1284 | 1289 |
| 1285 // Test that break points can be set using the global Debug object. | 1290 // Test that break points can be set using the global Debug object. |
| 1286 TEST(BreakPointThroughJavaScript) { | 1291 TEST(BreakPointThroughJavaScript) { |
| 1287 break_point_hit_count = 0; | 1292 break_point_hit_count = 0; |
| 1288 DebugLocalContext env; | 1293 DebugLocalContext env; |
| 1289 v8::Isolate* isolate = env->GetIsolate(); | 1294 v8::Isolate* isolate = env->GetIsolate(); |
| 1290 v8::HandleScope scope(isolate); | 1295 v8::HandleScope scope(isolate); |
| 1291 v8::Local<v8::Context> context = env.context(); | 1296 v8::Local<v8::Context> context = env.context(); |
| 1292 env.ExposeDebug(); | 1297 env.ExposeDebug(); |
| 1293 | 1298 |
| 1294 v8::Debug::SetDebugEventListener(isolate, DebugEventBreakPointHitCount); | 1299 SetDebugEventListener(isolate, DebugEventBreakPointHitCount); |
| 1295 CompileRunChecked(isolate, "function bar(){}"); | 1300 CompileRunChecked(isolate, "function bar(){}"); |
| 1296 CompileFunction(isolate, "function foo(){bar();bar();}", "foo"); | 1301 CompileFunction(isolate, "function foo(){bar();bar();}", "foo"); |
| 1297 // 012345678901234567890 | 1302 // 012345678901234567890 |
| 1298 // 1 2 | 1303 // 1 2 |
| 1299 // Break points are set at position 3 and 9 | 1304 // Break points are set at position 3 and 9 |
| 1300 v8::Local<v8::String> source = v8_str(env->GetIsolate(), "foo()"); | 1305 v8::Local<v8::String> source = v8_str(env->GetIsolate(), "foo()"); |
| 1301 v8::Local<v8::Script> foo = | 1306 v8::Local<v8::Script> foo = |
| 1302 v8::Script::Compile(context, source).ToLocalChecked(); | 1307 v8::Script::Compile(context, source).ToLocalChecked(); |
| 1303 | 1308 |
| 1304 CHECK_EQ(0, break_point_hit_count); | 1309 CHECK_EQ(0, break_point_hit_count); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1322 foo->Run(context).ToLocalChecked(); | 1327 foo->Run(context).ToLocalChecked(); |
| 1323 CHECK_EQ(7, break_point_hit_count); | 1328 CHECK_EQ(7, break_point_hit_count); |
| 1324 foo->Run(context).ToLocalChecked(); | 1329 foo->Run(context).ToLocalChecked(); |
| 1325 CHECK_EQ(8, break_point_hit_count); | 1330 CHECK_EQ(8, break_point_hit_count); |
| 1326 | 1331 |
| 1327 // Run without breakpoints. | 1332 // Run without breakpoints. |
| 1328 ClearBreakPointFromJS(env->GetIsolate(), bp1); | 1333 ClearBreakPointFromJS(env->GetIsolate(), bp1); |
| 1329 foo->Run(context).ToLocalChecked(); | 1334 foo->Run(context).ToLocalChecked(); |
| 1330 CHECK_EQ(8, break_point_hit_count); | 1335 CHECK_EQ(8, break_point_hit_count); |
| 1331 | 1336 |
| 1332 v8::Debug::SetDebugEventListener(isolate, nullptr); | 1337 SetDebugEventListener(isolate, nullptr); |
| 1333 CheckDebuggerUnloaded(isolate); | 1338 CheckDebuggerUnloaded(isolate); |
| 1334 | 1339 |
| 1335 // Make sure that the break point numbers are consecutive. | 1340 // Make sure that the break point numbers are consecutive. |
| 1336 CHECK_EQ(1, bp1); | 1341 CHECK_EQ(1, bp1); |
| 1337 CHECK_EQ(2, bp2); | 1342 CHECK_EQ(2, bp2); |
| 1338 } | 1343 } |
| 1339 | 1344 |
| 1340 | 1345 |
| 1341 // Test that break points on scripts identified by name can be set using the | 1346 // Test that break points on scripts identified by name can be set using the |
| 1342 // global Debug object. | 1347 // global Debug object. |
| 1343 TEST(ScriptBreakPointByNameThroughJavaScript) { | 1348 TEST(ScriptBreakPointByNameThroughJavaScript) { |
| 1344 break_point_hit_count = 0; | 1349 break_point_hit_count = 0; |
| 1345 DebugLocalContext env; | 1350 DebugLocalContext env; |
| 1346 v8::Isolate* isolate = env->GetIsolate(); | 1351 v8::Isolate* isolate = env->GetIsolate(); |
| 1347 v8::HandleScope scope(isolate); | 1352 v8::HandleScope scope(isolate); |
| 1348 v8::Local<v8::Context> context = env.context(); | 1353 v8::Local<v8::Context> context = env.context(); |
| 1349 env.ExposeDebug(); | 1354 env.ExposeDebug(); |
| 1350 | 1355 |
| 1351 v8::Debug::SetDebugEventListener(isolate, DebugEventBreakPointHitCount); | 1356 SetDebugEventListener(isolate, DebugEventBreakPointHitCount); |
| 1352 | 1357 |
| 1353 v8::Local<v8::String> script = v8_str(isolate, | 1358 v8::Local<v8::String> script = v8_str(isolate, |
| 1354 "function f() {\n" | 1359 "function f() {\n" |
| 1355 " function h() {\n" | 1360 " function h() {\n" |
| 1356 " a = 0; // line 2\n" | 1361 " a = 0; // line 2\n" |
| 1357 " }\n" | 1362 " }\n" |
| 1358 " b = 1; // line 4\n" | 1363 " b = 1; // line 4\n" |
| 1359 " return h();\n" | 1364 " return h();\n" |
| 1360 "}\n" | 1365 "}\n" |
| 1361 "\n" | 1366 "\n" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 ClearBreakPointFromJS(isolate, sbp2); | 1432 ClearBreakPointFromJS(isolate, sbp2); |
| 1428 ClearBreakPointFromJS(isolate, sbp3); | 1433 ClearBreakPointFromJS(isolate, sbp3); |
| 1429 ClearBreakPointFromJS(isolate, sbp4); | 1434 ClearBreakPointFromJS(isolate, sbp4); |
| 1430 ClearBreakPointFromJS(isolate, sbp5); | 1435 ClearBreakPointFromJS(isolate, sbp5); |
| 1431 ClearBreakPointFromJS(isolate, sbp6); | 1436 ClearBreakPointFromJS(isolate, sbp6); |
| 1432 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 1437 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 1433 CHECK_EQ(0, break_point_hit_count); | 1438 CHECK_EQ(0, break_point_hit_count); |
| 1434 g->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 1439 g->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 1435 CHECK_EQ(0, break_point_hit_count); | 1440 CHECK_EQ(0, break_point_hit_count); |
| 1436 | 1441 |
| 1437 v8::Debug::SetDebugEventListener(isolate, nullptr); | 1442 SetDebugEventListener(isolate, nullptr); |
| 1438 CheckDebuggerUnloaded(isolate); | 1443 CheckDebuggerUnloaded(isolate); |
| 1439 | 1444 |
| 1440 // Make sure that the break point numbers are consecutive. | 1445 // Make sure that the break point numbers are consecutive. |
| 1441 CHECK_EQ(1, sbp1); | 1446 CHECK_EQ(1, sbp1); |
| 1442 CHECK_EQ(2, sbp2); | 1447 CHECK_EQ(2, sbp2); |
| 1443 CHECK_EQ(3, sbp3); | 1448 CHECK_EQ(3, sbp3); |
| 1444 CHECK_EQ(4, sbp4); | 1449 CHECK_EQ(4, sbp4); |
| 1445 CHECK_EQ(5, sbp5); | 1450 CHECK_EQ(5, sbp5); |
| 1446 CHECK_EQ(6, sbp6); | 1451 CHECK_EQ(6, sbp6); |
| 1447 } | 1452 } |
| 1448 | 1453 |
| 1449 | 1454 |
| 1450 TEST(ScriptBreakPointByIdThroughJavaScript) { | 1455 TEST(ScriptBreakPointByIdThroughJavaScript) { |
| 1451 break_point_hit_count = 0; | 1456 break_point_hit_count = 0; |
| 1452 DebugLocalContext env; | 1457 DebugLocalContext env; |
| 1453 v8::Isolate* isolate = env->GetIsolate(); | 1458 v8::Isolate* isolate = env->GetIsolate(); |
| 1454 v8::HandleScope scope(isolate); | 1459 v8::HandleScope scope(isolate); |
| 1455 v8::Local<v8::Context> context = env.context(); | 1460 v8::Local<v8::Context> context = env.context(); |
| 1456 env.ExposeDebug(); | 1461 env.ExposeDebug(); |
| 1457 | 1462 |
| 1458 v8::Debug::SetDebugEventListener(isolate, DebugEventBreakPointHitCount); | 1463 SetDebugEventListener(isolate, DebugEventBreakPointHitCount); |
| 1459 | 1464 |
| 1460 v8::Local<v8::String> source = v8_str(isolate, | 1465 v8::Local<v8::String> source = v8_str(isolate, |
| 1461 "function f() {\n" | 1466 "function f() {\n" |
| 1462 " function h() {\n" | 1467 " function h() {\n" |
| 1463 " a = 0; // line 2\n" | 1468 " a = 0; // line 2\n" |
| 1464 " }\n" | 1469 " }\n" |
| 1465 " b = 1; // line 4\n" | 1470 " b = 1; // line 4\n" |
| 1466 " return h();\n" | 1471 " return h();\n" |
| 1467 "}\n" | 1472 "}\n" |
| 1468 "\n" | 1473 "\n" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 ClearBreakPointFromJS(env->GetIsolate(), sbp2); | 1541 ClearBreakPointFromJS(env->GetIsolate(), sbp2); |
| 1537 ClearBreakPointFromJS(env->GetIsolate(), sbp3); | 1542 ClearBreakPointFromJS(env->GetIsolate(), sbp3); |
| 1538 ClearBreakPointFromJS(env->GetIsolate(), sbp4); | 1543 ClearBreakPointFromJS(env->GetIsolate(), sbp4); |
| 1539 ClearBreakPointFromJS(env->GetIsolate(), sbp5); | 1544 ClearBreakPointFromJS(env->GetIsolate(), sbp5); |
| 1540 ClearBreakPointFromJS(env->GetIsolate(), sbp6); | 1545 ClearBreakPointFromJS(env->GetIsolate(), sbp6); |
| 1541 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 1546 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 1542 CHECK_EQ(0, break_point_hit_count); | 1547 CHECK_EQ(0, break_point_hit_count); |
| 1543 g->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 1548 g->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 1544 CHECK_EQ(0, break_point_hit_count); | 1549 CHECK_EQ(0, break_point_hit_count); |
| 1545 | 1550 |
| 1546 v8::Debug::SetDebugEventListener(isolate, nullptr); | 1551 SetDebugEventListener(isolate, nullptr); |
| 1547 CheckDebuggerUnloaded(isolate); | 1552 CheckDebuggerUnloaded(isolate); |
| 1548 | 1553 |
| 1549 // Make sure that the break point numbers are consecutive. | 1554 // Make sure that the break point numbers are consecutive. |
| 1550 CHECK_EQ(1, sbp1); | 1555 CHECK_EQ(1, sbp1); |
| 1551 CHECK_EQ(2, sbp2); | 1556 CHECK_EQ(2, sbp2); |
| 1552 CHECK_EQ(3, sbp3); | 1557 CHECK_EQ(3, sbp3); |
| 1553 CHECK_EQ(4, sbp4); | 1558 CHECK_EQ(4, sbp4); |
| 1554 CHECK_EQ(5, sbp5); | 1559 CHECK_EQ(5, sbp5); |
| 1555 CHECK_EQ(6, sbp6); | 1560 CHECK_EQ(6, sbp6); |
| 1556 } | 1561 } |
| 1557 | 1562 |
| 1558 | 1563 |
| 1559 // Test conditional script break points. | 1564 // Test conditional script break points. |
| 1560 TEST(EnableDisableScriptBreakPoint) { | 1565 TEST(EnableDisableScriptBreakPoint) { |
| 1561 break_point_hit_count = 0; | 1566 break_point_hit_count = 0; |
| 1562 DebugLocalContext env; | 1567 DebugLocalContext env; |
| 1563 v8::Isolate* isolate = env->GetIsolate(); | 1568 v8::Isolate* isolate = env->GetIsolate(); |
| 1564 v8::HandleScope scope(isolate); | 1569 v8::HandleScope scope(isolate); |
| 1565 v8::Local<v8::Context> context = env.context(); | 1570 v8::Local<v8::Context> context = env.context(); |
| 1566 env.ExposeDebug(); | 1571 env.ExposeDebug(); |
| 1567 | 1572 |
| 1568 v8::Debug::SetDebugEventListener(isolate, DebugEventBreakPointHitCount); | 1573 SetDebugEventListener(isolate, DebugEventBreakPointHitCount); |
| 1569 | 1574 |
| 1570 v8::Local<v8::String> script = v8_str(isolate, | 1575 v8::Local<v8::String> script = v8_str(isolate, |
| 1571 "function f() {\n" | 1576 "function f() {\n" |
| 1572 " a = 0; // line 1\n" | 1577 " a = 0; // line 1\n" |
| 1573 "};"); | 1578 "};"); |
| 1574 | 1579 |
| 1575 // Compile the script and get function f. | 1580 // Compile the script and get function f. |
| 1576 v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str(isolate, "test")); | 1581 v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str(isolate, "test")); |
| 1577 v8::Script::Compile(context, script, &origin) | 1582 v8::Script::Compile(context, script, &origin) |
| 1578 .ToLocalChecked() | 1583 .ToLocalChecked() |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1594 CHECK_EQ(1, break_point_hit_count); | 1599 CHECK_EQ(1, break_point_hit_count); |
| 1595 | 1600 |
| 1596 EnableScriptBreakPointFromJS(isolate, sbp); | 1601 EnableScriptBreakPointFromJS(isolate, sbp); |
| 1597 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 1602 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 1598 CHECK_EQ(2, break_point_hit_count); | 1603 CHECK_EQ(2, break_point_hit_count); |
| 1599 | 1604 |
| 1600 DisableScriptBreakPointFromJS(isolate, sbp); | 1605 DisableScriptBreakPointFromJS(isolate, sbp); |
| 1601 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 1606 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 1602 CHECK_EQ(2, break_point_hit_count); | 1607 CHECK_EQ(2, break_point_hit_count); |
| 1603 | 1608 |
| 1604 v8::Debug::SetDebugEventListener(isolate, nullptr); | 1609 SetDebugEventListener(isolate, nullptr); |
| 1605 CheckDebuggerUnloaded(isolate); | 1610 CheckDebuggerUnloaded(isolate); |
| 1606 } | 1611 } |
| 1607 | 1612 |
| 1608 | 1613 |
| 1609 // Test conditional script break points. | 1614 // Test conditional script break points. |
| 1610 TEST(ConditionalScriptBreakPoint) { | 1615 TEST(ConditionalScriptBreakPoint) { |
| 1611 break_point_hit_count = 0; | 1616 break_point_hit_count = 0; |
| 1612 DebugLocalContext env; | 1617 DebugLocalContext env; |
| 1613 v8::HandleScope scope(env->GetIsolate()); | 1618 v8::HandleScope scope(env->GetIsolate()); |
| 1614 env.ExposeDebug(); | 1619 env.ExposeDebug(); |
| 1615 | 1620 |
| 1616 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 1621 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount); |
| 1617 DebugEventBreakPointHitCount); | |
| 1618 | 1622 |
| 1619 v8::Local<v8::String> script = v8_str(env->GetIsolate(), | 1623 v8::Local<v8::String> script = v8_str(env->GetIsolate(), |
| 1620 "count = 0;\n" | 1624 "count = 0;\n" |
| 1621 "function f() {\n" | 1625 "function f() {\n" |
| 1622 " g(count++); // line 2\n" | 1626 " g(count++); // line 2\n" |
| 1623 "};\n" | 1627 "};\n" |
| 1624 "function g(x) {\n" | 1628 "function g(x) {\n" |
| 1625 " var a=x; // line 5\n" | 1629 " var a=x; // line 5\n" |
| 1626 "};"); | 1630 "};"); |
| 1627 | 1631 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1651 f->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); | 1655 f->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); |
| 1652 CHECK_EQ(1, break_point_hit_count); | 1656 CHECK_EQ(1, break_point_hit_count); |
| 1653 | 1657 |
| 1654 ChangeScriptBreakPointConditionFromJS(env->GetIsolate(), sbp1, "x % 2 == 0"); | 1658 ChangeScriptBreakPointConditionFromJS(env->GetIsolate(), sbp1, "x % 2 == 0"); |
| 1655 break_point_hit_count = 0; | 1659 break_point_hit_count = 0; |
| 1656 for (int i = 0; i < 10; i++) { | 1660 for (int i = 0; i < 10; i++) { |
| 1657 f->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); | 1661 f->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); |
| 1658 } | 1662 } |
| 1659 CHECK_EQ(5, break_point_hit_count); | 1663 CHECK_EQ(5, break_point_hit_count); |
| 1660 | 1664 |
| 1661 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 1665 SetDebugEventListener(env->GetIsolate(), nullptr); |
| 1662 CheckDebuggerUnloaded(env->GetIsolate()); | 1666 CheckDebuggerUnloaded(env->GetIsolate()); |
| 1663 } | 1667 } |
| 1664 | 1668 |
| 1665 | 1669 |
| 1666 // Test when several scripts has the same script data | 1670 // Test when several scripts has the same script data |
| 1667 TEST(ScriptBreakPointMultiple) { | 1671 TEST(ScriptBreakPointMultiple) { |
| 1668 break_point_hit_count = 0; | 1672 break_point_hit_count = 0; |
| 1669 DebugLocalContext env; | 1673 DebugLocalContext env; |
| 1670 v8::HandleScope scope(env->GetIsolate()); | 1674 v8::HandleScope scope(env->GetIsolate()); |
| 1671 env.ExposeDebug(); | 1675 env.ExposeDebug(); |
| 1672 | 1676 |
| 1673 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 1677 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount); |
| 1674 DebugEventBreakPointHitCount); | |
| 1675 | 1678 |
| 1676 v8::Local<v8::Context> context = env.context(); | 1679 v8::Local<v8::Context> context = env.context(); |
| 1677 v8::Local<v8::Function> f; | 1680 v8::Local<v8::Function> f; |
| 1678 v8::Local<v8::String> script_f = v8_str(env->GetIsolate(), | 1681 v8::Local<v8::String> script_f = v8_str(env->GetIsolate(), |
| 1679 "function f() {\n" | 1682 "function f() {\n" |
| 1680 " a = 0; // line 1\n" | 1683 " a = 0; // line 1\n" |
| 1681 "}"); | 1684 "}"); |
| 1682 | 1685 |
| 1683 v8::Local<v8::Function> g; | 1686 v8::Local<v8::Function> g; |
| 1684 v8::Local<v8::String> script_g = v8_str(env->GetIsolate(), | 1687 v8::Local<v8::String> script_g = v8_str(env->GetIsolate(), |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1728 // Set script break point with the scripts loaded. | 1731 // Set script break point with the scripts loaded. |
| 1729 sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0); | 1732 sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0); |
| 1730 | 1733 |
| 1731 // Call f and g and check that the script break point is active. | 1734 // Call f and g and check that the script break point is active. |
| 1732 break_point_hit_count = 0; | 1735 break_point_hit_count = 0; |
| 1733 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 1736 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 1734 CHECK_EQ(1, break_point_hit_count); | 1737 CHECK_EQ(1, break_point_hit_count); |
| 1735 g->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 1738 g->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 1736 CHECK_EQ(2, break_point_hit_count); | 1739 CHECK_EQ(2, break_point_hit_count); |
| 1737 | 1740 |
| 1738 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 1741 SetDebugEventListener(env->GetIsolate(), nullptr); |
| 1739 CheckDebuggerUnloaded(env->GetIsolate()); | 1742 CheckDebuggerUnloaded(env->GetIsolate()); |
| 1740 } | 1743 } |
| 1741 | 1744 |
| 1742 | 1745 |
| 1743 // Test the script origin which has both name and line offset. | 1746 // Test the script origin which has both name and line offset. |
| 1744 TEST(ScriptBreakPointLineOffset) { | 1747 TEST(ScriptBreakPointLineOffset) { |
| 1745 break_point_hit_count = 0; | 1748 break_point_hit_count = 0; |
| 1746 DebugLocalContext env; | 1749 DebugLocalContext env; |
| 1747 v8::HandleScope scope(env->GetIsolate()); | 1750 v8::HandleScope scope(env->GetIsolate()); |
| 1748 env.ExposeDebug(); | 1751 env.ExposeDebug(); |
| 1749 | 1752 |
| 1750 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 1753 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount); |
| 1751 DebugEventBreakPointHitCount); | |
| 1752 | 1754 |
| 1753 v8::Local<v8::Context> context = env.context(); | 1755 v8::Local<v8::Context> context = env.context(); |
| 1754 v8::Local<v8::Function> f; | 1756 v8::Local<v8::Function> f; |
| 1755 v8::Local<v8::String> script = | 1757 v8::Local<v8::String> script = |
| 1756 v8_str(env->GetIsolate(), | 1758 v8_str(env->GetIsolate(), |
| 1757 "function f() {\n" | 1759 "function f() {\n" |
| 1758 " a = 0; // line 8 as this script has line offset 7\n" | 1760 " a = 0; // line 8 as this script has line offset 7\n" |
| 1759 " b = 0; // line 9 as this script has line offset 7\n" | 1761 " b = 0; // line 9 as this script has line offset 7\n" |
| 1760 "}"); | 1762 "}"); |
| 1761 | 1763 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1794 CHECK_EQ(0, break_point_hit_count); | 1796 CHECK_EQ(0, break_point_hit_count); |
| 1795 | 1797 |
| 1796 // Set a script break point with the script loaded. | 1798 // Set a script break point with the script loaded. |
| 1797 sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 9, 0); | 1799 sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 9, 0); |
| 1798 | 1800 |
| 1799 // Call f and check that the script break point is active. | 1801 // Call f and check that the script break point is active. |
| 1800 break_point_hit_count = 0; | 1802 break_point_hit_count = 0; |
| 1801 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 1803 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 1802 CHECK_EQ(1, break_point_hit_count); | 1804 CHECK_EQ(1, break_point_hit_count); |
| 1803 | 1805 |
| 1804 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 1806 SetDebugEventListener(env->GetIsolate(), nullptr); |
| 1805 CheckDebuggerUnloaded(env->GetIsolate()); | 1807 CheckDebuggerUnloaded(env->GetIsolate()); |
| 1806 } | 1808 } |
| 1807 | 1809 |
| 1808 | 1810 |
| 1809 // Test script break points set on lines. | 1811 // Test script break points set on lines. |
| 1810 TEST(ScriptBreakPointLine) { | 1812 TEST(ScriptBreakPointLine) { |
| 1811 DebugLocalContext env; | 1813 DebugLocalContext env; |
| 1812 v8::HandleScope scope(env->GetIsolate()); | 1814 v8::HandleScope scope(env->GetIsolate()); |
| 1813 env.ExposeDebug(); | 1815 env.ExposeDebug(); |
| 1814 | 1816 |
| 1815 // Create a function for checking the function when hitting a break point. | 1817 // Create a function for checking the function when hitting a break point. |
| 1816 frame_function_name = CompileFunction(&env, | 1818 frame_function_name = CompileFunction(&env, |
| 1817 frame_function_name_source, | 1819 frame_function_name_source, |
| 1818 "frame_function_name"); | 1820 "frame_function_name"); |
| 1819 | 1821 |
| 1820 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 1822 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount); |
| 1821 DebugEventBreakPointHitCount); | |
| 1822 | 1823 |
| 1823 v8::Local<v8::Context> context = env.context(); | 1824 v8::Local<v8::Context> context = env.context(); |
| 1824 v8::Local<v8::Function> f; | 1825 v8::Local<v8::Function> f; |
| 1825 v8::Local<v8::Function> g; | 1826 v8::Local<v8::Function> g; |
| 1826 v8::Local<v8::String> script = | 1827 v8::Local<v8::String> script = |
| 1827 v8_str(env->GetIsolate(), | 1828 v8_str(env->GetIsolate(), |
| 1828 "a = 0 // line 0\n" | 1829 "a = 0 // line 0\n" |
| 1829 "function f() {\n" | 1830 "function f() {\n" |
| 1830 " a = 1; // line 2\n" | 1831 " a = 1; // line 2\n" |
| 1831 "}\n" | 1832 "}\n" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1909 v8::Script::Compile(context, script, &origin) | 1910 v8::Script::Compile(context, script, &origin) |
| 1910 .ToLocalChecked() | 1911 .ToLocalChecked() |
| 1911 ->Run(context) | 1912 ->Run(context) |
| 1912 .ToLocalChecked(); | 1913 .ToLocalChecked(); |
| 1913 CHECK_EQ(0, break_point_hit_count); | 1914 CHECK_EQ(0, break_point_hit_count); |
| 1914 | 1915 |
| 1915 ClearBreakPointFromJS(env->GetIsolate(), sbp1); | 1916 ClearBreakPointFromJS(env->GetIsolate(), sbp1); |
| 1916 ClearBreakPointFromJS(env->GetIsolate(), sbp5); | 1917 ClearBreakPointFromJS(env->GetIsolate(), sbp5); |
| 1917 ClearBreakPointFromJS(env->GetIsolate(), sbp6); | 1918 ClearBreakPointFromJS(env->GetIsolate(), sbp6); |
| 1918 | 1919 |
| 1919 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 1920 SetDebugEventListener(env->GetIsolate(), nullptr); |
| 1920 CheckDebuggerUnloaded(env->GetIsolate()); | 1921 CheckDebuggerUnloaded(env->GetIsolate()); |
| 1921 } | 1922 } |
| 1922 | 1923 |
| 1923 | 1924 |
| 1924 // Test top level script break points set on lines. | 1925 // Test top level script break points set on lines. |
| 1925 TEST(ScriptBreakPointLineTopLevel) { | 1926 TEST(ScriptBreakPointLineTopLevel) { |
| 1926 DebugLocalContext env; | 1927 DebugLocalContext env; |
| 1927 v8::HandleScope scope(env->GetIsolate()); | 1928 v8::HandleScope scope(env->GetIsolate()); |
| 1928 env.ExposeDebug(); | 1929 env.ExposeDebug(); |
| 1929 | 1930 |
| 1930 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 1931 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount); |
| 1931 DebugEventBreakPointHitCount); | |
| 1932 | 1932 |
| 1933 v8::Local<v8::Context> context = env.context(); | 1933 v8::Local<v8::Context> context = env.context(); |
| 1934 v8::Local<v8::String> script = | 1934 v8::Local<v8::String> script = |
| 1935 v8_str(env->GetIsolate(), | 1935 v8_str(env->GetIsolate(), |
| 1936 "function f() {\n" | 1936 "function f() {\n" |
| 1937 " a = 1; // line 1\n" | 1937 " a = 1; // line 1\n" |
| 1938 "}\n" | 1938 "}\n" |
| 1939 "a = 2; // line 3\n"); | 1939 "a = 2; // line 3\n"); |
| 1940 v8::Local<v8::Function> f; | 1940 v8::Local<v8::Function> f; |
| 1941 { | 1941 { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1954 // Call f and check that there was no break points. | 1954 // Call f and check that there was no break points. |
| 1955 break_point_hit_count = 0; | 1955 break_point_hit_count = 0; |
| 1956 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 1956 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 1957 CHECK_EQ(0, break_point_hit_count); | 1957 CHECK_EQ(0, break_point_hit_count); |
| 1958 | 1958 |
| 1959 // Recompile and run script and check that break point was not reapplied. | 1959 // Recompile and run script and check that break point was not reapplied. |
| 1960 break_point_hit_count = 0; | 1960 break_point_hit_count = 0; |
| 1961 CompileRunWithOrigin(script, "test.html"); | 1961 CompileRunWithOrigin(script, "test.html"); |
| 1962 CHECK_EQ(0, break_point_hit_count); | 1962 CHECK_EQ(0, break_point_hit_count); |
| 1963 | 1963 |
| 1964 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 1964 SetDebugEventListener(env->GetIsolate(), nullptr); |
| 1965 CheckDebuggerUnloaded(env->GetIsolate()); | 1965 CheckDebuggerUnloaded(env->GetIsolate()); |
| 1966 } | 1966 } |
| 1967 | 1967 |
| 1968 | 1968 |
| 1969 // Test that it is possible to add and remove break points in a top level | 1969 // Test that it is possible to add and remove break points in a top level |
| 1970 // function which has no references but has not been collected yet. | 1970 // function which has no references but has not been collected yet. |
| 1971 TEST(ScriptBreakPointTopLevelCrash) { | 1971 TEST(ScriptBreakPointTopLevelCrash) { |
| 1972 DebugLocalContext env; | 1972 DebugLocalContext env; |
| 1973 v8::HandleScope scope(env->GetIsolate()); | 1973 v8::HandleScope scope(env->GetIsolate()); |
| 1974 env.ExposeDebug(); | 1974 env.ExposeDebug(); |
| 1975 | 1975 |
| 1976 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 1976 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount); |
| 1977 DebugEventBreakPointHitCount); | |
| 1978 | 1977 |
| 1979 CompileRunWithOrigin( | 1978 CompileRunWithOrigin( |
| 1980 "function f() {\n" | 1979 "function f() {\n" |
| 1981 " return 0;\n" | 1980 " return 0;\n" |
| 1982 "}\n", | 1981 "}\n", |
| 1983 "test.html"); | 1982 "test.html"); |
| 1984 int sbp1 = | 1983 int sbp1 = |
| 1985 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 1, -1); | 1984 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 1, -1); |
| 1986 break_point_hit_count = 0; | 1985 break_point_hit_count = 0; |
| 1987 | 1986 |
| 1988 CompileRun("f();"); | 1987 CompileRun("f();"); |
| 1989 | 1988 |
| 1990 CHECK_EQ(1, break_point_hit_count); | 1989 CHECK_EQ(1, break_point_hit_count); |
| 1991 | 1990 |
| 1992 int sbp2 = | 1991 int sbp2 = |
| 1993 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1); | 1992 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1); |
| 1994 ClearBreakPointFromJS(env->GetIsolate(), sbp1); | 1993 ClearBreakPointFromJS(env->GetIsolate(), sbp1); |
| 1995 ClearBreakPointFromJS(env->GetIsolate(), sbp2); | 1994 ClearBreakPointFromJS(env->GetIsolate(), sbp2); |
| 1996 | 1995 |
| 1997 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 1996 SetDebugEventListener(env->GetIsolate(), nullptr); |
| 1998 CheckDebuggerUnloaded(env->GetIsolate()); | 1997 CheckDebuggerUnloaded(env->GetIsolate()); |
| 1999 } | 1998 } |
| 2000 | 1999 |
| 2001 | 2000 |
| 2002 // Test that it is possible to remove the last break point for a function | 2001 // Test that it is possible to remove the last break point for a function |
| 2003 // inside the break handling of that break point. | 2002 // inside the break handling of that break point. |
| 2004 TEST(RemoveBreakPointInBreak) { | 2003 TEST(RemoveBreakPointInBreak) { |
| 2005 DebugLocalContext env; | 2004 DebugLocalContext env; |
| 2006 v8::HandleScope scope(env->GetIsolate()); | 2005 v8::HandleScope scope(env->GetIsolate()); |
| 2007 | 2006 |
| (...skipping 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3947 v8::Number::New(isolate, 1), v8::Number::New(isolate, 1), | 3946 v8::Number::New(isolate, 1), v8::Number::New(isolate, 1), |
| 3948 v8::Number::New(isolate, 1), v8::Number::New(isolate, 1)}; | 3947 v8::Number::New(isolate, 1), v8::Number::New(isolate, 1)}; |
| 3949 | 3948 |
| 3950 // Call all functions to make sure that they are compiled. | 3949 // Call all functions to make sure that they are compiled. |
| 3951 f0->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 3950 f0->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 3952 f1->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 3951 f1->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 3953 f2->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 3952 f2->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 3954 f3->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 3953 f3->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 3955 | 3954 |
| 3956 // Set the debug break flag. | 3955 // Set the debug break flag. |
| 3957 v8::Debug::DebugBreak(env->GetIsolate()); | 3956 v8::debug::DebugBreak(env->GetIsolate()); |
| 3958 | 3957 |
| 3959 // Call all functions with different argument count. | 3958 // Call all functions with different argument count. |
| 3960 break_point_hit_count = 0; | 3959 break_point_hit_count = 0; |
| 3961 for (unsigned int i = 0; i < arraysize(argv); i++) { | 3960 for (unsigned int i = 0; i < arraysize(argv); i++) { |
| 3962 f0->Call(context, env->Global(), i, argv).ToLocalChecked(); | 3961 f0->Call(context, env->Global(), i, argv).ToLocalChecked(); |
| 3963 f1->Call(context, env->Global(), i, argv).ToLocalChecked(); | 3962 f1->Call(context, env->Global(), i, argv).ToLocalChecked(); |
| 3964 f2->Call(context, env->Global(), i, argv).ToLocalChecked(); | 3963 f2->Call(context, env->Global(), i, argv).ToLocalChecked(); |
| 3965 f3->Call(context, env->Global(), i, argv).ToLocalChecked(); | 3964 f3->Call(context, env->Global(), i, argv).ToLocalChecked(); |
| 3966 } | 3965 } |
| 3967 | 3966 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3982 | 3981 |
| 3983 // Register a debug event listener which sets the break flag and counts. | 3982 // Register a debug event listener which sets the break flag and counts. |
| 3984 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter); | 3983 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter); |
| 3985 | 3984 |
| 3986 v8::Local<v8::Context> context = env.context(); | 3985 v8::Local<v8::Context> context = env.context(); |
| 3987 // Create a function for testing stepping. | 3986 // Create a function for testing stepping. |
| 3988 const char* src = "function f() {g()};function g(){i=0; while(i<10){i++}}"; | 3987 const char* src = "function f() {g()};function g(){i=0; while(i<10){i++}}"; |
| 3989 v8::Local<v8::Function> f = CompileFunction(&env, src, "f"); | 3988 v8::Local<v8::Function> f = CompileFunction(&env, src, "f"); |
| 3990 | 3989 |
| 3991 // Set, test and cancel debug break. | 3990 // Set, test and cancel debug break. |
| 3992 v8::Debug::DebugBreak(env->GetIsolate()); | 3991 v8::debug::DebugBreak(env->GetIsolate()); |
| 3993 v8::Debug::CancelDebugBreak(env->GetIsolate()); | 3992 v8::Debug::CancelDebugBreak(env->GetIsolate()); |
| 3994 | 3993 |
| 3995 // Set the debug break flag. | 3994 // Set the debug break flag. |
| 3996 v8::Debug::DebugBreak(env->GetIsolate()); | 3995 v8::debug::DebugBreak(env->GetIsolate()); |
| 3997 | 3996 |
| 3998 // Call all functions with different argument count. | 3997 // Call all functions with different argument count. |
| 3999 break_point_hit_count = 0; | 3998 break_point_hit_count = 0; |
| 4000 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 3999 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 4001 CHECK_EQ(1, break_point_hit_count); | 4000 CHECK_EQ(1, break_point_hit_count); |
| 4002 | 4001 |
| 4003 { | 4002 { |
| 4004 v8::Debug::DebugBreak(env->GetIsolate()); | 4003 v8::debug::DebugBreak(env->GetIsolate()); |
| 4005 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(env->GetIsolate()); | 4004 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(env->GetIsolate()); |
| 4006 v8::internal::DisableBreak disable_break(isolate->debug()); | 4005 v8::internal::DisableBreak disable_break(isolate->debug()); |
| 4007 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 4006 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 4008 CHECK_EQ(1, break_point_hit_count); | 4007 CHECK_EQ(1, break_point_hit_count); |
| 4009 } | 4008 } |
| 4010 | 4009 |
| 4011 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 4010 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 4012 CHECK_EQ(2, break_point_hit_count); | 4011 CHECK_EQ(2, break_point_hit_count); |
| 4013 | 4012 |
| 4014 // Get rid of the debug event listener. | 4013 // Get rid of the debug event listener. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 4040 // http://crbug.com/28933 | 4039 // http://crbug.com/28933 |
| 4041 // Test that debug break is disabled when bootstrapper is active. | 4040 // Test that debug break is disabled when bootstrapper is active. |
| 4042 TEST(NoBreakWhenBootstrapping) { | 4041 TEST(NoBreakWhenBootstrapping) { |
| 4043 v8::Isolate* isolate = CcTest::isolate(); | 4042 v8::Isolate* isolate = CcTest::isolate(); |
| 4044 v8::HandleScope scope(isolate); | 4043 v8::HandleScope scope(isolate); |
| 4045 | 4044 |
| 4046 // Register a debug event listener which sets the break flag and counts. | 4045 // Register a debug event listener which sets the break flag and counts. |
| 4047 v8::Debug::SetDebugEventListener(isolate, DebugEventCounter); | 4046 v8::Debug::SetDebugEventListener(isolate, DebugEventCounter); |
| 4048 | 4047 |
| 4049 // Set the debug break flag. | 4048 // Set the debug break flag. |
| 4050 v8::Debug::DebugBreak(isolate); | 4049 v8::debug::DebugBreak(isolate); |
| 4051 break_point_hit_count = 0; | 4050 break_point_hit_count = 0; |
| 4052 { | 4051 { |
| 4053 // Create a context with an extension to make sure that some JavaScript | 4052 // Create a context with an extension to make sure that some JavaScript |
| 4054 // code is executed during bootstrapping. | 4053 // code is executed during bootstrapping. |
| 4055 v8::RegisterExtension(new v8::Extension("simpletest", | 4054 v8::RegisterExtension(new v8::Extension("simpletest", |
| 4056 kSimpleExtensionSource)); | 4055 kSimpleExtensionSource)); |
| 4057 const char* extension_names[] = { "simpletest" }; | 4056 const char* extension_names[] = { "simpletest" }; |
| 4058 v8::ExtensionConfiguration extensions(1, extension_names); | 4057 v8::ExtensionConfiguration extensions(1, extension_names); |
| 4059 v8::HandleScope handle_scope(isolate); | 4058 v8::HandleScope handle_scope(isolate); |
| 4060 v8::Context::New(isolate, &extensions); | 4059 v8::Context::New(isolate, &extensions); |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4586 CHECK(CompileRun("obj_mirror.property('a').value().value() == 1") | 4585 CHECK(CompileRun("obj_mirror.property('a').value().value() == 1") |
| 4587 ->BooleanValue(context) | 4586 ->BooleanValue(context) |
| 4588 .FromJust()); | 4587 .FromJust()); |
| 4589 CHECK(CompileRun("obj_mirror.property('b').value().value() == 2") | 4588 CHECK(CompileRun("obj_mirror.property('b').value().value() == 2") |
| 4590 ->BooleanValue(context) | 4589 ->BooleanValue(context) |
| 4591 .FromJust()); | 4590 .FromJust()); |
| 4592 } | 4591 } |
| 4593 | 4592 |
| 4594 | 4593 |
| 4595 TEST(SetDebugEventListenerOnUninitializedVM) { | 4594 TEST(SetDebugEventListenerOnUninitializedVM) { |
| 4596 v8::Debug::SetDebugEventListener(CcTest::isolate(), DummyDebugEventListener); | 4595 EnableDebugger(CcTest::isolate()); |
| 4597 } | 4596 } |
| 4598 | 4597 |
| 4599 // Source for a JavaScript function which returns the data parameter of a | 4598 // Source for a JavaScript function which returns the data parameter of a |
| 4600 // function called in the context of the debugger. If no data parameter is | 4599 // function called in the context of the debugger. If no data parameter is |
| 4601 // passed it throws an exception. | 4600 // passed it throws an exception. |
| 4602 static const char* debugger_call_with_data_source = | 4601 static const char* debugger_call_with_data_source = |
| 4603 "function debugger_call_with_data(exec_state, data) {" | 4602 "function debugger_call_with_data(exec_state, data) {" |
| 4604 " if (data) return data;" | 4603 " if (data) return data;" |
| 4605 " throw 'No data!'" | 4604 " throw 'No data!'" |
| 4606 "}"; | 4605 "}"; |
| 4607 v8::Local<v8::Function> debugger_call_with_data; | 4606 v8::Local<v8::Function> debugger_call_with_data; |
| 4608 | 4607 |
| 4609 | 4608 |
| 4610 // Source for a JavaScript function which returns the data parameter of a | 4609 // Source for a JavaScript function which returns the data parameter of a |
| 4611 // function called in the context of the debugger. If no data parameter is | 4610 // function called in the context of the debugger. If no data parameter is |
| 4612 // passed it throws an exception. | 4611 // passed it throws an exception. |
| 4613 static const char* debugger_call_with_closure_source = | 4612 static const char* debugger_call_with_closure_source = |
| 4614 "var x = 3;" | 4613 "var x = 3;" |
| 4615 "(function (exec_state) {" | 4614 "(function (exec_state) {" |
| 4616 " if (exec_state.y) return x - 1;" | 4615 " if (exec_state.y) return x - 1;" |
| 4617 " exec_state.y = x;" | 4616 " exec_state.y = x;" |
| 4618 " return exec_state.y" | 4617 " return exec_state.y" |
| 4619 "})"; | 4618 "})"; |
| 4620 v8::Local<v8::Function> debugger_call_with_closure; | 4619 v8::Local<v8::Function> debugger_call_with_closure; |
| 4621 | 4620 |
| 4622 // Function to retrieve the number of JavaScript frames by calling a JavaScript | 4621 // Function to retrieve the number of JavaScript frames by calling a JavaScript |
| 4623 // in the debugger. | 4622 // in the debugger. |
| 4624 static void CheckFrameCount(const v8::FunctionCallbackInfo<v8::Value>& args) { | 4623 static void CheckFrameCount(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4625 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); | 4624 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); |
| 4626 CHECK(v8::Debug::Call(context, frame_count).ToLocalChecked()->IsNumber()); | 4625 CHECK(v8::debug::Call(context, frame_count).ToLocalChecked()->IsNumber()); |
| 4627 CHECK_EQ(args[0]->Int32Value(context).FromJust(), | 4626 CHECK_EQ(args[0]->Int32Value(context).FromJust(), |
| 4628 v8::Debug::Call(context, frame_count) | 4627 v8::debug::Call(context, frame_count) |
| 4629 .ToLocalChecked() | 4628 .ToLocalChecked() |
| 4630 ->Int32Value(context) | 4629 ->Int32Value(context) |
| 4631 .FromJust()); | 4630 .FromJust()); |
| 4632 } | 4631 } |
| 4633 | 4632 |
| 4634 | 4633 |
| 4635 // Function to retrieve the source line of the top JavaScript frame by calling a | 4634 // Function to retrieve the source line of the top JavaScript frame by calling a |
| 4636 // JavaScript function in the debugger. | 4635 // JavaScript function in the debugger. |
| 4637 static void CheckSourceLine(const v8::FunctionCallbackInfo<v8::Value>& args) { | 4636 static void CheckSourceLine(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4638 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); | 4637 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); |
| 4639 CHECK( | 4638 CHECK( |
| 4640 v8::Debug::Call(context, frame_source_line).ToLocalChecked()->IsNumber()); | 4639 v8::debug::Call(context, frame_source_line).ToLocalChecked()->IsNumber()); |
| 4641 CHECK_EQ(args[0]->Int32Value(context).FromJust(), | 4640 CHECK_EQ(args[0]->Int32Value(context).FromJust(), |
| 4642 v8::Debug::Call(context, frame_source_line) | 4641 v8::debug::Call(context, frame_source_line) |
| 4643 .ToLocalChecked() | 4642 .ToLocalChecked() |
| 4644 ->Int32Value(context) | 4643 ->Int32Value(context) |
| 4645 .FromJust()); | 4644 .FromJust()); |
| 4646 } | 4645 } |
| 4647 | 4646 |
| 4648 | 4647 |
| 4649 // Function to test passing an additional parameter to a JavaScript function | 4648 // Function to test passing an additional parameter to a JavaScript function |
| 4650 // called in the debugger. It also tests that functions called in the debugger | 4649 // called in the debugger. It also tests that functions called in the debugger |
| 4651 // can throw exceptions. | 4650 // can throw exceptions. |
| 4652 static void CheckDataParameter( | 4651 static void CheckDataParameter( |
| 4653 const v8::FunctionCallbackInfo<v8::Value>& args) { | 4652 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4654 v8::Local<v8::String> data = v8_str(args.GetIsolate(), "Test"); | 4653 v8::Local<v8::String> data = v8_str(args.GetIsolate(), "Test"); |
| 4655 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); | 4654 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); |
| 4656 CHECK(v8::Debug::Call(context, debugger_call_with_data, data) | 4655 CHECK(v8::debug::Call(context, debugger_call_with_data, data) |
| 4657 .ToLocalChecked() | 4656 .ToLocalChecked() |
| 4658 ->IsString()); | 4657 ->IsString()); |
| 4659 | 4658 |
| 4660 for (int i = 0; i < 3; i++) { | 4659 for (int i = 0; i < 3; i++) { |
| 4661 v8::TryCatch catcher(args.GetIsolate()); | 4660 v8::TryCatch catcher(args.GetIsolate()); |
| 4662 CHECK(v8::Debug::Call(context, debugger_call_with_data).IsEmpty()); | 4661 CHECK(v8::debug::Call(context, debugger_call_with_data).IsEmpty()); |
| 4663 CHECK(catcher.HasCaught()); | 4662 CHECK(catcher.HasCaught()); |
| 4664 CHECK(catcher.Exception()->IsString()); | 4663 CHECK(catcher.Exception()->IsString()); |
| 4665 } | 4664 } |
| 4666 } | 4665 } |
| 4667 | 4666 |
| 4668 | 4667 |
| 4669 // Function to test using a JavaScript with closure in the debugger. | 4668 // Function to test using a JavaScript with closure in the debugger. |
| 4670 static void CheckClosure(const v8::FunctionCallbackInfo<v8::Value>& args) { | 4669 static void CheckClosure(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4671 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); | 4670 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); |
| 4672 CHECK(v8::Debug::Call(context, debugger_call_with_closure) | 4671 CHECK(v8::debug::Call(context, debugger_call_with_closure) |
| 4673 .ToLocalChecked() | 4672 .ToLocalChecked() |
| 4674 ->IsNumber()); | 4673 ->IsNumber()); |
| 4675 CHECK_EQ(3, v8::Debug::Call(context, debugger_call_with_closure) | 4674 CHECK_EQ(3, v8::debug::Call(context, debugger_call_with_closure) |
| 4676 .ToLocalChecked() | 4675 .ToLocalChecked() |
| 4677 ->Int32Value(context) | 4676 ->Int32Value(context) |
| 4678 .FromJust()); | 4677 .FromJust()); |
| 4679 } | 4678 } |
| 4680 | 4679 |
| 4681 | 4680 |
| 4682 // Test functions called through the debugger. | 4681 // Test functions called through the debugger. |
| 4683 TEST(CallFunctionInDebugger) { | 4682 TEST(CallFunctionInDebugger) { |
| 4684 // Create and enter a context with the functions CheckFrameCount, | 4683 // Create and enter a context with the functions CheckFrameCount, |
| 4685 // CheckSourceLine and CheckDataParameter installed. | 4684 // CheckSourceLine and CheckDataParameter installed. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4734 v8::Script::Compile(context, | 4733 v8::Script::Compile(context, |
| 4735 v8_str(isolate, debugger_call_with_closure_source)) | 4734 v8_str(isolate, debugger_call_with_closure_source)) |
| 4736 .ToLocalChecked() | 4735 .ToLocalChecked() |
| 4737 ->Run(context) | 4736 ->Run(context) |
| 4738 .ToLocalChecked()); | 4737 .ToLocalChecked()); |
| 4739 | 4738 |
| 4740 // Calling a function through the debugger returns 0 frames if there are | 4739 // Calling a function through the debugger returns 0 frames if there are |
| 4741 // no JavaScript frames. | 4740 // no JavaScript frames. |
| 4742 CHECK(v8::Integer::New(isolate, 0) | 4741 CHECK(v8::Integer::New(isolate, 0) |
| 4743 ->Equals(context, | 4742 ->Equals(context, |
| 4744 v8::Debug::Call(context, frame_count).ToLocalChecked()) | 4743 v8::debug::Call(context, frame_count).ToLocalChecked()) |
| 4745 .FromJust()); | 4744 .FromJust()); |
| 4746 | 4745 |
| 4747 // Test that the number of frames can be retrieved. | 4746 // Test that the number of frames can be retrieved. |
| 4748 v8::Script::Compile(context, v8_str(isolate, "CheckFrameCount(1)")) | 4747 v8::Script::Compile(context, v8_str(isolate, "CheckFrameCount(1)")) |
| 4749 .ToLocalChecked() | 4748 .ToLocalChecked() |
| 4750 ->Run(context) | 4749 ->Run(context) |
| 4751 .ToLocalChecked(); | 4750 .ToLocalChecked(); |
| 4752 v8::Script::Compile(context, v8_str(isolate, | 4751 v8::Script::Compile(context, v8_str(isolate, |
| 4753 "function f() {" | 4752 "function f() {" |
| 4754 " CheckFrameCount(2);" | 4753 " CheckFrameCount(2);" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5095 CheckDebuggerUnloaded(isolate); | 5094 CheckDebuggerUnloaded(isolate); |
| 5096 } | 5095 } |
| 5097 | 5096 |
| 5098 // Debug event listener which issues a debug break when it hits a break event. | 5097 // Debug event listener which issues a debug break when it hits a break event. |
| 5099 static int event_listener_break_hit_count = 0; | 5098 static int event_listener_break_hit_count = 0; |
| 5100 static void DebugBreakEventListener(const v8::Debug::EventDetails& details) { | 5099 static void DebugBreakEventListener(const v8::Debug::EventDetails& details) { |
| 5101 // Schedule a debug break for break events. | 5100 // Schedule a debug break for break events. |
| 5102 if (details.GetEvent() == v8::Break) { | 5101 if (details.GetEvent() == v8::Break) { |
| 5103 event_listener_break_hit_count++; | 5102 event_listener_break_hit_count++; |
| 5104 if (event_listener_break_hit_count == 1) { | 5103 if (event_listener_break_hit_count == 1) { |
| 5105 v8::Debug::DebugBreak(details.GetIsolate()); | 5104 v8::debug::DebugBreak(details.GetIsolate()); |
| 5106 } | 5105 } |
| 5107 } | 5106 } |
| 5108 } | 5107 } |
| 5109 | 5108 |
| 5110 // Test that a debug break can be scheduled while in a event listener. | 5109 // Test that a debug break can be scheduled while in a event listener. |
| 5111 TEST(DebugBreakInEventListener) { | 5110 TEST(DebugBreakInEventListener) { |
| 5112 i::FLAG_turbo_inlining = false; // Make sure g is not inlined into f. | 5111 i::FLAG_turbo_inlining = false; // Make sure g is not inlined into f. |
| 5113 DebugLocalContext env; | 5112 DebugLocalContext env; |
| 5114 v8::HandleScope scope(env->GetIsolate()); | 5113 v8::HandleScope scope(env->GetIsolate()); |
| 5115 | 5114 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5163 } else { | 5162 } else { |
| 5164 CHECK(result->IsString()); | 5163 CHECK(result->IsString()); |
| 5165 v8::Local<v8::String> function_name( | 5164 v8::Local<v8::String> function_name( |
| 5166 result->ToString(context).ToLocalChecked()); | 5165 result->ToString(context).ToLocalChecked()); |
| 5167 function_name->WriteUtf8(last_function_hit); | 5166 function_name->WriteUtf8(last_function_hit); |
| 5168 } | 5167 } |
| 5169 } | 5168 } |
| 5170 | 5169 |
| 5171 // Keep forcing breaks. | 5170 // Keep forcing breaks. |
| 5172 if (break_point_hit_count < 20) { | 5171 if (break_point_hit_count < 20) { |
| 5173 v8::Debug::DebugBreak(CcTest::isolate()); | 5172 v8::debug::DebugBreak(CcTest::isolate()); |
| 5174 } | 5173 } |
| 5175 } | 5174 } |
| 5176 } | 5175 } |
| 5177 | 5176 |
| 5178 | 5177 |
| 5179 TEST(RegExpDebugBreak) { | 5178 TEST(RegExpDebugBreak) { |
| 5180 // This test only applies to native regexps. | 5179 // This test only applies to native regexps. |
| 5181 DebugLocalContext env; | 5180 DebugLocalContext env; |
| 5182 v8::HandleScope scope(env->GetIsolate()); | 5181 v8::HandleScope scope(env->GetIsolate()); |
| 5183 v8::Local<v8::Context> context = env.context(); | 5182 v8::Local<v8::Context> context = env.context(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 5194 | 5193 |
| 5195 v8::Local<v8::Function> f = CompileFunction(env->GetIsolate(), script, "f"); | 5194 v8::Local<v8::Function> f = CompileFunction(env->GetIsolate(), script, "f"); |
| 5196 const int argc = 1; | 5195 const int argc = 1; |
| 5197 v8::Local<v8::Value> argv[argc] = { | 5196 v8::Local<v8::Value> argv[argc] = { |
| 5198 v8_str(env->GetIsolate(), " /* xxx */ a=0;")}; | 5197 v8_str(env->GetIsolate(), " /* xxx */ a=0;")}; |
| 5199 v8::Local<v8::Value> result = | 5198 v8::Local<v8::Value> result = |
| 5200 f->Call(context, env->Global(), argc, argv).ToLocalChecked(); | 5199 f->Call(context, env->Global(), argc, argv).ToLocalChecked(); |
| 5201 CHECK_EQ(12, result->Int32Value(context).FromJust()); | 5200 CHECK_EQ(12, result->Int32Value(context).FromJust()); |
| 5202 | 5201 |
| 5203 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventDebugBreak); | 5202 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventDebugBreak); |
| 5204 v8::Debug::DebugBreak(env->GetIsolate()); | 5203 v8::debug::DebugBreak(env->GetIsolate()); |
| 5205 result = f->Call(context, env->Global(), argc, argv).ToLocalChecked(); | 5204 result = f->Call(context, env->Global(), argc, argv).ToLocalChecked(); |
| 5206 | 5205 |
| 5207 // Check that there was only one break event. Matching RegExp should not | 5206 // Check that there was only one break event. Matching RegExp should not |
| 5208 // cause Break events. | 5207 // cause Break events. |
| 5209 CHECK_EQ(1, break_point_hit_count); | 5208 CHECK_EQ(1, break_point_hit_count); |
| 5210 CHECK_EQ(0, strcmp("f", last_function_hit)); | 5209 CHECK_EQ(0, strcmp("f", last_function_hit)); |
| 5211 } | 5210 } |
| 5212 #endif // V8_INTERPRETED_REGEXP | 5211 #endif // V8_INTERPRETED_REGEXP |
| 5213 | 5212 |
| 5214 // Test which creates a context and sets embedder data on it. Checks that this | 5213 // Test which creates a context and sets embedder data on it. Checks that this |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5276 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 5275 v8::Debug::SetDebugEventListener(env->GetIsolate(), |
| 5277 AfterCompileEventListener); | 5276 AfterCompileEventListener); |
| 5278 v8::Script::Compile(context, v8_str(env->GetIsolate(), script)) | 5277 v8::Script::Compile(context, v8_str(env->GetIsolate(), script)) |
| 5279 .ToLocalChecked() | 5278 .ToLocalChecked() |
| 5280 ->Run(context) | 5279 ->Run(context) |
| 5281 .ToLocalChecked(); | 5280 .ToLocalChecked(); |
| 5282 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 5281 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
| 5283 | 5282 |
| 5284 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 5283 v8::Debug::SetDebugEventListener(env->GetIsolate(), |
| 5285 AfterCompileEventListener); | 5284 AfterCompileEventListener); |
| 5286 v8::Debug::DebugBreak(env->GetIsolate()); | 5285 v8::debug::DebugBreak(env->GetIsolate()); |
| 5287 v8::Script::Compile(context, v8_str(env->GetIsolate(), script)) | 5286 v8::Script::Compile(context, v8_str(env->GetIsolate(), script)) |
| 5288 .ToLocalChecked() | 5287 .ToLocalChecked() |
| 5289 ->Run(context) | 5288 ->Run(context) |
| 5290 .ToLocalChecked(); | 5289 .ToLocalChecked(); |
| 5291 | 5290 |
| 5292 // Setting listener to NULL should cause debugger unload. | 5291 // Setting listener to NULL should cause debugger unload. |
| 5293 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 5292 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
| 5294 CheckDebuggerUnloaded(env->GetIsolate()); | 5293 CheckDebuggerUnloaded(env->GetIsolate()); |
| 5295 | 5294 |
| 5296 // Compilation cache should be disabled when debugger is active. | 5295 // Compilation cache should be disabled when debugger is active. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5369 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 5368 v8::Debug::SetDebugEventListener(env->GetIsolate(), |
| 5370 AfterCompileEventListener); | 5369 AfterCompileEventListener); |
| 5371 v8::Script::Compile(context, v8_str(env->GetIsolate(), script)) | 5370 v8::Script::Compile(context, v8_str(env->GetIsolate(), script)) |
| 5372 .ToLocalChecked() | 5371 .ToLocalChecked() |
| 5373 ->Run(context) | 5372 ->Run(context) |
| 5374 .ToLocalChecked(); | 5373 .ToLocalChecked(); |
| 5375 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 5374 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
| 5376 | 5375 |
| 5377 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 5376 v8::Debug::SetDebugEventListener(env->GetIsolate(), |
| 5378 AfterCompileEventListener); | 5377 AfterCompileEventListener); |
| 5379 v8::Debug::DebugBreak(env->GetIsolate()); | 5378 v8::debug::DebugBreak(env->GetIsolate()); |
| 5380 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 5379 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
| 5381 env->Global() | 5380 env->Global() |
| 5382 ->Get(context, v8_str(env->GetIsolate(), "f")) | 5381 ->Get(context, v8_str(env->GetIsolate(), "f")) |
| 5383 .ToLocalChecked()); | 5382 .ToLocalChecked()); |
| 5384 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 5383 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 5385 | 5384 |
| 5386 // Setting event listener to NULL should cause debugger unload. | 5385 // Setting event listener to NULL should cause debugger unload. |
| 5387 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 5386 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
| 5388 CheckDebuggerUnloaded(env->GetIsolate()); | 5387 CheckDebuggerUnloaded(env->GetIsolate()); |
| 5389 | 5388 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5484 // debug-delay.js is executed. | 5483 // debug-delay.js is executed. |
| 5485 TEST(NoDebugBreakInAfterCompileEventListener) { | 5484 TEST(NoDebugBreakInAfterCompileEventListener) { |
| 5486 DebugLocalContext env; | 5485 DebugLocalContext env; |
| 5487 v8::HandleScope scope(env->GetIsolate()); | 5486 v8::HandleScope scope(env->GetIsolate()); |
| 5488 v8::Local<v8::Context> context = env.context(); | 5487 v8::Local<v8::Context> context = env.context(); |
| 5489 | 5488 |
| 5490 // Register a debug event listener which sets the break flag and counts. | 5489 // Register a debug event listener which sets the break flag and counts. |
| 5491 v8::Debug::SetDebugEventListener(env->GetIsolate(), BreakEventListener); | 5490 v8::Debug::SetDebugEventListener(env->GetIsolate(), BreakEventListener); |
| 5492 | 5491 |
| 5493 // Set the debug break flag. | 5492 // Set the debug break flag. |
| 5494 v8::Debug::DebugBreak(env->GetIsolate()); | 5493 v8::debug::DebugBreak(env->GetIsolate()); |
| 5495 | 5494 |
| 5496 // Create a function for testing stepping. | 5495 // Create a function for testing stepping. |
| 5497 const char* src = "function f() { eval('var x = 10;'); } "; | 5496 const char* src = "function f() { eval('var x = 10;'); } "; |
| 5498 v8::Local<v8::Function> f = CompileFunction(&env, src, "f"); | 5497 v8::Local<v8::Function> f = CompileFunction(&env, src, "f"); |
| 5499 | 5498 |
| 5500 // There should be only one break event. | 5499 // There should be only one break event. |
| 5501 CHECK_EQ(1, break_point_hit_count); | 5500 CHECK_EQ(1, break_point_hit_count); |
| 5502 | 5501 |
| 5503 // Set the debug break flag again. | 5502 // Set the debug break flag again. |
| 5504 v8::Debug::DebugBreak(env->GetIsolate()); | 5503 v8::debug::DebugBreak(env->GetIsolate()); |
| 5505 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 5504 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 5506 // There should be one more break event when the script is evaluated in 'f'. | 5505 // There should be one more break event when the script is evaluated in 'f'. |
| 5507 CHECK_EQ(2, break_point_hit_count); | 5506 CHECK_EQ(2, break_point_hit_count); |
| 5508 | 5507 |
| 5509 // Get rid of the debug event listener. | 5508 // Get rid of the debug event listener. |
| 5510 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 5509 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
| 5511 CheckDebuggerUnloaded(env->GetIsolate()); | 5510 CheckDebuggerUnloaded(env->GetIsolate()); |
| 5512 } | 5511 } |
| 5513 | 5512 |
| 5514 | 5513 |
| 5515 // Test that the debug break flag works with function.apply. | 5514 // Test that the debug break flag works with function.apply. |
| 5516 TEST(DebugBreakFunctionApply) { | 5515 TEST(DebugBreakFunctionApply) { |
| 5517 DebugLocalContext env; | 5516 DebugLocalContext env; |
| 5518 v8::HandleScope scope(env->GetIsolate()); | 5517 v8::HandleScope scope(env->GetIsolate()); |
| 5519 v8::Local<v8::Context> context = env.context(); | 5518 v8::Local<v8::Context> context = env.context(); |
| 5520 | 5519 |
| 5521 // Create a function for testing breaking in apply. | 5520 // Create a function for testing breaking in apply. |
| 5522 v8::Local<v8::Function> foo = CompileFunction( | 5521 v8::Local<v8::Function> foo = CompileFunction( |
| 5523 &env, | 5522 &env, |
| 5524 "function baz(x) { }" | 5523 "function baz(x) { }" |
| 5525 "function bar(x) { baz(); }" | 5524 "function bar(x) { baz(); }" |
| 5526 "function foo(){ bar.apply(this, [1]); }", | 5525 "function foo(){ bar.apply(this, [1]); }", |
| 5527 "foo"); | 5526 "foo"); |
| 5528 | 5527 |
| 5529 // Register a debug event listener which steps and counts. | 5528 // Register a debug event listener which steps and counts. |
| 5530 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventBreakMax); | 5529 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventBreakMax); |
| 5531 | 5530 |
| 5532 // Set the debug break flag before calling the code using function.apply. | 5531 // Set the debug break flag before calling the code using function.apply. |
| 5533 v8::Debug::DebugBreak(env->GetIsolate()); | 5532 v8::debug::DebugBreak(env->GetIsolate()); |
| 5534 | 5533 |
| 5535 // Limit the number of debug breaks. This is a regression test for issue 493 | 5534 // Limit the number of debug breaks. This is a regression test for issue 493 |
| 5536 // where this test would enter an infinite loop. | 5535 // where this test would enter an infinite loop. |
| 5537 break_point_hit_count = 0; | 5536 break_point_hit_count = 0; |
| 5538 max_break_point_hit_count = 10000; // 10000 => infinite loop. | 5537 max_break_point_hit_count = 10000; // 10000 => infinite loop. |
| 5539 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 5538 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 5540 | 5539 |
| 5541 // When keeping the debug break several break will happen. | 5540 // When keeping the debug break several break will happen. |
| 5542 CHECK_GT(break_point_hit_count, 1); | 5541 CHECK_GT(break_point_hit_count, 1); |
| 5543 | 5542 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5681 v8::Local<v8::String> function_name( | 5680 v8::Local<v8::String> function_name( |
| 5682 result->ToString(context).ToLocalChecked()); | 5681 result->ToString(context).ToLocalChecked()); |
| 5683 function_name->WriteUtf8(fn); | 5682 function_name->WriteUtf8(fn); |
| 5684 if (strcmp(fn, "bar") == 0) { | 5683 if (strcmp(fn, "bar") == 0) { |
| 5685 i::Deoptimizer::DeoptimizeAll(CcTest::i_isolate()); | 5684 i::Deoptimizer::DeoptimizeAll(CcTest::i_isolate()); |
| 5686 debug_event_break_deoptimize_done = true; | 5685 debug_event_break_deoptimize_done = true; |
| 5687 } | 5686 } |
| 5688 } | 5687 } |
| 5689 } | 5688 } |
| 5690 | 5689 |
| 5691 v8::Debug::DebugBreak(CcTest::isolate()); | 5690 v8::debug::DebugBreak(CcTest::isolate()); |
| 5692 } | 5691 } |
| 5693 } | 5692 } |
| 5694 | 5693 |
| 5695 | 5694 |
| 5696 // Test deoptimization when execution is broken using the debug break stack | 5695 // Test deoptimization when execution is broken using the debug break stack |
| 5697 // check interrupt. | 5696 // check interrupt. |
| 5698 TEST(DeoptimizeDuringDebugBreak) { | 5697 TEST(DeoptimizeDuringDebugBreak) { |
| 5699 DebugLocalContext env; | 5698 DebugLocalContext env; |
| 5700 v8::HandleScope scope(env->GetIsolate()); | 5699 v8::HandleScope scope(env->GetIsolate()); |
| 5701 env.ExposeDebug(); | 5700 env.ExposeDebug(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 5712 // time in function bar when using debug break and no break points will be at | 5711 // time in function bar when using debug break and no break points will be at |
| 5713 // the initial stack check. | 5712 // the initial stack check. |
| 5714 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 5713 v8::Debug::SetDebugEventListener(env->GetIsolate(), |
| 5715 DebugEventBreakDeoptimize); | 5714 DebugEventBreakDeoptimize); |
| 5716 | 5715 |
| 5717 // Compile and run function bar which will optimize it for some flag settings. | 5716 // Compile and run function bar which will optimize it for some flag settings. |
| 5718 v8::Local<v8::Function> f = CompileFunction(&env, "function bar(){}", "bar"); | 5717 v8::Local<v8::Function> f = CompileFunction(&env, "function bar(){}", "bar"); |
| 5719 f->Call(context, v8::Undefined(env->GetIsolate()), 0, NULL).ToLocalChecked(); | 5718 f->Call(context, v8::Undefined(env->GetIsolate()), 0, NULL).ToLocalChecked(); |
| 5720 | 5719 |
| 5721 // Set debug break and call bar again. | 5720 // Set debug break and call bar again. |
| 5722 v8::Debug::DebugBreak(env->GetIsolate()); | 5721 v8::debug::DebugBreak(env->GetIsolate()); |
| 5723 f->Call(context, v8::Undefined(env->GetIsolate()), 0, NULL).ToLocalChecked(); | 5722 f->Call(context, v8::Undefined(env->GetIsolate()), 0, NULL).ToLocalChecked(); |
| 5724 | 5723 |
| 5725 CHECK(debug_event_break_deoptimize_done); | 5724 CHECK(debug_event_break_deoptimize_done); |
| 5726 | 5725 |
| 5727 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 5726 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
| 5728 } | 5727 } |
| 5729 | 5728 |
| 5730 | 5729 |
| 5731 static void DebugEventBreakWithOptimizedStack( | 5730 static void DebugEventBreakWithOptimizedStack( |
| 5732 const v8::Debug::EventDetails& event_details) { | 5731 const v8::Debug::EventDetails& event_details) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5786 (result->Int32Value(context).FromJust() == 42)); | 5785 (result->Int32Value(context).FromJust() == 42)); |
| 5787 } | 5786 } |
| 5788 } | 5787 } |
| 5789 } | 5788 } |
| 5790 } | 5789 } |
| 5791 | 5790 |
| 5792 | 5791 |
| 5793 static void ScheduleBreak(const v8::FunctionCallbackInfo<v8::Value>& args) { | 5792 static void ScheduleBreak(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 5794 v8::Debug::SetDebugEventListener(args.GetIsolate(), | 5793 v8::Debug::SetDebugEventListener(args.GetIsolate(), |
| 5795 DebugEventBreakWithOptimizedStack); | 5794 DebugEventBreakWithOptimizedStack); |
| 5796 v8::Debug::DebugBreak(args.GetIsolate()); | 5795 v8::debug::DebugBreak(args.GetIsolate()); |
| 5797 } | 5796 } |
| 5798 | 5797 |
| 5799 | 5798 |
| 5800 TEST(DebugBreakStackInspection) { | 5799 TEST(DebugBreakStackInspection) { |
| 5801 DebugLocalContext env; | 5800 DebugLocalContext env; |
| 5802 v8::HandleScope scope(env->GetIsolate()); | 5801 v8::HandleScope scope(env->GetIsolate()); |
| 5803 v8::Local<v8::Context> context = env.context(); | 5802 v8::Local<v8::Context> context = env.context(); |
| 5804 | 5803 |
| 5805 frame_function_name = | 5804 frame_function_name = |
| 5806 CompileFunction(&env, frame_function_name_source, "frame_function_name"); | 5805 CompileFunction(&env, frame_function_name_source, "frame_function_name"); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5859 } | 5858 } |
| 5860 | 5859 |
| 5861 break_point_hit_count = 0; | 5860 break_point_hit_count = 0; |
| 5862 max_break_point_hit_count = kBreaksPerTest; | 5861 max_break_point_hit_count = kBreaksPerTest; |
| 5863 terminate_after_max_break_point_hit = true; | 5862 terminate_after_max_break_point_hit = true; |
| 5864 | 5863 |
| 5865 // Function with infinite loop. | 5864 // Function with infinite loop. |
| 5866 CompileRun(buffer.start()); | 5865 CompileRun(buffer.start()); |
| 5867 | 5866 |
| 5868 // Set the debug break to enter the debugger as soon as possible. | 5867 // Set the debug break to enter the debugger as soon as possible. |
| 5869 v8::Debug::DebugBreak(CcTest::isolate()); | 5868 v8::debug::DebugBreak(CcTest::isolate()); |
| 5870 | 5869 |
| 5871 // Call function with infinite loop. | 5870 // Call function with infinite loop. |
| 5872 CompileRun("f();"); | 5871 CompileRun("f();"); |
| 5873 CHECK_EQ(kBreaksPerTest, break_point_hit_count); | 5872 CHECK_EQ(kBreaksPerTest, break_point_hit_count); |
| 5874 | 5873 |
| 5875 CHECK(!CcTest::isolate()->IsExecutionTerminating()); | 5874 CHECK(!CcTest::isolate()->IsExecutionTerminating()); |
| 5876 } | 5875 } |
| 5877 } | 5876 } |
| 5878 } | 5877 } |
| 5879 | 5878 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6108 CHECK_EQ(2, v8::internal::CountNativeContexts()); | 6107 CHECK_EQ(2, v8::internal::CountNativeContexts()); |
| 6109 | 6108 |
| 6110 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 6109 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
| 6111 } | 6110 } |
| 6112 | 6111 |
| 6113 | 6112 |
| 6114 TEST(LiveEditEnabled) { | 6113 TEST(LiveEditEnabled) { |
| 6115 v8::internal::FLAG_allow_natives_syntax = true; | 6114 v8::internal::FLAG_allow_natives_syntax = true; |
| 6116 LocalContext env; | 6115 LocalContext env; |
| 6117 v8::HandleScope scope(env->GetIsolate()); | 6116 v8::HandleScope scope(env->GetIsolate()); |
| 6118 v8::Debug::SetLiveEditEnabled(env->GetIsolate(), true); | 6117 v8::debug::SetLiveEditEnabled(env->GetIsolate(), true); |
| 6119 CompileRun("%LiveEditCompareStrings('', '')"); | 6118 CompileRun("%LiveEditCompareStrings('', '')"); |
| 6120 } | 6119 } |
| 6121 | 6120 |
| 6122 | 6121 |
| 6123 TEST(LiveEditDisabled) { | 6122 TEST(LiveEditDisabled) { |
| 6124 v8::internal::FLAG_allow_natives_syntax = true; | 6123 v8::internal::FLAG_allow_natives_syntax = true; |
| 6125 LocalContext env; | 6124 LocalContext env; |
| 6126 v8::HandleScope scope(env->GetIsolate()); | 6125 v8::HandleScope scope(env->GetIsolate()); |
| 6127 v8::Debug::SetLiveEditEnabled(env->GetIsolate(), false); | 6126 v8::debug::SetLiveEditEnabled(env->GetIsolate(), false); |
| 6128 CompileRun("%LiveEditCompareStrings('', '')"); | 6127 CompileRun("%LiveEditCompareStrings('', '')"); |
| 6129 } | 6128 } |
| 6130 | 6129 |
| 6131 | 6130 |
| 6132 TEST(PrecompiledFunction) { | 6131 TEST(PrecompiledFunction) { |
| 6133 // Regression test for crbug.com/346207. If we have preparse data, parsing the | 6132 // Regression test for crbug.com/346207. If we have preparse data, parsing the |
| 6134 // function in the presence of the debugger (and breakpoints) should still | 6133 // function in the presence of the debugger (and breakpoints) should still |
| 6135 // succeed. The bug was that preparsing was done lazily and parsing was done | 6134 // succeed. The bug was that preparsing was done lazily and parsing was done |
| 6136 // eagerly, so, the symbol streams didn't match. | 6135 // eagerly, so, the symbol streams didn't match. |
| 6137 DebugLocalContext env; | 6136 DebugLocalContext env; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 6164 } | 6163 } |
| 6165 | 6164 |
| 6166 | 6165 |
| 6167 static void DebugBreakStackTraceListener( | 6166 static void DebugBreakStackTraceListener( |
| 6168 const v8::Debug::EventDetails& event_details) { | 6167 const v8::Debug::EventDetails& event_details) { |
| 6169 v8::StackTrace::CurrentStackTrace(CcTest::isolate(), 10); | 6168 v8::StackTrace::CurrentStackTrace(CcTest::isolate(), 10); |
| 6170 } | 6169 } |
| 6171 | 6170 |
| 6172 | 6171 |
| 6173 static void AddDebugBreak(const v8::FunctionCallbackInfo<v8::Value>& args) { | 6172 static void AddDebugBreak(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 6174 v8::Debug::DebugBreak(args.GetIsolate()); | 6173 v8::debug::DebugBreak(args.GetIsolate()); |
| 6175 } | 6174 } |
| 6176 | 6175 |
| 6177 | 6176 |
| 6178 TEST(DebugBreakStackTrace) { | 6177 TEST(DebugBreakStackTrace) { |
| 6179 DebugLocalContext env; | 6178 DebugLocalContext env; |
| 6180 v8::HandleScope scope(env->GetIsolate()); | 6179 v8::HandleScope scope(env->GetIsolate()); |
| 6181 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 6180 v8::Debug::SetDebugEventListener(env->GetIsolate(), |
| 6182 DebugBreakStackTraceListener); | 6181 DebugBreakStackTraceListener); |
| 6183 v8::Local<v8::Context> context = env.context(); | 6182 v8::Local<v8::Context> context = env.context(); |
| 6184 v8::Local<v8::FunctionTemplate> add_debug_break_template = | 6183 v8::Local<v8::FunctionTemplate> add_debug_break_template = |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6231 | 6230 |
| 6232 | 6231 |
| 6233 TEST(DebugBreakOffThreadTerminate) { | 6232 TEST(DebugBreakOffThreadTerminate) { |
| 6234 DebugLocalContext env; | 6233 DebugLocalContext env; |
| 6235 v8::Isolate* isolate = env->GetIsolate(); | 6234 v8::Isolate* isolate = env->GetIsolate(); |
| 6236 v8::HandleScope scope(isolate); | 6235 v8::HandleScope scope(isolate); |
| 6237 v8::Debug::SetDebugEventListener(isolate, DebugBreakTriggerTerminate); | 6236 v8::Debug::SetDebugEventListener(isolate, DebugBreakTriggerTerminate); |
| 6238 TerminationThread terminator(isolate); | 6237 TerminationThread terminator(isolate); |
| 6239 terminator.Start(); | 6238 terminator.Start(); |
| 6240 v8::TryCatch try_catch(env->GetIsolate()); | 6239 v8::TryCatch try_catch(env->GetIsolate()); |
| 6241 v8::Debug::DebugBreak(isolate); | 6240 v8::debug::DebugBreak(isolate); |
| 6242 CompileRun("while (true);"); | 6241 CompileRun("while (true);"); |
| 6243 CHECK(try_catch.HasTerminated()); | 6242 CHECK(try_catch.HasTerminated()); |
| 6244 } | 6243 } |
| 6245 | 6244 |
| 6246 | 6245 |
| 6247 static void DebugEventExpectNoException( | 6246 static void DebugEventExpectNoException( |
| 6248 const v8::Debug::EventDetails& event_details) { | 6247 const v8::Debug::EventDetails& event_details) { |
| 6249 v8::DebugEvent event = event_details.GetEvent(); | 6248 v8::DebugEvent event = event_details.GetEvent(); |
| 6250 CHECK_NE(v8::Exception, event); | 6249 CHECK_NE(v8::Exception, event); |
| 6251 } | 6250 } |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6452 | 6451 |
| 6453 TEST(DisableTailCallElimination) { | 6452 TEST(DisableTailCallElimination) { |
| 6454 i::FLAG_allow_natives_syntax = true; | 6453 i::FLAG_allow_natives_syntax = true; |
| 6455 i::FLAG_harmony_tailcalls = true; | 6454 i::FLAG_harmony_tailcalls = true; |
| 6456 // TODO(ishell, 4698): Investigate why TurboFan in --always-opt mode makes | 6455 // TODO(ishell, 4698): Investigate why TurboFan in --always-opt mode makes |
| 6457 // stack[2].getFunctionName() return null. | 6456 // stack[2].getFunctionName() return null. |
| 6458 i::FLAG_turbo_inlining = false; | 6457 i::FLAG_turbo_inlining = false; |
| 6459 | 6458 |
| 6460 DebugLocalContext env; | 6459 DebugLocalContext env; |
| 6461 v8::Isolate* isolate = env->GetIsolate(); | 6460 v8::Isolate* isolate = env->GetIsolate(); |
| 6461 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6462 v8::HandleScope scope(isolate); | 6462 v8::HandleScope scope(isolate); |
| 6463 CHECK(v8::Debug::IsTailCallEliminationEnabled(isolate)); | 6463 CHECK(i_isolate->is_tail_call_elimination_enabled()); |
| 6464 | 6464 |
| 6465 CompileRun( | 6465 CompileRun( |
| 6466 "'use strict'; \n" | 6466 "'use strict'; \n" |
| 6467 "Error.prepareStackTrace = (error,stack) => { \n" | 6467 "Error.prepareStackTrace = (error,stack) => { \n" |
| 6468 " error.strace = stack; \n" | 6468 " error.strace = stack; \n" |
| 6469 " return error.message + \"\\n at \" + stack.join(\"\\n at \"); \n" | 6469 " return error.message + \"\\n at \" + stack.join(\"\\n at \"); \n" |
| 6470 "} \n" | 6470 "} \n" |
| 6471 " \n" | 6471 " \n" |
| 6472 "function getCaller() { \n" | 6472 "function getCaller() { \n" |
| 6473 " var e = new Error(); \n" | 6473 " var e = new Error(); \n" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 6490 "function h() { \n" | 6490 "function h() { \n" |
| 6491 " var result = g(); \n" | 6491 " var result = g(); \n" |
| 6492 " return result; \n" | 6492 " return result; \n" |
| 6493 "} \n" | 6493 "} \n" |
| 6494 "%NeverOptimizeFunction(getCaller); \n" | 6494 "%NeverOptimizeFunction(getCaller); \n" |
| 6495 "%NeverOptimizeFunction(f); \n" | 6495 "%NeverOptimizeFunction(f); \n" |
| 6496 "%NeverOptimizeFunction(h); \n" | 6496 "%NeverOptimizeFunction(h); \n" |
| 6497 ""); | 6497 ""); |
| 6498 ExpectInt32("h();", 2); | 6498 ExpectInt32("h();", 2); |
| 6499 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 2); | 6499 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 2); |
| 6500 v8::Debug::SetTailCallEliminationEnabled(isolate, false); | 6500 i_isolate->SetTailCallEliminationEnabled(false); |
| 6501 CHECK(!v8::Debug::IsTailCallEliminationEnabled(isolate)); | 6501 CHECK(!i_isolate->is_tail_call_elimination_enabled()); |
| 6502 ExpectInt32("h();", 1); | 6502 ExpectInt32("h();", 1); |
| 6503 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 1); | 6503 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 1); |
| 6504 v8::Debug::SetTailCallEliminationEnabled(isolate, true); | 6504 i_isolate->SetTailCallEliminationEnabled(true); |
| 6505 CHECK(v8::Debug::IsTailCallEliminationEnabled(isolate)); | 6505 CHECK(i_isolate->is_tail_call_elimination_enabled()); |
| 6506 ExpectInt32("h();", 2); | 6506 ExpectInt32("h();", 2); |
| 6507 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 2); | 6507 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 2); |
| 6508 } | 6508 } |
| 6509 | 6509 |
| 6510 TEST(DebugStepNextTailCallEliminiation) { | 6510 TEST(DebugStepNextTailCallEliminiation) { |
| 6511 i::FLAG_allow_natives_syntax = true; | 6511 i::FLAG_allow_natives_syntax = true; |
| 6512 i::FLAG_harmony_tailcalls = true; | 6512 i::FLAG_harmony_tailcalls = true; |
| 6513 // TODO(ishell, 4698): Investigate why TurboFan in --always-opt mode makes | 6513 // TODO(ishell, 4698): Investigate why TurboFan in --always-opt mode makes |
| 6514 // stack[2].getFunctionName() return null. | 6514 // stack[2].getFunctionName() return null. |
| 6515 i::FLAG_turbo_inlining = false; | 6515 i::FLAG_turbo_inlining = false; |
| 6516 | 6516 |
| 6517 DebugLocalContext env; | 6517 DebugLocalContext env; |
| 6518 env.ExposeDebug(); | 6518 env.ExposeDebug(); |
| 6519 v8::Isolate* isolate = env->GetIsolate(); | 6519 v8::Isolate* isolate = env->GetIsolate(); |
| 6520 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6520 v8::HandleScope scope(isolate); | 6521 v8::HandleScope scope(isolate); |
| 6521 CHECK(v8::Debug::IsTailCallEliminationEnabled(isolate)); | 6522 CHECK(i_isolate->is_tail_call_elimination_enabled()); |
| 6522 | 6523 |
| 6523 const char* source = | 6524 const char* source = |
| 6524 "'use strict'; \n" | 6525 "'use strict'; \n" |
| 6525 "var Debug = debug.Debug; \n" | 6526 "var Debug = debug.Debug; \n" |
| 6526 "var exception = null; \n" | 6527 "var exception = null; \n" |
| 6527 "var breaks = 0; \n" | 6528 "var breaks = 0; \n" |
| 6528 "var log = []; \n" | 6529 "var log = []; \n" |
| 6529 "function f(x) { \n" | 6530 "function f(x) { \n" |
| 6530 " if (x == 2) { \n" | 6531 " if (x == 2) { \n" |
| 6531 " debugger; // Break a \n" | 6532 " debugger; // Break a \n" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 6547 " }; \n" | 6548 " }; \n" |
| 6548 "}; \n" | 6549 "}; \n" |
| 6549 "Debug.setListener(listener); \n" | 6550 "Debug.setListener(listener); \n" |
| 6550 "f(4); \n" | 6551 "f(4); \n" |
| 6551 "Debug.setListener(null); // Break d \n"; | 6552 "Debug.setListener(null); // Break d \n"; |
| 6552 | 6553 |
| 6553 CompileRun(source); | 6554 CompileRun(source); |
| 6554 ExpectNull("exception"); | 6555 ExpectNull("exception"); |
| 6555 ExpectString("JSON.stringify(log)", "[\"a4\",\"b2\",\"c4\",\"c11\",\"d0\"]"); | 6556 ExpectString("JSON.stringify(log)", "[\"a4\",\"b2\",\"c4\",\"c11\",\"d0\"]"); |
| 6556 | 6557 |
| 6557 v8::Debug::SetTailCallEliminationEnabled(isolate, false); | 6558 i_isolate->SetTailCallEliminationEnabled(false); |
| 6558 CompileRun( | 6559 CompileRun( |
| 6559 "log = []; \n" | 6560 "log = []; \n" |
| 6560 "Debug.setListener(listener); \n" | 6561 "Debug.setListener(listener); \n" |
| 6561 "f(5); \n" | 6562 "f(5); \n" |
| 6562 "Debug.setListener(null); // Break f \n"); | 6563 "Debug.setListener(null); // Break f \n"); |
| 6563 ExpectNull("exception"); | 6564 ExpectNull("exception"); |
| 6564 ExpectString("JSON.stringify(log)", | 6565 ExpectString("JSON.stringify(log)", |
| 6565 "[\"a4\",\"b2\",\"c4\",\"e0\",\"e0\",\"e0\",\"e0\",\"f0\"]"); | 6566 "[\"a4\",\"b2\",\"c4\",\"e0\",\"e0\",\"e0\",\"e0\",\"f0\"]"); |
| 6566 } | 6567 } |
| 6567 | 6568 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6656 CHECK_EQ(4, function_data.End().GetColumnNumber()); | 6657 CHECK_EQ(4, function_data.End().GetColumnNumber()); |
| 6657 CHECK_EQ(1, function_data.Count()); | 6658 CHECK_EQ(1, function_data.Count()); |
| 6658 | 6659 |
| 6659 function_data = script_data.GetFunctionData(1); | 6660 function_data = script_data.GetFunctionData(1); |
| 6660 CHECK_EQ(0, function_data.Start().GetLineNumber()); | 6661 CHECK_EQ(0, function_data.Start().GetLineNumber()); |
| 6661 CHECK_EQ(0, function_data.Start().GetColumnNumber()); | 6662 CHECK_EQ(0, function_data.Start().GetColumnNumber()); |
| 6662 CHECK_EQ(1, function_data.End().GetLineNumber()); | 6663 CHECK_EQ(1, function_data.End().GetLineNumber()); |
| 6663 CHECK_EQ(1, function_data.End().GetColumnNumber()); | 6664 CHECK_EQ(1, function_data.End().GetColumnNumber()); |
| 6664 CHECK_EQ(2, function_data.Count()); | 6665 CHECK_EQ(2, function_data.Count()); |
| 6665 } | 6666 } |
| OLD | NEW |