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

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

Issue 2727393003: [debugger,api] deprecate everything in v8-debug.h (Closed)
Patch Set: remove TODO Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
2008 v8::Local<v8::Context> context = env.context(); 2007 v8::Local<v8::Context> context = env.context();
2009 v8::Local<v8::Function> foo = 2008 v8::Local<v8::Function> foo =
2010 CompileFunction(&env, "function foo(){a=1;}", "foo"); 2009 CompileFunction(&env, "function foo(){a=1;}", "foo");
2011 2010
2012 // Register the debug event listener pasing the function 2011 // Register the debug event listener pasing the function
2013 v8::Debug::SetDebugEventListener(env->GetIsolate(), 2012 SetDebugEventListener(env->GetIsolate(), DebugEventRemoveBreakPoint, foo);
2014 DebugEventRemoveBreakPoint, foo);
2015 2013
2016 debug_event_remove_break_point = SetBreakPoint(foo, 0); 2014 debug_event_remove_break_point = SetBreakPoint(foo, 0);
2017 2015
2018 break_point_hit_count = 0; 2016 break_point_hit_count = 0;
2019 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 2017 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
2020 CHECK_EQ(1, break_point_hit_count); 2018 CHECK_EQ(1, break_point_hit_count);
2021 2019
2022 break_point_hit_count = 0; 2020 break_point_hit_count = 0;
2023 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 2021 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
2024 CHECK_EQ(0, break_point_hit_count); 2022 CHECK_EQ(0, break_point_hit_count);
2025 2023
2026 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 2024 SetDebugEventListener(env->GetIsolate(), nullptr);
2027 CheckDebuggerUnloaded(env->GetIsolate()); 2025 CheckDebuggerUnloaded(env->GetIsolate());
2028 } 2026 }
2029 2027
2030 2028
2031 // Test that the debugger statement causes a break. 2029 // Test that the debugger statement causes a break.
2032 TEST(DebuggerStatement) { 2030 TEST(DebuggerStatement) {
2033 break_point_hit_count = 0; 2031 break_point_hit_count = 0;
2034 DebugLocalContext env; 2032 DebugLocalContext env;
2035 v8::HandleScope scope(env->GetIsolate()); 2033 v8::HandleScope scope(env->GetIsolate());
2036 v8::Debug::SetDebugEventListener(env->GetIsolate(), 2034 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount);
2037 DebugEventBreakPointHitCount);
2038 v8::Local<v8::Context> context = env.context(); 2035 v8::Local<v8::Context> context = env.context();
2039 v8::Script::Compile(context, 2036 v8::Script::Compile(context,
2040 v8_str(env->GetIsolate(), "function bar(){debugger}")) 2037 v8_str(env->GetIsolate(), "function bar(){debugger}"))
2041 .ToLocalChecked() 2038 .ToLocalChecked()
2042 ->Run(context) 2039 ->Run(context)
2043 .ToLocalChecked(); 2040 .ToLocalChecked();
2044 v8::Script::Compile( 2041 v8::Script::Compile(
2045 context, v8_str(env->GetIsolate(), "function foo(){debugger;debugger;}")) 2042 context, v8_str(env->GetIsolate(), "function foo(){debugger;debugger;}"))
2046 .ToLocalChecked() 2043 .ToLocalChecked()
2047 ->Run(context) 2044 ->Run(context)
2048 .ToLocalChecked(); 2045 .ToLocalChecked();
2049 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( 2046 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
2050 env->Global() 2047 env->Global()
2051 ->Get(context, v8_str(env->GetIsolate(), "foo")) 2048 ->Get(context, v8_str(env->GetIsolate(), "foo"))
2052 .ToLocalChecked()); 2049 .ToLocalChecked());
2053 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( 2050 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast(
2054 env->Global() 2051 env->Global()
2055 ->Get(context, v8_str(env->GetIsolate(), "bar")) 2052 ->Get(context, v8_str(env->GetIsolate(), "bar"))
2056 .ToLocalChecked()); 2053 .ToLocalChecked());
2057 2054
2058 // Run function with debugger statement 2055 // Run function with debugger statement
2059 bar->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 2056 bar->Call(context, env->Global(), 0, NULL).ToLocalChecked();
2060 CHECK_EQ(1, break_point_hit_count); 2057 CHECK_EQ(1, break_point_hit_count);
2061 2058
2062 // Run function with two debugger statement 2059 // Run function with two debugger statement
2063 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 2060 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
2064 CHECK_EQ(3, break_point_hit_count); 2061 CHECK_EQ(3, break_point_hit_count);
2065 2062
2066 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 2063 SetDebugEventListener(env->GetIsolate(), nullptr);
2067 CheckDebuggerUnloaded(env->GetIsolate()); 2064 CheckDebuggerUnloaded(env->GetIsolate());
2068 } 2065 }
2069 2066
2070 2067
2071 // Test setting a breakpoint on the debugger statement. 2068 // Test setting a breakpoint on the debugger statement.
2072 TEST(DebuggerStatementBreakpoint) { 2069 TEST(DebuggerStatementBreakpoint) {
2073 break_point_hit_count = 0; 2070 break_point_hit_count = 0;
2074 DebugLocalContext env; 2071 DebugLocalContext env;
2075 v8::HandleScope scope(env->GetIsolate()); 2072 v8::HandleScope scope(env->GetIsolate());
2076 v8::Local<v8::Context> context = env.context(); 2073 v8::Local<v8::Context> context = env.context();
2077 v8::Debug::SetDebugEventListener(env->GetIsolate(), 2074 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount);
2078 DebugEventBreakPointHitCount);
2079 v8::Script::Compile(context, 2075 v8::Script::Compile(context,
2080 v8_str(env->GetIsolate(), "function foo(){debugger;}")) 2076 v8_str(env->GetIsolate(), "function foo(){debugger;}"))
2081 .ToLocalChecked() 2077 .ToLocalChecked()
2082 ->Run(context) 2078 ->Run(context)
2083 .ToLocalChecked(); 2079 .ToLocalChecked();
2084 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( 2080 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
2085 env->Global() 2081 env->Global()
2086 ->Get(context, v8_str(env->GetIsolate(), "foo")) 2082 ->Get(context, v8_str(env->GetIsolate(), "foo"))
2087 .ToLocalChecked()); 2083 .ToLocalChecked());
2088 2084
2089 // The debugger statement triggers breakpoint hit 2085 // The debugger statement triggers breakpoint hit
2090 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 2086 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
2091 CHECK_EQ(1, break_point_hit_count); 2087 CHECK_EQ(1, break_point_hit_count);
2092 2088
2093 int bp = SetBreakPoint(foo, 0); 2089 int bp = SetBreakPoint(foo, 0);
2094 2090
2095 // Set breakpoint does not duplicate hits 2091 // Set breakpoint does not duplicate hits
2096 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 2092 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
2097 CHECK_EQ(2, break_point_hit_count); 2093 CHECK_EQ(2, break_point_hit_count);
2098 2094
2099 ClearBreakPoint(bp); 2095 ClearBreakPoint(bp);
2100 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 2096 SetDebugEventListener(env->GetIsolate(), nullptr);
2101 CheckDebuggerUnloaded(env->GetIsolate()); 2097 CheckDebuggerUnloaded(env->GetIsolate());
2102 } 2098 }
2103 2099
2104 2100
2105 // Test that the evaluation of expressions when a break point is hit generates 2101 // Test that the evaluation of expressions when a break point is hit generates
2106 // the correct results. 2102 // the correct results.
2107 TEST(DebugEvaluate) { 2103 TEST(DebugEvaluate) {
2108 DebugLocalContext env; 2104 DebugLocalContext env;
2109 v8::Isolate* isolate = env->GetIsolate(); 2105 v8::Isolate* isolate = env->GetIsolate();
2110 v8::HandleScope scope(isolate); 2106 v8::HandleScope scope(isolate);
2111 env.ExposeDebug(); 2107 env.ExposeDebug();
2112 2108
2113 // Create a function for checking the evaluation when hitting a break point. 2109 // Create a function for checking the evaluation when hitting a break point.
2114 evaluate_check_function = CompileFunction(&env, 2110 evaluate_check_function = CompileFunction(&env,
2115 evaluate_check_source, 2111 evaluate_check_source,
2116 "evaluate_check"); 2112 "evaluate_check");
2117 // Register the debug event listener 2113 // Register the debug event listener
2118 v8::Debug::SetDebugEventListener(isolate, DebugEventEvaluate); 2114 SetDebugEventListener(isolate, DebugEventEvaluate);
2119 2115
2120 // Different expected vaules of x and a when in a break point (u = undefined, 2116 // Different expected vaules of x and a when in a break point (u = undefined,
2121 // d = Hello, world!). 2117 // d = Hello, world!).
2122 struct EvaluateCheck checks_uu[] = {{"x", v8::Undefined(isolate)}, 2118 struct EvaluateCheck checks_uu[] = {{"x", v8::Undefined(isolate)},
2123 {"a", v8::Undefined(isolate)}, 2119 {"a", v8::Undefined(isolate)},
2124 {NULL, v8::Local<v8::Value>()}}; 2120 {NULL, v8::Local<v8::Value>()}};
2125 struct EvaluateCheck checks_hu[] = { 2121 struct EvaluateCheck checks_hu[] = {
2126 {"x", v8_str(env->GetIsolate(), "Hello, world!")}, 2122 {"x", v8_str(env->GetIsolate(), "Hello, world!")},
2127 {"a", v8::Undefined(isolate)}, 2123 {"a", v8::Undefined(isolate)},
2128 {NULL, v8::Local<v8::Value>()}}; 2124 {NULL, v8::Local<v8::Value>()}};
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 bar->Call(context, env->Global(), 2, argv_bar_2).ToLocalChecked(); 2226 bar->Call(context, env->Global(), 2, argv_bar_2).ToLocalChecked();
2231 2227
2232 // Call bar setting breakpoint after a=x in barbar and parameter 2228 // Call bar setting breakpoint after a=x in barbar and parameter
2233 // "Hello, world!". 2229 // "Hello, world!".
2234 checks = checks_hh; 2230 checks = checks_hh;
2235 v8::Local<v8::Value> argv_bar_3[2] = { 2231 v8::Local<v8::Value> argv_bar_3[2] = {
2236 v8_str(env->GetIsolate(), "Hello, world!"), 2232 v8_str(env->GetIsolate(), "Hello, world!"),
2237 v8::Number::New(env->GetIsolate(), barbar_break_position + 1)}; 2233 v8::Number::New(env->GetIsolate(), barbar_break_position + 1)};
2238 bar->Call(context, env->Global(), 2, argv_bar_3).ToLocalChecked(); 2234 bar->Call(context, env->Global(), 2, argv_bar_3).ToLocalChecked();
2239 2235
2240 v8::Debug::SetDebugEventListener(isolate, nullptr); 2236 SetDebugEventListener(isolate, nullptr);
2241 CheckDebuggerUnloaded(isolate); 2237 CheckDebuggerUnloaded(isolate);
2242 } 2238 }
2243 2239
2244 2240
2245 int debugEventCount = 0; 2241 int debugEventCount = 0;
2246 static void CheckDebugEvent(const v8::Debug::EventDetails& eventDetails) { 2242 static void CheckDebugEvent(const v8::Debug::EventDetails& eventDetails) {
2247 if (eventDetails.GetEvent() == v8::Break) ++debugEventCount; 2243 if (eventDetails.GetEvent() == v8::Break) ++debugEventCount;
2248 } 2244 }
2249 2245
2250 2246
2251 // Test that the conditional breakpoints work event if code generation from 2247 // Test that the conditional breakpoints work event if code generation from
2252 // strings is prohibited in the debugee context. 2248 // strings is prohibited in the debugee context.
2253 TEST(ConditionalBreakpointWithCodeGenerationDisallowed) { 2249 TEST(ConditionalBreakpointWithCodeGenerationDisallowed) {
2254 DebugLocalContext env; 2250 DebugLocalContext env;
2255 v8::HandleScope scope(env->GetIsolate()); 2251 v8::HandleScope scope(env->GetIsolate());
2256 env.ExposeDebug(); 2252 env.ExposeDebug();
2257 2253
2258 v8::Debug::SetDebugEventListener(env->GetIsolate(), CheckDebugEvent); 2254 SetDebugEventListener(env->GetIsolate(), CheckDebugEvent);
2259 2255
2260 v8::Local<v8::Context> context = env.context(); 2256 v8::Local<v8::Context> context = env.context();
2261 v8::Local<v8::Function> foo = CompileFunction(&env, 2257 v8::Local<v8::Function> foo = CompileFunction(&env,
2262 "function foo(x) {\n" 2258 "function foo(x) {\n"
2263 " var s = 'String value2';\n" 2259 " var s = 'String value2';\n"
2264 " return s + x;\n" 2260 " return s + x;\n"
2265 "}", 2261 "}",
2266 "foo"); 2262 "foo");
2267 2263
2268 // Set conditional breakpoint with condition 'true'. 2264 // Set conditional breakpoint with condition 'true'.
2269 CompileRun("debug.Debug.setBreakPoint(foo, 2, 0, 'true')"); 2265 CompileRun("debug.Debug.setBreakPoint(foo, 2, 0, 'true')");
2270 2266
2271 debugEventCount = 0; 2267 debugEventCount = 0;
2272 env->AllowCodeGenerationFromStrings(false); 2268 env->AllowCodeGenerationFromStrings(false);
2273 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 2269 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
2274 CHECK_EQ(1, debugEventCount); 2270 CHECK_EQ(1, debugEventCount);
2275 2271
2276 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 2272 SetDebugEventListener(env->GetIsolate(), nullptr);
2277 CheckDebuggerUnloaded(env->GetIsolate()); 2273 CheckDebuggerUnloaded(env->GetIsolate());
2278 } 2274 }
2279 2275
2280 2276
2281 bool checkedDebugEvals = true; 2277 bool checkedDebugEvals = true;
2282 v8::Local<v8::Function> checkGlobalEvalFunction; 2278 v8::Local<v8::Function> checkGlobalEvalFunction;
2283 v8::Local<v8::Function> checkFrameEvalFunction; 2279 v8::Local<v8::Function> checkFrameEvalFunction;
2284 static void CheckDebugEval(const v8::Debug::EventDetails& eventDetails) { 2280 static void CheckDebugEval(const v8::Debug::EventDetails& eventDetails) {
2285 if (eventDetails.GetEvent() == v8::Break) { 2281 if (eventDetails.GetEvent() == v8::Break) {
2286 ++debugEventCount; 2282 ++debugEventCount;
(...skipping 16 matching lines...) Expand all
2303 2299
2304 2300
2305 // Test that the evaluation of expressions when a break point is hit generates 2301 // Test that the evaluation of expressions when a break point is hit generates
2306 // the correct results in case code generation from strings is disallowed in the 2302 // the correct results in case code generation from strings is disallowed in the
2307 // debugee context. 2303 // debugee context.
2308 TEST(DebugEvaluateWithCodeGenerationDisallowed) { 2304 TEST(DebugEvaluateWithCodeGenerationDisallowed) {
2309 DebugLocalContext env; 2305 DebugLocalContext env;
2310 v8::HandleScope scope(env->GetIsolate()); 2306 v8::HandleScope scope(env->GetIsolate());
2311 env.ExposeDebug(); 2307 env.ExposeDebug();
2312 2308
2313 v8::Debug::SetDebugEventListener(env->GetIsolate(), CheckDebugEval); 2309 SetDebugEventListener(env->GetIsolate(), CheckDebugEval);
2314 2310
2315 v8::Local<v8::Context> context = env.context(); 2311 v8::Local<v8::Context> context = env.context();
2316 v8::Local<v8::Function> foo = CompileFunction(&env, 2312 v8::Local<v8::Function> foo = CompileFunction(&env,
2317 "var global = 'Global';\n" 2313 "var global = 'Global';\n"
2318 "function foo(x) {\n" 2314 "function foo(x) {\n"
2319 " var local = 'Local';\n" 2315 " var local = 'Local';\n"
2320 " debugger;\n" 2316 " debugger;\n"
2321 " return local + x;\n" 2317 " return local + x;\n"
2322 "}", 2318 "}",
2323 "foo"); 2319 "foo");
2324 checkGlobalEvalFunction = CompileFunction(&env, 2320 checkGlobalEvalFunction = CompileFunction(&env,
2325 "function checkGlobalEval(exec_state) {\n" 2321 "function checkGlobalEval(exec_state) {\n"
2326 " return exec_state.evaluateGlobal('global').value() === 'Global';\n" 2322 " return exec_state.evaluateGlobal('global').value() === 'Global';\n"
2327 "}", 2323 "}",
2328 "checkGlobalEval"); 2324 "checkGlobalEval");
2329 2325
2330 checkFrameEvalFunction = CompileFunction(&env, 2326 checkFrameEvalFunction = CompileFunction(&env,
2331 "function checkFrameEval(exec_state) {\n" 2327 "function checkFrameEval(exec_state) {\n"
2332 " return exec_state.frame(0).evaluate('local').value() === 'Local';\n" 2328 " return exec_state.frame(0).evaluate('local').value() === 'Local';\n"
2333 "}", 2329 "}",
2334 "checkFrameEval"); 2330 "checkFrameEval");
2335 debugEventCount = 0; 2331 debugEventCount = 0;
2336 env->AllowCodeGenerationFromStrings(false); 2332 env->AllowCodeGenerationFromStrings(false);
2337 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 2333 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
2338 CHECK_EQ(1, debugEventCount); 2334 CHECK_EQ(1, debugEventCount);
2339 2335
2340 checkGlobalEvalFunction.Clear(); 2336 checkGlobalEvalFunction.Clear();
2341 checkFrameEvalFunction.Clear(); 2337 checkFrameEvalFunction.Clear();
2342 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 2338 SetDebugEventListener(env->GetIsolate(), nullptr);
2343 CheckDebuggerUnloaded(env->GetIsolate()); 2339 CheckDebuggerUnloaded(env->GetIsolate());
2344 } 2340 }
2345 2341
2346 2342
2347 // Simple test of the stepping mechanism using only store ICs. 2343 // Simple test of the stepping mechanism using only store ICs.
2348 TEST(DebugStepLinear) { 2344 TEST(DebugStepLinear) {
2349 DebugLocalContext env; 2345 DebugLocalContext env;
2350 v8::HandleScope scope(env->GetIsolate()); 2346 v8::HandleScope scope(env->GetIsolate());
2351 2347
2352 // Create a function for testing stepping. 2348 // Create a function for testing stepping.
2353 v8::Local<v8::Function> foo = CompileFunction(&env, 2349 v8::Local<v8::Function> foo = CompileFunction(&env,
2354 "function foo(){a=1;b=1;c=1;}", 2350 "function foo(){a=1;b=1;c=1;}",
2355 "foo"); 2351 "foo");
2356 2352
2357 // Run foo to allow it to get optimized. 2353 // Run foo to allow it to get optimized.
2358 CompileRun("a=0; b=0; c=0; foo();"); 2354 CompileRun("a=0; b=0; c=0; foo();");
2359 2355
2360 // Register a debug event listener which steps and counts. 2356 // Register a debug event listener which steps and counts.
2361 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep); 2357 SetDebugEventListener(env->GetIsolate(), DebugEventStep);
2362 2358
2363 SetBreakPoint(foo, 3); 2359 SetBreakPoint(foo, 3);
2364 2360
2365 step_action = StepIn; 2361 step_action = StepIn;
2366 break_point_hit_count = 0; 2362 break_point_hit_count = 0;
2367 v8::Local<v8::Context> context = env.context(); 2363 v8::Local<v8::Context> context = env.context();
2368 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 2364 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
2369 2365
2370 // With stepping all break locations are hit. 2366 // With stepping all break locations are hit.
2371 CHECK_EQ(4, break_point_hit_count); 2367 CHECK_EQ(4, break_point_hit_count);
2372 2368
2373 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 2369 SetDebugEventListener(env->GetIsolate(), nullptr);
2374 CheckDebuggerUnloaded(env->GetIsolate()); 2370 CheckDebuggerUnloaded(env->GetIsolate());
2375 2371
2376 // Register a debug event listener which just counts. 2372 // Register a debug event listener which just counts.
2377 v8::Debug::SetDebugEventListener(env->GetIsolate(), 2373 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount);
2378 DebugEventBreakPointHitCount);
2379 2374
2380 SetBreakPoint(foo, 3); 2375 SetBreakPoint(foo, 3);
2381 break_point_hit_count = 0; 2376 break_point_hit_count = 0;
2382 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 2377 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
2383 2378
2384 // Without stepping only active break points are hit. 2379 // Without stepping only active break points are hit.
2385 CHECK_EQ(1, break_point_hit_count); 2380 CHECK_EQ(1, break_point_hit_count);
2386 2381
2387 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 2382 SetDebugEventListener(env->GetIsolate(), nullptr);
2388 CheckDebuggerUnloaded(env->GetIsolate()); 2383 CheckDebuggerUnloaded(env->GetIsolate());
2389 } 2384 }
2390 2385
2391 2386
2392 // Test of the stepping mechanism for keyed load in a loop. 2387 // Test of the stepping mechanism for keyed load in a loop.
2393 TEST(DebugStepKeyedLoadLoop) { 2388 TEST(DebugStepKeyedLoadLoop) {
2394 DebugLocalContext env; 2389 DebugLocalContext env;
2395 v8::HandleScope scope(env->GetIsolate()); 2390 v8::HandleScope scope(env->GetIsolate());
2396 2391
2397 // Register a debug event listener which steps and counts. 2392 // Register a debug event listener which steps and counts.
2398 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep); 2393 SetDebugEventListener(env->GetIsolate(), DebugEventStep);
2399 2394
2400 // Create a function for testing stepping of keyed load. The statement 'y=1' 2395 // Create a function for testing stepping of keyed load. The statement 'y=1'
2401 // is there to have more than one breakable statement in the loop, TODO(315). 2396 // is there to have more than one breakable statement in the loop, TODO(315).
2402 v8::Local<v8::Function> foo = CompileFunction( 2397 v8::Local<v8::Function> foo = CompileFunction(
2403 &env, 2398 &env,
2404 "function foo(a) {\n" 2399 "function foo(a) {\n"
2405 " var x;\n" 2400 " var x;\n"
2406 " var len = a.length;\n" 2401 " var len = a.length;\n"
2407 " for (var i = 0; i < len; i++) {\n" 2402 " for (var i = 0; i < len; i++) {\n"
2408 " y = 1;\n" 2403 " y = 1;\n"
(...skipping 19 matching lines...) Expand all
2428 2423
2429 // Set up break point and step through the function. 2424 // Set up break point and step through the function.
2430 SetBreakPoint(foo, 3); 2425 SetBreakPoint(foo, 3);
2431 step_action = StepNext; 2426 step_action = StepNext;
2432 break_point_hit_count = 0; 2427 break_point_hit_count = 0;
2433 foo->Call(context, env->Global(), kArgc, args).ToLocalChecked(); 2428 foo->Call(context, env->Global(), kArgc, args).ToLocalChecked();
2434 2429
2435 // With stepping all break locations are hit. 2430 // With stepping all break locations are hit.
2436 CHECK_EQ(44, break_point_hit_count); 2431 CHECK_EQ(44, break_point_hit_count);
2437 2432
2438 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 2433 SetDebugEventListener(env->GetIsolate(), nullptr);
2439 CheckDebuggerUnloaded(env->GetIsolate()); 2434 CheckDebuggerUnloaded(env->GetIsolate());
2440 } 2435 }
2441 2436
2442 2437
2443 // Test of the stepping mechanism for keyed store in a loop. 2438 // Test of the stepping mechanism for keyed store in a loop.
2444 TEST(DebugStepKeyedStoreLoop) { 2439 TEST(DebugStepKeyedStoreLoop) {
2445 DebugLocalContext env; 2440 DebugLocalContext env;
2446 v8::HandleScope scope(env->GetIsolate()); 2441 v8::HandleScope scope(env->GetIsolate());
2447 2442
2448 // Register a debug event listener which steps and counts. 2443 // Register a debug event listener which steps and counts.
2449 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep); 2444 SetDebugEventListener(env->GetIsolate(), DebugEventStep);
2450 2445
2451 // Create a function for testing stepping of keyed store. The statement 'y=1' 2446 // Create a function for testing stepping of keyed store. The statement 'y=1'
2452 // is there to have more than one breakable statement in the loop, TODO(315). 2447 // is there to have more than one breakable statement in the loop, TODO(315).
2453 v8::Local<v8::Function> foo = CompileFunction( 2448 v8::Local<v8::Function> foo = CompileFunction(
2454 &env, 2449 &env,
2455 "function foo(a) {\n" 2450 "function foo(a) {\n"
2456 " var len = a.length;\n" 2451 " var len = a.length;\n"
2457 " for (var i = 0; i < len; i++) {\n" 2452 " for (var i = 0; i < len; i++) {\n"
2458 " y = 1;\n" 2453 " y = 1;\n"
2459 " a[i] = 42;\n" 2454 " a[i] = 42;\n"
(...skipping 18 matching lines...) Expand all
2478 2473
2479 // Set up break point and step through the function. 2474 // Set up break point and step through the function.
2480 SetBreakPoint(foo, 3); 2475 SetBreakPoint(foo, 3);
2481 step_action = StepNext; 2476 step_action = StepNext;
2482 break_point_hit_count = 0; 2477 break_point_hit_count = 0;
2483 foo->Call(context, env->Global(), kArgc, args).ToLocalChecked(); 2478 foo->Call(context, env->Global(), kArgc, args).ToLocalChecked();
2484 2479
2485 // With stepping all break locations are hit. 2480 // With stepping all break locations are hit.
2486 CHECK_EQ(44, break_point_hit_count); 2481 CHECK_EQ(44, break_point_hit_count);
2487 2482
2488 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 2483 SetDebugEventListener(env->GetIsolate(), nullptr);
2489 CheckDebuggerUnloaded(env->GetIsolate()); 2484 CheckDebuggerUnloaded(env->GetIsolate());
2490 } 2485 }
2491 2486
2492 2487
2493 // Test of the stepping mechanism for named load in a loop. 2488 // Test of the stepping mechanism for named load in a loop.
2494 TEST(DebugStepNamedLoadLoop) { 2489 TEST(DebugStepNamedLoadLoop) {
2495 DebugLocalContext env; 2490 DebugLocalContext env;
2496 v8::HandleScope scope(env->GetIsolate()); 2491 v8::HandleScope scope(env->GetIsolate());
2497 2492
2498 // Register a debug event listener which steps and counts. 2493 // Register a debug event listener which steps and counts.
2499 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep); 2494 SetDebugEventListener(env->GetIsolate(), DebugEventStep);
2500 2495
2501 v8::Local<v8::Context> context = env.context(); 2496 v8::Local<v8::Context> context = env.context();
2502 // Create a function for testing stepping of named load. 2497 // Create a function for testing stepping of named load.
2503 v8::Local<v8::Function> foo = CompileFunction( 2498 v8::Local<v8::Function> foo = CompileFunction(
2504 &env, 2499 &env,
2505 "function foo() {\n" 2500 "function foo() {\n"
2506 " var a = [];\n" 2501 " var a = [];\n"
2507 " var s = \"\";\n" 2502 " var s = \"\";\n"
2508 " for (var i = 0; i < 10; i++) {\n" 2503 " for (var i = 0; i < 10; i++) {\n"
2509 " var v = new V(i, i + 1);\n" 2504 " var v = new V(i, i + 1);\n"
(...skipping 13 matching lines...) Expand all
2523 2518
2524 // Set up break point and step through the function. 2519 // Set up break point and step through the function.
2525 SetBreakPoint(foo, 4); 2520 SetBreakPoint(foo, 4);
2526 step_action = StepNext; 2521 step_action = StepNext;
2527 break_point_hit_count = 0; 2522 break_point_hit_count = 0;
2528 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 2523 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
2529 2524
2530 // With stepping all break locations are hit. 2525 // With stepping all break locations are hit.
2531 CHECK_EQ(65, break_point_hit_count); 2526 CHECK_EQ(65, break_point_hit_count);
2532 2527
2533 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 2528 SetDebugEventListener(env->GetIsolate(), nullptr);
2534 CheckDebuggerUnloaded(env->GetIsolate()); 2529 CheckDebuggerUnloaded(env->GetIsolate());
2535 } 2530 }
2536 2531
2537 2532
2538 static void DoDebugStepNamedStoreLoop(int expected) { 2533 static void DoDebugStepNamedStoreLoop(int expected) {
2539 DebugLocalContext env; 2534 DebugLocalContext env;
2540 v8::HandleScope scope(env->GetIsolate()); 2535 v8::HandleScope scope(env->GetIsolate());
2541 2536
2542 // Register a debug event listener which steps and counts. 2537 // Register a debug event listener which steps and counts.
2543 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep); 2538 SetDebugEventListener(env->GetIsolate(), DebugEventStep);
2544 2539
2545 // Create a function for testing stepping of named store. 2540 // Create a function for testing stepping of named store.
2546 v8::Local<v8::Context> context = env.context(); 2541 v8::Local<v8::Context> context = env.context();
2547 v8::Local<v8::Function> foo = CompileFunction( 2542 v8::Local<v8::Function> foo = CompileFunction(
2548 &env, 2543 &env,
2549 "function foo() {\n" 2544 "function foo() {\n"
2550 " var a = {a:1};\n" 2545 " var a = {a:1};\n"
2551 " for (var i = 0; i < 10; i++) {\n" 2546 " for (var i = 0; i < 10; i++) {\n"
2552 " a.a = 2\n" 2547 " a.a = 2\n"
2553 " }\n" 2548 " }\n"
2554 "}\n", 2549 "}\n",
2555 "foo"); 2550 "foo");
2556 2551
2557 // Call function without any break points to ensure inlining is in place. 2552 // Call function without any break points to ensure inlining is in place.
2558 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 2553 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
2559 2554
2560 // Set up break point and step through the function. 2555 // Set up break point and step through the function.
2561 SetBreakPoint(foo, 3); 2556 SetBreakPoint(foo, 3);
2562 step_action = StepNext; 2557 step_action = StepNext;
2563 break_point_hit_count = 0; 2558 break_point_hit_count = 0;
2564 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 2559 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
2565 2560
2566 // With stepping all expected break locations are hit. 2561 // With stepping all expected break locations are hit.
2567 CHECK_EQ(expected, break_point_hit_count); 2562 CHECK_EQ(expected, break_point_hit_count);
2568 2563
2569 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 2564 SetDebugEventListener(env->GetIsolate(), nullptr);
2570 CheckDebuggerUnloaded(env->GetIsolate()); 2565 CheckDebuggerUnloaded(env->GetIsolate());
2571 } 2566 }
2572 2567
2573 2568
2574 // Test of the stepping mechanism for named load in a loop. 2569 // Test of the stepping mechanism for named load in a loop.
2575 TEST(DebugStepNamedStoreLoop) { DoDebugStepNamedStoreLoop(34); } 2570 TEST(DebugStepNamedStoreLoop) { DoDebugStepNamedStoreLoop(34); }
2576 2571
2577 // Test the stepping mechanism with different ICs. 2572 // Test the stepping mechanism with different ICs.
2578 TEST(DebugStepLinearMixedICs) { 2573 TEST(DebugStepLinearMixedICs) {
2579 DebugLocalContext env; 2574 DebugLocalContext env;
2580 v8::HandleScope scope(env->GetIsolate()); 2575 v8::HandleScope scope(env->GetIsolate());
2581 2576
2582 // Register a debug event listener which steps and counts. 2577 // Register a debug event listener which steps and counts.
2583 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep); 2578 SetDebugEventListener(env->GetIsolate(), DebugEventStep);
2584 2579
2585 v8::Local<v8::Context> context = env.context(); 2580 v8::Local<v8::Context> context = env.context();
2586 // Create a function for testing stepping. 2581 // Create a function for testing stepping.
2587 v8::Local<v8::Function> foo = CompileFunction(&env, 2582 v8::Local<v8::Function> foo = CompileFunction(&env,
2588 "function bar() {};" 2583 "function bar() {};"
2589 "function foo() {" 2584 "function foo() {"
2590 " var x;" 2585 " var x;"
2591 " var index='name';" 2586 " var index='name';"
2592 " var y = {};" 2587 " var y = {};"
2593 " a=1;b=2;x=a;y[index]=3;x=y[index];bar();}", "foo"); 2588 " a=1;b=2;x=a;y[index]=3;x=y[index];bar();}", "foo");
2594 2589
2595 // Run functions to allow them to get optimized. 2590 // Run functions to allow them to get optimized.
2596 CompileRun("a=0; b=0; bar(); foo();"); 2591 CompileRun("a=0; b=0; bar(); foo();");
2597 2592
2598 SetBreakPoint(foo, 0); 2593 SetBreakPoint(foo, 0);
2599 2594
2600 step_action = StepIn; 2595 step_action = StepIn;
2601 break_point_hit_count = 0; 2596 break_point_hit_count = 0;
2602 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 2597 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
2603 2598
2604 // With stepping all break locations are hit. 2599 // With stepping all break locations are hit.
2605 CHECK_EQ(10, break_point_hit_count); 2600 CHECK_EQ(10, break_point_hit_count);
2606 2601
2607 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 2602 SetDebugEventListener(env->GetIsolate(), nullptr);
2608 CheckDebuggerUnloaded(env->GetIsolate()); 2603 CheckDebuggerUnloaded(env->GetIsolate());
2609 2604
2610 // Register a debug event listener which just counts. 2605 // Register a debug event listener which just counts.
2611 v8::Debug::SetDebugEventListener(env->GetIsolate(), 2606 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount);
2612 DebugEventBreakPointHitCount);
2613 2607
2614 SetBreakPoint(foo, 0); 2608 SetBreakPoint(foo, 0);
2615 break_point_hit_count = 0; 2609 break_point_hit_count = 0;
2616 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 2610 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
2617 2611
2618 // Without stepping only active break points are hit. 2612 // Without stepping only active break points are hit.
2619 CHECK_EQ(1, break_point_hit_count); 2613 CHECK_EQ(1, break_point_hit_count);
2620 2614
2621 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 2615 SetDebugEventListener(env->GetIsolate(), nullptr);
2622 CheckDebuggerUnloaded(env->GetIsolate()); 2616 CheckDebuggerUnloaded(env->GetIsolate());
2623 } 2617 }
2624 2618
2625 2619
2626 TEST(DebugStepDeclarations) { 2620 TEST(DebugStepDeclarations) {
2627 DebugLocalContext env; 2621 DebugLocalContext env;
2628 v8::HandleScope scope(env->GetIsolate()); 2622 v8::HandleScope scope(env->GetIsolate());
2629 2623
2630 // Register a debug event listener which steps and counts. 2624 // Register a debug event listener which steps and counts.
2631 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep); 2625 SetDebugEventListener(env->GetIsolate(), DebugEventStep);
2632 2626
2633 v8::Local<v8::Context> context = env.context(); 2627 v8::Local<v8::Context> context = env.context();
2634 // Create a function for testing stepping. Run it to allow it to get 2628 // Create a function for testing stepping. Run it to allow it to get
2635 // optimized. 2629 // optimized.
2636 const char* src = "function foo() { " 2630 const char* src = "function foo() { "
2637 " var a;" 2631 " var a;"
2638 " var b = 1;" 2632 " var b = 1;"
2639 " var c = foo;" 2633 " var c = foo;"
2640 " var d = Math.floor;" 2634 " var d = Math.floor;"
2641 " var e = b + d(1.2);" 2635 " var e = b + d(1.2);"
2642 "}" 2636 "}"
2643 "foo()"; 2637 "foo()";
2644 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 2638 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
2645 2639
2646 SetBreakPoint(foo, 0); 2640 SetBreakPoint(foo, 0);
2647 2641
2648 // Stepping through the declarations. 2642 // Stepping through the declarations.
2649 step_action = StepIn; 2643 step_action = StepIn;
2650 break_point_hit_count = 0; 2644 break_point_hit_count = 0;
2651 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 2645 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
2652 CHECK_EQ(5, break_point_hit_count); 2646 CHECK_EQ(5, break_point_hit_count);
2653 2647
2654 // Get rid of the debug event listener. 2648 // Get rid of the debug event listener.
2655 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 2649 SetDebugEventListener(env->GetIsolate(), nullptr);
2656 CheckDebuggerUnloaded(env->GetIsolate()); 2650 CheckDebuggerUnloaded(env->GetIsolate());
2657 } 2651 }
2658 2652
2659 2653
2660 TEST(DebugStepLocals) { 2654 TEST(DebugStepLocals) {
2661 DebugLocalContext env; 2655 DebugLocalContext env;
2662 v8::HandleScope scope(env->GetIsolate()); 2656 v8::HandleScope scope(env->GetIsolate());
2663 2657
2664 // Register a debug event listener which steps and counts. 2658 // Register a debug event listener which steps and counts.
2665 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep); 2659 SetDebugEventListener(env->GetIsolate(), DebugEventStep);
2666 2660
2667 v8::Local<v8::Context> context = env.context(); 2661 v8::Local<v8::Context> context = env.context();
2668 // Create a function for testing stepping. Run it to allow it to get 2662 // Create a function for testing stepping. Run it to allow it to get
2669 // optimized. 2663 // optimized.
2670 const char* src = "function foo() { " 2664 const char* src = "function foo() { "
2671 " var a,b;" 2665 " var a,b;"
2672 " a = 1;" 2666 " a = 1;"
2673 " b = a + 2;" 2667 " b = a + 2;"
2674 " b = 1 + 2 + 3;" 2668 " b = 1 + 2 + 3;"
2675 " a = Math.floor(b);" 2669 " a = Math.floor(b);"
2676 "}" 2670 "}"
2677 "foo()"; 2671 "foo()";
2678 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 2672 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
2679 2673
2680 SetBreakPoint(foo, 0); 2674 SetBreakPoint(foo, 0);
2681 2675
2682 // Stepping through the declarations. 2676 // Stepping through the declarations.
2683 step_action = StepIn; 2677 step_action = StepIn;
2684 break_point_hit_count = 0; 2678 break_point_hit_count = 0;
2685 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 2679 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
2686 CHECK_EQ(5, break_point_hit_count); 2680 CHECK_EQ(5, break_point_hit_count);
2687 2681
2688 // Get rid of the debug event listener. 2682 // Get rid of the debug event listener.
2689 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 2683 SetDebugEventListener(env->GetIsolate(), nullptr);
2690 CheckDebuggerUnloaded(env->GetIsolate()); 2684 CheckDebuggerUnloaded(env->GetIsolate());
2691 } 2685 }
2692 2686
2693 2687
2694 TEST(DebugStepIf) { 2688 TEST(DebugStepIf) {
2695 DebugLocalContext env; 2689 DebugLocalContext env;
2696 v8::Isolate* isolate = env->GetIsolate(); 2690 v8::Isolate* isolate = env->GetIsolate();
2697 v8::HandleScope scope(isolate); 2691 v8::HandleScope scope(isolate);
2698 2692
2699 // Register a debug event listener which steps and counts. 2693 // Register a debug event listener which steps and counts.
2700 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep); 2694 SetDebugEventListener(env->GetIsolate(), DebugEventStep);
2701 2695
2702 v8::Local<v8::Context> context = env.context(); 2696 v8::Local<v8::Context> context = env.context();
2703 // Create a function for testing stepping. Run it to allow it to get 2697 // Create a function for testing stepping. Run it to allow it to get
2704 // optimized. 2698 // optimized.
2705 const int argc = 1; 2699 const int argc = 1;
2706 const char* src = "function foo(x) { " 2700 const char* src = "function foo(x) { "
2707 " a = 1;" 2701 " a = 1;"
2708 " if (x) {" 2702 " if (x) {"
2709 " b = 1;" 2703 " b = 1;"
2710 " } else {" 2704 " } else {"
(...skipping 13 matching lines...) Expand all
2724 CHECK_EQ(4, break_point_hit_count); 2718 CHECK_EQ(4, break_point_hit_count);
2725 2719
2726 // Stepping through the false part. 2720 // Stepping through the false part.
2727 step_action = StepIn; 2721 step_action = StepIn;
2728 break_point_hit_count = 0; 2722 break_point_hit_count = 0;
2729 v8::Local<v8::Value> argv_false[argc] = {v8::False(isolate)}; 2723 v8::Local<v8::Value> argv_false[argc] = {v8::False(isolate)};
2730 foo->Call(context, env->Global(), argc, argv_false).ToLocalChecked(); 2724 foo->Call(context, env->Global(), argc, argv_false).ToLocalChecked();
2731 CHECK_EQ(5, break_point_hit_count); 2725 CHECK_EQ(5, break_point_hit_count);
2732 2726
2733 // Get rid of the debug event listener. 2727 // Get rid of the debug event listener.
2734 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 2728 SetDebugEventListener(env->GetIsolate(), nullptr);
2735 CheckDebuggerUnloaded(isolate); 2729 CheckDebuggerUnloaded(isolate);
2736 } 2730 }
2737 2731
2738 2732
2739 TEST(DebugStepSwitch) { 2733 TEST(DebugStepSwitch) {
2740 DebugLocalContext env; 2734 DebugLocalContext env;
2741 v8::Isolate* isolate = env->GetIsolate(); 2735 v8::Isolate* isolate = env->GetIsolate();
2742 v8::HandleScope scope(isolate); 2736 v8::HandleScope scope(isolate);
2743 2737
2744 // Register a debug event listener which steps and counts. 2738 // Register a debug event listener which steps and counts.
2745 v8::Debug::SetDebugEventListener(isolate, DebugEventStep); 2739 SetDebugEventListener(isolate, DebugEventStep);
2746 2740
2747 v8::Local<v8::Context> context = env.context(); 2741 v8::Local<v8::Context> context = env.context();
2748 // Create a function for testing stepping. Run it to allow it to get 2742 // Create a function for testing stepping. Run it to allow it to get
2749 // optimized. 2743 // optimized.
2750 const int argc = 1; 2744 const int argc = 1;
2751 const char* src = "function foo(x) { " 2745 const char* src = "function foo(x) { "
2752 " a = 1;" 2746 " a = 1;"
2753 " switch (x) {" 2747 " switch (x) {"
2754 " case 1:" 2748 " case 1:"
2755 " b = 1;" 2749 " b = 1;"
(...skipping 26 matching lines...) Expand all
2782 CHECK_EQ(5, break_point_hit_count); 2776 CHECK_EQ(5, break_point_hit_count);
2783 2777
2784 // Last case. 2778 // Last case.
2785 step_action = StepIn; 2779 step_action = StepIn;
2786 break_point_hit_count = 0; 2780 break_point_hit_count = 0;
2787 v8::Local<v8::Value> argv_3[argc] = {v8::Number::New(isolate, 3)}; 2781 v8::Local<v8::Value> argv_3[argc] = {v8::Number::New(isolate, 3)};
2788 foo->Call(context, env->Global(), argc, argv_3).ToLocalChecked(); 2782 foo->Call(context, env->Global(), argc, argv_3).ToLocalChecked();
2789 CHECK_EQ(7, break_point_hit_count); 2783 CHECK_EQ(7, break_point_hit_count);
2790 2784
2791 // Get rid of the debug event listener. 2785 // Get rid of the debug event listener.
2792 v8::Debug::SetDebugEventListener(isolate, nullptr); 2786 SetDebugEventListener(isolate, nullptr);
2793 CheckDebuggerUnloaded(isolate); 2787 CheckDebuggerUnloaded(isolate);
2794 } 2788 }
2795 2789
2796 2790
2797 TEST(DebugStepWhile) { 2791 TEST(DebugStepWhile) {
2798 DebugLocalContext env; 2792 DebugLocalContext env;
2799 v8::Isolate* isolate = env->GetIsolate(); 2793 v8::Isolate* isolate = env->GetIsolate();
2800 v8::HandleScope scope(isolate); 2794 v8::HandleScope scope(isolate);
2801 2795
2802 // Register a debug event listener which steps and counts. 2796 // Register a debug event listener which steps and counts.
2803 v8::Debug::SetDebugEventListener(isolate, DebugEventStep); 2797 SetDebugEventListener(isolate, DebugEventStep);
2804 2798
2805 v8::Local<v8::Context> context = env.context(); 2799 v8::Local<v8::Context> context = env.context();
2806 // Create a function for testing stepping. Run it to allow it to get 2800 // Create a function for testing stepping. Run it to allow it to get
2807 // optimized. 2801 // optimized.
2808 const int argc = 1; 2802 const int argc = 1;
2809 const char* src = "function foo(x) { " 2803 const char* src = "function foo(x) { "
2810 " var a = 0;" 2804 " var a = 0;"
2811 " while (a < x) {" 2805 " while (a < x) {"
2812 " a++;" 2806 " a++;"
2813 " }" 2807 " }"
(...skipping 17 matching lines...) Expand all
2831 CHECK_EQ(23, break_point_hit_count); 2825 CHECK_EQ(23, break_point_hit_count);
2832 2826
2833 // Looping 100 times. 2827 // Looping 100 times.
2834 step_action = StepIn; 2828 step_action = StepIn;
2835 break_point_hit_count = 0; 2829 break_point_hit_count = 0;
2836 v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)}; 2830 v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)};
2837 foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked(); 2831 foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked();
2838 CHECK_EQ(203, break_point_hit_count); 2832 CHECK_EQ(203, break_point_hit_count);
2839 2833
2840 // Get rid of the debug event listener. 2834 // Get rid of the debug event listener.
2841 v8::Debug::SetDebugEventListener(isolate, nullptr); 2835 SetDebugEventListener(isolate, nullptr);
2842 CheckDebuggerUnloaded(isolate); 2836 CheckDebuggerUnloaded(isolate);
2843 } 2837 }
2844 2838
2845 2839
2846 TEST(DebugStepDoWhile) { 2840 TEST(DebugStepDoWhile) {
2847 DebugLocalContext env; 2841 DebugLocalContext env;
2848 v8::Isolate* isolate = env->GetIsolate(); 2842 v8::Isolate* isolate = env->GetIsolate();
2849 v8::HandleScope scope(isolate); 2843 v8::HandleScope scope(isolate);
2850 2844
2851 // Register a debug event listener which steps and counts. 2845 // Register a debug event listener which steps and counts.
2852 v8::Debug::SetDebugEventListener(isolate, DebugEventStep); 2846 SetDebugEventListener(isolate, DebugEventStep);
2853 2847
2854 v8::Local<v8::Context> context = env.context(); 2848 v8::Local<v8::Context> context = env.context();
2855 // Create a function for testing stepping. Run it to allow it to get 2849 // Create a function for testing stepping. Run it to allow it to get
2856 // optimized. 2850 // optimized.
2857 const int argc = 1; 2851 const int argc = 1;
2858 const char* src = "function foo(x) { " 2852 const char* src = "function foo(x) { "
2859 " var a = 0;" 2853 " var a = 0;"
2860 " do {" 2854 " do {"
2861 " a++;" 2855 " a++;"
2862 " } while (a < x)" 2856 " } while (a < x)"
(...skipping 17 matching lines...) Expand all
2880 CHECK_EQ(22, break_point_hit_count); 2874 CHECK_EQ(22, break_point_hit_count);
2881 2875
2882 // Looping 100 times. 2876 // Looping 100 times.
2883 step_action = StepIn; 2877 step_action = StepIn;
2884 break_point_hit_count = 0; 2878 break_point_hit_count = 0;
2885 v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)}; 2879 v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)};
2886 foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked(); 2880 foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked();
2887 CHECK_EQ(202, break_point_hit_count); 2881 CHECK_EQ(202, break_point_hit_count);
2888 2882
2889 // Get rid of the debug event listener. 2883 // Get rid of the debug event listener.
2890 v8::Debug::SetDebugEventListener(isolate, nullptr); 2884 SetDebugEventListener(isolate, nullptr);
2891 CheckDebuggerUnloaded(isolate); 2885 CheckDebuggerUnloaded(isolate);
2892 } 2886 }
2893 2887
2894 2888
2895 TEST(DebugStepFor) { 2889 TEST(DebugStepFor) {
2896 DebugLocalContext env; 2890 DebugLocalContext env;
2897 v8::Isolate* isolate = env->GetIsolate(); 2891 v8::Isolate* isolate = env->GetIsolate();
2898 v8::HandleScope scope(isolate); 2892 v8::HandleScope scope(isolate);
2899 2893
2900 // Register a debug event listener which steps and counts. 2894 // Register a debug event listener which steps and counts.
2901 v8::Debug::SetDebugEventListener(isolate, DebugEventStep); 2895 SetDebugEventListener(isolate, DebugEventStep);
2902 2896
2903 v8::Local<v8::Context> context = env.context(); 2897 v8::Local<v8::Context> context = env.context();
2904 // Create a function for testing stepping. Run it to allow it to get 2898 // Create a function for testing stepping. Run it to allow it to get
2905 // optimized. 2899 // optimized.
2906 const int argc = 1; 2900 const int argc = 1;
2907 const char* src = "function foo(x) { " 2901 const char* src = "function foo(x) { "
2908 " a = 1;" 2902 " a = 1;"
2909 " for (i = 0; i < x; i++) {" 2903 " for (i = 0; i < x; i++) {"
2910 " b = 1;" 2904 " b = 1;"
2911 " }" 2905 " }"
(...skipping 18 matching lines...) Expand all
2930 CHECK_EQ(34, break_point_hit_count); 2924 CHECK_EQ(34, break_point_hit_count);
2931 2925
2932 // Looping 100 times. 2926 // Looping 100 times.
2933 step_action = StepIn; 2927 step_action = StepIn;
2934 break_point_hit_count = 0; 2928 break_point_hit_count = 0;
2935 v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)}; 2929 v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)};
2936 foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked(); 2930 foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked();
2937 CHECK_EQ(304, break_point_hit_count); 2931 CHECK_EQ(304, break_point_hit_count);
2938 2932
2939 // Get rid of the debug event listener. 2933 // Get rid of the debug event listener.
2940 v8::Debug::SetDebugEventListener(isolate, nullptr); 2934 SetDebugEventListener(isolate, nullptr);
2941 CheckDebuggerUnloaded(isolate); 2935 CheckDebuggerUnloaded(isolate);
2942 } 2936 }
2943 2937
2944 2938
2945 TEST(DebugStepForContinue) { 2939 TEST(DebugStepForContinue) {
2946 DebugLocalContext env; 2940 DebugLocalContext env;
2947 v8::Isolate* isolate = env->GetIsolate(); 2941 v8::Isolate* isolate = env->GetIsolate();
2948 v8::HandleScope scope(isolate); 2942 v8::HandleScope scope(isolate);
2949 2943
2950 // Register a debug event listener which steps and counts. 2944 // Register a debug event listener which steps and counts.
2951 v8::Debug::SetDebugEventListener(isolate, DebugEventStep); 2945 SetDebugEventListener(isolate, DebugEventStep);
2952 2946
2953 v8::Local<v8::Context> context = env.context(); 2947 v8::Local<v8::Context> context = env.context();
2954 // Create a function for testing stepping. Run it to allow it to get 2948 // Create a function for testing stepping. Run it to allow it to get
2955 // optimized. 2949 // optimized.
2956 const int argc = 1; 2950 const int argc = 1;
2957 const char* src = "function foo(x) { " 2951 const char* src = "function foo(x) { "
2958 " var a = 0;" 2952 " var a = 0;"
2959 " var b = 0;" 2953 " var b = 0;"
2960 " var c = 0;" 2954 " var c = 0;"
2961 " for (var i = 0; i < x; i++) {" 2955 " for (var i = 0; i < x; i++) {"
(...skipping 21 matching lines...) Expand all
2983 2977
2984 // Looping 100 times. 2978 // Looping 100 times.
2985 step_action = StepIn; 2979 step_action = StepIn;
2986 break_point_hit_count = 0; 2980 break_point_hit_count = 0;
2987 v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)}; 2981 v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)};
2988 result = foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked(); 2982 result = foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked();
2989 CHECK_EQ(50, result->Int32Value(context).FromJust()); 2983 CHECK_EQ(50, result->Int32Value(context).FromJust());
2990 CHECK_EQ(557, break_point_hit_count); 2984 CHECK_EQ(557, break_point_hit_count);
2991 2985
2992 // Get rid of the debug event listener. 2986 // Get rid of the debug event listener.
2993 v8::Debug::SetDebugEventListener(isolate, nullptr); 2987 SetDebugEventListener(isolate, nullptr);
2994 CheckDebuggerUnloaded(isolate); 2988 CheckDebuggerUnloaded(isolate);
2995 } 2989 }
2996 2990
2997 2991
2998 TEST(DebugStepForBreak) { 2992 TEST(DebugStepForBreak) {
2999 DebugLocalContext env; 2993 DebugLocalContext env;
3000 v8::Isolate* isolate = env->GetIsolate(); 2994 v8::Isolate* isolate = env->GetIsolate();
3001 v8::HandleScope scope(isolate); 2995 v8::HandleScope scope(isolate);
3002 2996
3003 // Register a debug event listener which steps and counts. 2997 // Register a debug event listener which steps and counts.
3004 v8::Debug::SetDebugEventListener(isolate, DebugEventStep); 2998 SetDebugEventListener(isolate, DebugEventStep);
3005 2999
3006 v8::Local<v8::Context> context = env.context(); 3000 v8::Local<v8::Context> context = env.context();
3007 // Create a function for testing stepping. Run it to allow it to get 3001 // Create a function for testing stepping. Run it to allow it to get
3008 // optimized. 3002 // optimized.
3009 const int argc = 1; 3003 const int argc = 1;
3010 const char* src = "function foo(x) { " 3004 const char* src = "function foo(x) { "
3011 " var a = 0;" 3005 " var a = 0;"
3012 " var b = 0;" 3006 " var b = 0;"
3013 " var c = 0;" 3007 " var c = 0;"
3014 " for (var i = 0; i < 1000; i++) {" 3008 " for (var i = 0; i < 1000; i++) {"
(...skipping 22 matching lines...) Expand all
3037 3031
3038 // Looping 100 times. 3032 // Looping 100 times.
3039 step_action = StepIn; 3033 step_action = StepIn;
3040 break_point_hit_count = 0; 3034 break_point_hit_count = 0;
3041 v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)}; 3035 v8::Local<v8::Value> argv_100[argc] = {v8::Number::New(isolate, 100)};
3042 result = foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked(); 3036 result = foo->Call(context, env->Global(), argc, argv_100).ToLocalChecked();
3043 CHECK_EQ(99, result->Int32Value(context).FromJust()); 3037 CHECK_EQ(99, result->Int32Value(context).FromJust());
3044 CHECK_EQ(604, break_point_hit_count); 3038 CHECK_EQ(604, break_point_hit_count);
3045 3039
3046 // Get rid of the debug event listener. 3040 // Get rid of the debug event listener.
3047 v8::Debug::SetDebugEventListener(isolate, nullptr); 3041 SetDebugEventListener(isolate, nullptr);
3048 CheckDebuggerUnloaded(isolate); 3042 CheckDebuggerUnloaded(isolate);
3049 } 3043 }
3050 3044
3051 3045
3052 TEST(DebugStepForIn) { 3046 TEST(DebugStepForIn) {
3053 DebugLocalContext env; 3047 DebugLocalContext env;
3054 v8::HandleScope scope(env->GetIsolate()); 3048 v8::HandleScope scope(env->GetIsolate());
3055 3049
3056 // Register a debug event listener which steps and counts. 3050 // Register a debug event listener which steps and counts.
3057 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep); 3051 SetDebugEventListener(env->GetIsolate(), DebugEventStep);
3058 3052
3059 v8::Local<v8::Context> context = env.context(); 3053 v8::Local<v8::Context> context = env.context();
3060 // Create a function for testing stepping. Run it to allow it to get 3054 // Create a function for testing stepping. Run it to allow it to get
3061 // optimized. 3055 // optimized.
3062 v8::Local<v8::Function> foo; 3056 v8::Local<v8::Function> foo;
3063 const char* src_1 = "function foo() { " 3057 const char* src_1 = "function foo() { "
3064 " var a = [1, 2];" 3058 " var a = [1, 2];"
3065 " for (x in a) {" 3059 " for (x in a) {"
3066 " b = 0;" 3060 " b = 0;"
3067 " }" 3061 " }"
(...skipping 18 matching lines...) Expand all
3086 "foo()"; 3080 "foo()";
3087 foo = CompileFunction(&env, src_2, "foo"); 3081 foo = CompileFunction(&env, src_2, "foo");
3088 SetBreakPoint(foo, 0); // "var a = ..." 3082 SetBreakPoint(foo, 0); // "var a = ..."
3089 3083
3090 step_action = StepIn; 3084 step_action = StepIn;
3091 break_point_hit_count = 0; 3085 break_point_hit_count = 0;
3092 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3086 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3093 CHECK_EQ(10, break_point_hit_count); 3087 CHECK_EQ(10, break_point_hit_count);
3094 3088
3095 // Get rid of the debug event listener. 3089 // Get rid of the debug event listener.
3096 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 3090 SetDebugEventListener(env->GetIsolate(), nullptr);
3097 CheckDebuggerUnloaded(env->GetIsolate()); 3091 CheckDebuggerUnloaded(env->GetIsolate());
3098 } 3092 }
3099 3093
3100 3094
3101 TEST(DebugStepWith) { 3095 TEST(DebugStepWith) {
3102 DebugLocalContext env; 3096 DebugLocalContext env;
3103 v8::HandleScope scope(env->GetIsolate()); 3097 v8::HandleScope scope(env->GetIsolate());
3104 3098
3105 // Register a debug event listener which steps and counts. 3099 // Register a debug event listener which steps and counts.
3106 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep); 3100 SetDebugEventListener(env->GetIsolate(), DebugEventStep);
3107 3101
3108 v8::Local<v8::Context> context = env.context(); 3102 v8::Local<v8::Context> context = env.context();
3109 // Create a function for testing stepping. Run it to allow it to get 3103 // Create a function for testing stepping. Run it to allow it to get
3110 // optimized. 3104 // optimized.
3111 const char* src = "function foo(x) { " 3105 const char* src = "function foo(x) { "
3112 " var a = {};" 3106 " var a = {};"
3113 " with (a) {}" 3107 " with (a) {}"
3114 " with (b) {}" 3108 " with (b) {}"
3115 "}" 3109 "}"
3116 "foo()"; 3110 "foo()";
3117 CHECK(env->Global() 3111 CHECK(env->Global()
3118 ->Set(context, v8_str(env->GetIsolate(), "b"), 3112 ->Set(context, v8_str(env->GetIsolate(), "b"),
3119 v8::Object::New(env->GetIsolate())) 3113 v8::Object::New(env->GetIsolate()))
3120 .FromJust()); 3114 .FromJust());
3121 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3115 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3122 v8::Local<v8::Value> result; 3116 v8::Local<v8::Value> result;
3123 SetBreakPoint(foo, 8); // "var a = {};" 3117 SetBreakPoint(foo, 8); // "var a = {};"
3124 3118
3125 step_action = StepIn; 3119 step_action = StepIn;
3126 break_point_hit_count = 0; 3120 break_point_hit_count = 0;
3127 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3121 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3128 CHECK_EQ(4, break_point_hit_count); 3122 CHECK_EQ(4, break_point_hit_count);
3129 3123
3130 // Get rid of the debug event listener. 3124 // Get rid of the debug event listener.
3131 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 3125 SetDebugEventListener(env->GetIsolate(), nullptr);
3132 CheckDebuggerUnloaded(env->GetIsolate()); 3126 CheckDebuggerUnloaded(env->GetIsolate());
3133 } 3127 }
3134 3128
3135 3129
3136 TEST(DebugConditional) { 3130 TEST(DebugConditional) {
3137 DebugLocalContext env; 3131 DebugLocalContext env;
3138 v8::Isolate* isolate = env->GetIsolate(); 3132 v8::Isolate* isolate = env->GetIsolate();
3139 v8::HandleScope scope(isolate); 3133 v8::HandleScope scope(isolate);
3140 3134
3141 // Register a debug event listener which steps and counts. 3135 // Register a debug event listener which steps and counts.
3142 v8::Debug::SetDebugEventListener(isolate, DebugEventStep); 3136 SetDebugEventListener(isolate, DebugEventStep);
3143 3137
3144 v8::Local<v8::Context> context = env.context(); 3138 v8::Local<v8::Context> context = env.context();
3145 // Create a function for testing stepping. Run it to allow it to get 3139 // Create a function for testing stepping. Run it to allow it to get
3146 // optimized. 3140 // optimized.
3147 const char* src = 3141 const char* src =
3148 "function foo(x) { " 3142 "function foo(x) { "
3149 " return x ? 1 : 2;" 3143 " return x ? 1 : 2;"
3150 "}" 3144 "}"
3151 "foo()"; 3145 "foo()";
3152 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3146 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3153 SetBreakPoint(foo, 0); // "var a;" 3147 SetBreakPoint(foo, 0); // "var a;"
3154 3148
3155 step_action = StepIn; 3149 step_action = StepIn;
3156 break_point_hit_count = 0; 3150 break_point_hit_count = 0;
3157 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3151 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3158 CHECK_EQ(2, break_point_hit_count); 3152 CHECK_EQ(2, break_point_hit_count);
3159 3153
3160 step_action = StepIn; 3154 step_action = StepIn;
3161 break_point_hit_count = 0; 3155 break_point_hit_count = 0;
3162 const int argc = 1; 3156 const int argc = 1;
3163 v8::Local<v8::Value> argv_true[argc] = {v8::True(isolate)}; 3157 v8::Local<v8::Value> argv_true[argc] = {v8::True(isolate)};
3164 foo->Call(context, env->Global(), argc, argv_true).ToLocalChecked(); 3158 foo->Call(context, env->Global(), argc, argv_true).ToLocalChecked();
3165 CHECK_EQ(2, break_point_hit_count); 3159 CHECK_EQ(2, break_point_hit_count);
3166 3160
3167 // Get rid of the debug event listener. 3161 // Get rid of the debug event listener.
3168 v8::Debug::SetDebugEventListener(isolate, nullptr); 3162 SetDebugEventListener(isolate, nullptr);
3169 CheckDebuggerUnloaded(isolate); 3163 CheckDebuggerUnloaded(isolate);
3170 } 3164 }
3171 3165
3172 3166
3173 TEST(StepInOutSimple) { 3167 TEST(StepInOutSimple) {
3174 DebugLocalContext env; 3168 DebugLocalContext env;
3175 v8::HandleScope scope(env->GetIsolate()); 3169 v8::HandleScope scope(env->GetIsolate());
3176 3170
3177 // Create a function for checking the function when hitting a break point. 3171 // Create a function for checking the function when hitting a break point.
3178 frame_function_name = CompileFunction(&env, 3172 frame_function_name = CompileFunction(&env,
3179 frame_function_name_source, 3173 frame_function_name_source,
3180 "frame_function_name"); 3174 "frame_function_name");
3181 3175
3182 // Register a debug event listener which steps and counts. 3176 // Register a debug event listener which steps and counts.
3183 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStepSequence); 3177 SetDebugEventListener(env->GetIsolate(), DebugEventStepSequence);
3184 3178
3185 v8::Local<v8::Context> context = env.context(); 3179 v8::Local<v8::Context> context = env.context();
3186 // Create a function for testing stepping. Run it to allow it to get 3180 // Create a function for testing stepping. Run it to allow it to get
3187 // optimized. 3181 // optimized.
3188 const char* src = "function a() {b();c();}; " 3182 const char* src = "function a() {b();c();}; "
3189 "function b() {c();}; " 3183 "function b() {c();}; "
3190 "function c() {}; " 3184 "function c() {}; "
3191 "a(); b(); c()"; 3185 "a(); b(); c()";
3192 v8::Local<v8::Function> a = CompileFunction(&env, src, "a"); 3186 v8::Local<v8::Function> a = CompileFunction(&env, src, "a");
3193 SetBreakPoint(a, 0); 3187 SetBreakPoint(a, 0);
(...skipping 16 matching lines...) Expand all
3210 3204
3211 // Step through invocation of a with step out. 3205 // Step through invocation of a with step out.
3212 step_action = StepOut; 3206 step_action = StepOut;
3213 break_point_hit_count = 0; 3207 break_point_hit_count = 0;
3214 expected_step_sequence = "a"; 3208 expected_step_sequence = "a";
3215 a->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3209 a->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3216 CHECK_EQ(StrLength(expected_step_sequence), 3210 CHECK_EQ(StrLength(expected_step_sequence),
3217 break_point_hit_count); 3211 break_point_hit_count);
3218 3212
3219 // Get rid of the debug event listener. 3213 // Get rid of the debug event listener.
3220 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 3214 SetDebugEventListener(env->GetIsolate(), nullptr);
3221 CheckDebuggerUnloaded(env->GetIsolate()); 3215 CheckDebuggerUnloaded(env->GetIsolate());
3222 } 3216 }
3223 3217
3224 3218
3225 TEST(StepInOutTree) { 3219 TEST(StepInOutTree) {
3226 DebugLocalContext env; 3220 DebugLocalContext env;
3227 v8::HandleScope scope(env->GetIsolate()); 3221 v8::HandleScope scope(env->GetIsolate());
3228 3222
3229 // Create a function for checking the function when hitting a break point. 3223 // Create a function for checking the function when hitting a break point.
3230 frame_function_name = CompileFunction(&env, 3224 frame_function_name = CompileFunction(&env,
3231 frame_function_name_source, 3225 frame_function_name_source,
3232 "frame_function_name"); 3226 "frame_function_name");
3233 3227
3234 // Register a debug event listener which steps and counts. 3228 // Register a debug event listener which steps and counts.
3235 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStepSequence); 3229 SetDebugEventListener(env->GetIsolate(), DebugEventStepSequence);
3236 3230
3237 v8::Local<v8::Context> context = env.context(); 3231 v8::Local<v8::Context> context = env.context();
3238 // Create a function for testing stepping. Run it to allow it to get 3232 // Create a function for testing stepping. Run it to allow it to get
3239 // optimized. 3233 // optimized.
3240 const char* src = "function a() {b(c(d()),d());c(d());d()}; " 3234 const char* src = "function a() {b(c(d()),d());c(d());d()}; "
3241 "function b(x,y) {c();}; " 3235 "function b(x,y) {c();}; "
3242 "function c(x) {}; " 3236 "function c(x) {}; "
3243 "function d() {}; " 3237 "function d() {}; "
3244 "a(); b(); c(); d()"; 3238 "a(); b(); c(); d()";
3245 v8::Local<v8::Function> a = CompileFunction(&env, src, "a"); 3239 v8::Local<v8::Function> a = CompileFunction(&env, src, "a");
(...skipping 17 matching lines...) Expand all
3263 3257
3264 // Step through invocation of a with step out. 3258 // Step through invocation of a with step out.
3265 step_action = StepOut; 3259 step_action = StepOut;
3266 break_point_hit_count = 0; 3260 break_point_hit_count = 0;
3267 expected_step_sequence = "a"; 3261 expected_step_sequence = "a";
3268 a->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3262 a->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3269 CHECK_EQ(StrLength(expected_step_sequence), 3263 CHECK_EQ(StrLength(expected_step_sequence),
3270 break_point_hit_count); 3264 break_point_hit_count);
3271 3265
3272 // Get rid of the debug event listener. 3266 // Get rid of the debug event listener.
3273 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 3267 SetDebugEventListener(env->GetIsolate(), nullptr);
3274 CheckDebuggerUnloaded(env->GetIsolate(), true); 3268 CheckDebuggerUnloaded(env->GetIsolate(), true);
3275 } 3269 }
3276 3270
3277 3271
3278 TEST(StepInOutBranch) { 3272 TEST(StepInOutBranch) {
3279 DebugLocalContext env; 3273 DebugLocalContext env;
3280 v8::HandleScope scope(env->GetIsolate()); 3274 v8::HandleScope scope(env->GetIsolate());
3281 3275
3282 // Create a function for checking the function when hitting a break point. 3276 // Create a function for checking the function when hitting a break point.
3283 frame_function_name = CompileFunction(&env, 3277 frame_function_name = CompileFunction(&env,
3284 frame_function_name_source, 3278 frame_function_name_source,
3285 "frame_function_name"); 3279 "frame_function_name");
3286 3280
3287 // Register a debug event listener which steps and counts. 3281 // Register a debug event listener which steps and counts.
3288 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStepSequence); 3282 SetDebugEventListener(env->GetIsolate(), DebugEventStepSequence);
3289 3283
3290 v8::Local<v8::Context> context = env.context(); 3284 v8::Local<v8::Context> context = env.context();
3291 // Create a function for testing stepping. Run it to allow it to get 3285 // Create a function for testing stepping. Run it to allow it to get
3292 // optimized. 3286 // optimized.
3293 const char* src = "function a() {b(false);c();}; " 3287 const char* src = "function a() {b(false);c();}; "
3294 "function b(x) {if(x){c();};}; " 3288 "function b(x) {if(x){c();};}; "
3295 "function c() {}; " 3289 "function c() {}; "
3296 "a(); b(); c()"; 3290 "a(); b(); c()";
3297 v8::Local<v8::Function> a = CompileFunction(&env, src, "a"); 3291 v8::Local<v8::Function> a = CompileFunction(&env, src, "a");
3298 SetBreakPoint(a, 0); 3292 SetBreakPoint(a, 0);
3299 3293
3300 // Step through invocation of a. 3294 // Step through invocation of a.
3301 step_action = StepIn; 3295 step_action = StepIn;
3302 break_point_hit_count = 0; 3296 break_point_hit_count = 0;
3303 expected_step_sequence = "abbaca"; 3297 expected_step_sequence = "abbaca";
3304 a->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3298 a->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3305 CHECK_EQ(StrLength(expected_step_sequence), 3299 CHECK_EQ(StrLength(expected_step_sequence),
3306 break_point_hit_count); 3300 break_point_hit_count);
3307 3301
3308 // Get rid of the debug event listener. 3302 // Get rid of the debug event listener.
3309 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 3303 SetDebugEventListener(env->GetIsolate(), nullptr);
3310 CheckDebuggerUnloaded(env->GetIsolate()); 3304 CheckDebuggerUnloaded(env->GetIsolate());
3311 } 3305 }
3312 3306
3313 3307
3314 // Test that step in does not step into native functions. 3308 // Test that step in does not step into native functions.
3315 TEST(DebugStepNatives) { 3309 TEST(DebugStepNatives) {
3316 DebugLocalContext env; 3310 DebugLocalContext env;
3317 v8::HandleScope scope(env->GetIsolate()); 3311 v8::HandleScope scope(env->GetIsolate());
3318 3312
3319 // Create a function for testing stepping. 3313 // Create a function for testing stepping.
3320 v8::Local<v8::Function> foo = CompileFunction( 3314 v8::Local<v8::Function> foo = CompileFunction(
3321 &env, 3315 &env,
3322 "function foo(){debugger;Math.sin(1);}", 3316 "function foo(){debugger;Math.sin(1);}",
3323 "foo"); 3317 "foo");
3324 3318
3325 // Register a debug event listener which steps and counts. 3319 // Register a debug event listener which steps and counts.
3326 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep); 3320 SetDebugEventListener(env->GetIsolate(), DebugEventStep);
3327 3321
3328 v8::Local<v8::Context> context = env.context(); 3322 v8::Local<v8::Context> context = env.context();
3329 step_action = StepIn; 3323 step_action = StepIn;
3330 break_point_hit_count = 0; 3324 break_point_hit_count = 0;
3331 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3325 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3332 3326
3333 // With stepping all break locations are hit. 3327 // With stepping all break locations are hit.
3334 CHECK_EQ(3, break_point_hit_count); 3328 CHECK_EQ(3, break_point_hit_count);
3335 3329
3336 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 3330 SetDebugEventListener(env->GetIsolate(), nullptr);
3337 CheckDebuggerUnloaded(env->GetIsolate()); 3331 CheckDebuggerUnloaded(env->GetIsolate());
3338 3332
3339 // Register a debug event listener which just counts. 3333 // Register a debug event listener which just counts.
3340 v8::Debug::SetDebugEventListener(env->GetIsolate(), 3334 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount);
3341 DebugEventBreakPointHitCount);
3342 3335
3343 break_point_hit_count = 0; 3336 break_point_hit_count = 0;
3344 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3337 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3345 3338
3346 // Without stepping only active break points are hit. 3339 // Without stepping only active break points are hit.
3347 CHECK_EQ(1, break_point_hit_count); 3340 CHECK_EQ(1, break_point_hit_count);
3348 3341
3349 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 3342 SetDebugEventListener(env->GetIsolate(), nullptr);
3350 CheckDebuggerUnloaded(env->GetIsolate()); 3343 CheckDebuggerUnloaded(env->GetIsolate());
3351 } 3344 }
3352 3345
3353 3346
3354 // Test that step in works with function.apply. 3347 // Test that step in works with function.apply.
3355 TEST(DebugStepFunctionApply) { 3348 TEST(DebugStepFunctionApply) {
3356 DebugLocalContext env; 3349 DebugLocalContext env;
3357 v8::HandleScope scope(env->GetIsolate()); 3350 v8::HandleScope scope(env->GetIsolate());
3358 3351
3359 // Create a function for testing stepping. 3352 // Create a function for testing stepping.
3360 v8::Local<v8::Function> foo = CompileFunction( 3353 v8::Local<v8::Function> foo = CompileFunction(
3361 &env, 3354 &env,
3362 "function bar(x, y, z) { if (x == 1) { a = y; b = z; } }" 3355 "function bar(x, y, z) { if (x == 1) { a = y; b = z; } }"
3363 "function foo(){ debugger; bar.apply(this, [1,2,3]); }", 3356 "function foo(){ debugger; bar.apply(this, [1,2,3]); }",
3364 "foo"); 3357 "foo");
3365 3358
3366 // Register a debug event listener which steps and counts. 3359 // Register a debug event listener which steps and counts.
3367 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStep); 3360 SetDebugEventListener(env->GetIsolate(), DebugEventStep);
3368 3361
3369 v8::Local<v8::Context> context = env.context(); 3362 v8::Local<v8::Context> context = env.context();
3370 step_action = StepIn; 3363 step_action = StepIn;
3371 break_point_hit_count = 0; 3364 break_point_hit_count = 0;
3372 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3365 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3373 3366
3374 // With stepping all break locations are hit. 3367 // With stepping all break locations are hit.
3375 CHECK_EQ(7, break_point_hit_count); 3368 CHECK_EQ(7, break_point_hit_count);
3376 3369
3377 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 3370 SetDebugEventListener(env->GetIsolate(), nullptr);
3378 CheckDebuggerUnloaded(env->GetIsolate()); 3371 CheckDebuggerUnloaded(env->GetIsolate());
3379 3372
3380 // Register a debug event listener which just counts. 3373 // Register a debug event listener which just counts.
3381 v8::Debug::SetDebugEventListener(env->GetIsolate(), 3374 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount);
3382 DebugEventBreakPointHitCount);
3383 3375
3384 break_point_hit_count = 0; 3376 break_point_hit_count = 0;
3385 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3377 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3386 3378
3387 // Without stepping only the debugger statement is hit. 3379 // Without stepping only the debugger statement is hit.
3388 CHECK_EQ(1, break_point_hit_count); 3380 CHECK_EQ(1, break_point_hit_count);
3389 3381
3390 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 3382 SetDebugEventListener(env->GetIsolate(), nullptr);
3391 CheckDebuggerUnloaded(env->GetIsolate()); 3383 CheckDebuggerUnloaded(env->GetIsolate());
3392 } 3384 }
3393 3385
3394 3386
3395 // Test that step in works with function.call. 3387 // Test that step in works with function.call.
3396 TEST(DebugStepFunctionCall) { 3388 TEST(DebugStepFunctionCall) {
3397 DebugLocalContext env; 3389 DebugLocalContext env;
3398 v8::Isolate* isolate = env->GetIsolate(); 3390 v8::Isolate* isolate = env->GetIsolate();
3399 v8::HandleScope scope(isolate); 3391 v8::HandleScope scope(isolate);
3400 3392
3401 v8::Local<v8::Context> context = env.context(); 3393 v8::Local<v8::Context> context = env.context();
3402 // Create a function for testing stepping. 3394 // Create a function for testing stepping.
3403 v8::Local<v8::Function> foo = CompileFunction( 3395 v8::Local<v8::Function> foo = CompileFunction(
3404 &env, 3396 &env,
3405 "function bar(x, y, z) { if (x == 1) { a = y; b = z; } }" 3397 "function bar(x, y, z) { if (x == 1) { a = y; b = z; } }"
3406 "function foo(a){ debugger;" 3398 "function foo(a){ debugger;"
3407 " if (a) {" 3399 " if (a) {"
3408 " bar.call(this, 1, 2, 3);" 3400 " bar.call(this, 1, 2, 3);"
3409 " } else {" 3401 " } else {"
3410 " bar.call(this, 0);" 3402 " bar.call(this, 0);"
3411 " }" 3403 " }"
3412 "}", 3404 "}",
3413 "foo"); 3405 "foo");
3414 3406
3415 // Register a debug event listener which steps and counts. 3407 // Register a debug event listener which steps and counts.
3416 v8::Debug::SetDebugEventListener(isolate, DebugEventStep); 3408 SetDebugEventListener(isolate, DebugEventStep);
3417 step_action = StepIn; 3409 step_action = StepIn;
3418 3410
3419 // Check stepping where the if condition in bar is false. 3411 // Check stepping where the if condition in bar is false.
3420 break_point_hit_count = 0; 3412 break_point_hit_count = 0;
3421 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3413 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3422 CHECK_EQ(6, break_point_hit_count); 3414 CHECK_EQ(6, break_point_hit_count);
3423 3415
3424 // Check stepping where the if condition in bar is true. 3416 // Check stepping where the if condition in bar is true.
3425 break_point_hit_count = 0; 3417 break_point_hit_count = 0;
3426 const int argc = 1; 3418 const int argc = 1;
3427 v8::Local<v8::Value> argv[argc] = {v8::True(isolate)}; 3419 v8::Local<v8::Value> argv[argc] = {v8::True(isolate)};
3428 foo->Call(context, env->Global(), argc, argv).ToLocalChecked(); 3420 foo->Call(context, env->Global(), argc, argv).ToLocalChecked();
3429 CHECK_EQ(8, break_point_hit_count); 3421 CHECK_EQ(8, break_point_hit_count);
3430 3422
3431 v8::Debug::SetDebugEventListener(isolate, nullptr); 3423 SetDebugEventListener(isolate, nullptr);
3432 CheckDebuggerUnloaded(isolate); 3424 CheckDebuggerUnloaded(isolate);
3433 3425
3434 // Register a debug event listener which just counts. 3426 // Register a debug event listener which just counts.
3435 v8::Debug::SetDebugEventListener(isolate, DebugEventBreakPointHitCount); 3427 SetDebugEventListener(isolate, DebugEventBreakPointHitCount);
3436 3428
3437 break_point_hit_count = 0; 3429 break_point_hit_count = 0;
3438 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3430 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3439 3431
3440 // Without stepping only the debugger statement is hit. 3432 // Without stepping only the debugger statement is hit.
3441 CHECK_EQ(1, break_point_hit_count); 3433 CHECK_EQ(1, break_point_hit_count);
3442 3434
3443 v8::Debug::SetDebugEventListener(isolate, nullptr); 3435 SetDebugEventListener(isolate, nullptr);
3444 CheckDebuggerUnloaded(isolate); 3436 CheckDebuggerUnloaded(isolate);
3445 } 3437 }
3446 3438
3447 3439
3448 // Test that step in works with Function.call.apply. 3440 // Test that step in works with Function.call.apply.
3449 TEST(DebugStepFunctionCallApply) { 3441 TEST(DebugStepFunctionCallApply) {
3450 DebugLocalContext env; 3442 DebugLocalContext env;
3451 v8::Isolate* isolate = env->GetIsolate(); 3443 v8::Isolate* isolate = env->GetIsolate();
3452 v8::HandleScope scope(isolate); 3444 v8::HandleScope scope(isolate);
3453 3445
3454 v8::Local<v8::Context> context = env.context(); 3446 v8::Local<v8::Context> context = env.context();
3455 // Create a function for testing stepping. 3447 // Create a function for testing stepping.
3456 v8::Local<v8::Function> foo = 3448 v8::Local<v8::Function> foo =
3457 CompileFunction(&env, 3449 CompileFunction(&env,
3458 "function bar() { }" 3450 "function bar() { }"
3459 "function foo(){ debugger;" 3451 "function foo(){ debugger;"
3460 " Function.call.apply(bar);" 3452 " Function.call.apply(bar);"
3461 " Function.call.apply(Function.call, " 3453 " Function.call.apply(Function.call, "
3462 "[Function.call, bar]);" 3454 "[Function.call, bar]);"
3463 "}", 3455 "}",
3464 "foo"); 3456 "foo");
3465 3457
3466 // Register a debug event listener which steps and counts. 3458 // Register a debug event listener which steps and counts.
3467 v8::Debug::SetDebugEventListener(isolate, DebugEventStep); 3459 SetDebugEventListener(isolate, DebugEventStep);
3468 step_action = StepIn; 3460 step_action = StepIn;
3469 3461
3470 break_point_hit_count = 0; 3462 break_point_hit_count = 0;
3471 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3463 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3472 CHECK_EQ(6, break_point_hit_count); 3464 CHECK_EQ(6, break_point_hit_count);
3473 3465
3474 v8::Debug::SetDebugEventListener(isolate, nullptr); 3466 SetDebugEventListener(isolate, nullptr);
3475 CheckDebuggerUnloaded(isolate); 3467 CheckDebuggerUnloaded(isolate);
3476 3468
3477 // Register a debug event listener which just counts. 3469 // Register a debug event listener which just counts.
3478 v8::Debug::SetDebugEventListener(isolate, DebugEventBreakPointHitCount); 3470 SetDebugEventListener(isolate, DebugEventBreakPointHitCount);
3479 3471
3480 break_point_hit_count = 0; 3472 break_point_hit_count = 0;
3481 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3473 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3482 3474
3483 // Without stepping only the debugger statement is hit. 3475 // Without stepping only the debugger statement is hit.
3484 CHECK_EQ(1, break_point_hit_count); 3476 CHECK_EQ(1, break_point_hit_count);
3485 3477
3486 v8::Debug::SetDebugEventListener(isolate, nullptr); 3478 SetDebugEventListener(isolate, nullptr);
3487 CheckDebuggerUnloaded(isolate); 3479 CheckDebuggerUnloaded(isolate);
3488 } 3480 }
3489 3481
3490 3482
3491 // Tests that breakpoint will be hit if it's set in script. 3483 // Tests that breakpoint will be hit if it's set in script.
3492 TEST(PauseInScript) { 3484 TEST(PauseInScript) {
3493 DebugLocalContext env; 3485 DebugLocalContext env;
3494 v8::HandleScope scope(env->GetIsolate()); 3486 v8::HandleScope scope(env->GetIsolate());
3495 env.ExposeDebug(); 3487 env.ExposeDebug();
3496 3488
3497 // Register a debug event listener which counts. 3489 // Register a debug event listener which counts.
3498 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter); 3490 SetDebugEventListener(env->GetIsolate(), DebugEventCounter);
3499 3491
3500 v8::Local<v8::Context> context = env.context(); 3492 v8::Local<v8::Context> context = env.context();
3501 // Create a script that returns a function. 3493 // Create a script that returns a function.
3502 const char* src = "(function (evt) {})"; 3494 const char* src = "(function (evt) {})";
3503 const char* script_name = "StepInHandlerTest"; 3495 const char* script_name = "StepInHandlerTest";
3504 3496
3505 v8::ScriptOrigin origin(v8_str(env->GetIsolate(), script_name), 3497 v8::ScriptOrigin origin(v8_str(env->GetIsolate(), script_name),
3506 v8::Integer::New(env->GetIsolate(), 0)); 3498 v8::Integer::New(env->GetIsolate(), 0));
3507 v8::Local<v8::Script> script = 3499 v8::Local<v8::Script> script =
3508 v8::Script::Compile(context, v8_str(env->GetIsolate(), src), &origin) 3500 v8::Script::Compile(context, v8_str(env->GetIsolate(), src), &origin)
3509 .ToLocalChecked(); 3501 .ToLocalChecked();
3510 3502
3511 // Set breakpoint in the script. 3503 // Set breakpoint in the script.
3512 SetScriptBreakPointByNameFromJS(env->GetIsolate(), script_name, 0, -1); 3504 SetScriptBreakPointByNameFromJS(env->GetIsolate(), script_name, 0, -1);
3513 break_point_hit_count = 0; 3505 break_point_hit_count = 0;
3514 3506
3515 v8::Local<v8::Value> r = script->Run(context).ToLocalChecked(); 3507 v8::Local<v8::Value> r = script->Run(context).ToLocalChecked();
3516 3508
3517 CHECK(r->IsFunction()); 3509 CHECK(r->IsFunction());
3518 CHECK_EQ(1, break_point_hit_count); 3510 CHECK_EQ(1, break_point_hit_count);
3519 3511
3520 // Get rid of the debug event listener. 3512 // Get rid of the debug event listener.
3521 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 3513 SetDebugEventListener(env->GetIsolate(), nullptr);
3522 CheckDebuggerUnloaded(env->GetIsolate()); 3514 CheckDebuggerUnloaded(env->GetIsolate());
3523 } 3515 }
3524 3516
3525 3517
3526 static void DebugEventCounterCheck(int caught, int uncaught, int message) { 3518 static void DebugEventCounterCheck(int caught, int uncaught, int message) {
3527 CHECK_EQ(caught, exception_hit_count); 3519 CHECK_EQ(caught, exception_hit_count);
3528 CHECK_EQ(uncaught, uncaught_exception_hit_count); 3520 CHECK_EQ(uncaught, uncaught_exception_hit_count);
3529 CHECK_EQ(message, message_callback_count); 3521 CHECK_EQ(message, message_callback_count);
3530 } 3522 }
3531 3523
(...skipping 22 matching lines...) Expand all
3554 &env, "function notCaughtFinally(){try{throws();}finally{}}", 3546 &env, "function notCaughtFinally(){try{throws();}finally{}}",
3555 "notCaughtFinally"); 3547 "notCaughtFinally");
3556 // In this edge case, even though this finally does not propagate the 3548 // In this edge case, even though this finally does not propagate the
3557 // exception, the debugger considers this uncaught, since we want to break 3549 // exception, the debugger considers this uncaught, since we want to break
3558 // at the first throw for the general case where finally implicitly rethrows. 3550 // at the first throw for the general case where finally implicitly rethrows.
3559 v8::Local<v8::Function> edgeCaseFinally = CompileFunction( 3551 v8::Local<v8::Function> edgeCaseFinally = CompileFunction(
3560 &env, "function caughtFinally(){L:try{throws();}finally{break L;}}", 3552 &env, "function caughtFinally(){L:try{throws();}finally{break L;}}",
3561 "caughtFinally"); 3553 "caughtFinally");
3562 3554
3563 env->GetIsolate()->AddMessageListener(MessageCallbackCount); 3555 env->GetIsolate()->AddMessageListener(MessageCallbackCount);
3564 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter); 3556 SetDebugEventListener(env->GetIsolate(), DebugEventCounter);
3565 3557
3566 // Initial state should be no break on exceptions. 3558 // Initial state should be no break on exceptions.
3567 DebugEventCounterClear(); 3559 DebugEventCounterClear();
3568 MessageCallbackCountClear(); 3560 MessageCallbackCountClear();
3569 caught->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3561 caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3570 DebugEventCounterCheck(0, 0, 0); 3562 DebugEventCounterCheck(0, 0, 0);
3571 CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty()); 3563 CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
3572 DebugEventCounterCheck(0, 0, 1); 3564 DebugEventCounterCheck(0, 0, 1);
3573 CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty()); 3565 CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
3574 DebugEventCounterCheck(0, 0, 2); 3566 DebugEventCounterCheck(0, 0, 2);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
3714 v8::debug::BreakOnAnyException); 3706 v8::debug::BreakOnAnyException);
3715 caught->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3707 caught->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3716 DebugEventCounterCheck(1, 0, 0); 3708 DebugEventCounterCheck(1, 0, 0);
3717 CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty()); 3709 CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty());
3718 DebugEventCounterCheck(2, 1, 1); 3710 DebugEventCounterCheck(2, 1, 1);
3719 CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty()); 3711 CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty());
3720 DebugEventCounterCheck(3, 2, 2); 3712 DebugEventCounterCheck(3, 2, 2);
3721 edgeCaseFinally->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3713 edgeCaseFinally->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3722 DebugEventCounterCheck(4, 3, 2); 3714 DebugEventCounterCheck(4, 3, 2);
3723 3715
3724 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 3716 SetDebugEventListener(env->GetIsolate(), nullptr);
3725 CheckDebuggerUnloaded(env->GetIsolate()); 3717 CheckDebuggerUnloaded(env->GetIsolate());
3726 env->GetIsolate()->RemoveMessageListeners(MessageCallbackCount); 3718 env->GetIsolate()->RemoveMessageListeners(MessageCallbackCount);
3727 } 3719 }
3728 3720
3729 3721
3730 static void try_finally_original_message(v8::Local<v8::Message> message, 3722 static void try_finally_original_message(v8::Local<v8::Message> message,
3731 v8::Local<v8::Value> data) { 3723 v8::Local<v8::Value> data) {
3732 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext(); 3724 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
3733 CHECK_EQ(2, message->GetLineNumber(context).FromJust()); 3725 CHECK_EQ(2, message->GetLineNumber(context).FromJust());
3734 CHECK_EQ(2, message->GetStartColumn(context).FromJust()); 3726 CHECK_EQ(2, message->GetStartColumn(context).FromJust());
3735 message_callback_count++; 3727 message_callback_count++;
3736 } 3728 }
3737 3729
3738 3730
3739 TEST(TryFinallyOriginalMessage) { 3731 TEST(TryFinallyOriginalMessage) {
3740 // Test that the debugger plays nicely with the pending message. 3732 // Test that the debugger plays nicely with the pending message.
3741 message_callback_count = 0; 3733 message_callback_count = 0;
3742 DebugEventCounterClear(); 3734 DebugEventCounterClear();
3743 DebugLocalContext env; 3735 DebugLocalContext env;
3744 v8::Isolate* isolate = CcTest::isolate(); 3736 v8::Isolate* isolate = CcTest::isolate();
3745 isolate->AddMessageListener(try_finally_original_message); 3737 isolate->AddMessageListener(try_finally_original_message);
3746 v8::Debug::SetDebugEventListener(isolate, DebugEventCounter); 3738 SetDebugEventListener(isolate, DebugEventCounter);
3747 ChangeBreakOnException(true, true); 3739 ChangeBreakOnException(true, true);
3748 v8::HandleScope scope(isolate); 3740 v8::HandleScope scope(isolate);
3749 CompileRun( 3741 CompileRun(
3750 "try {\n" 3742 "try {\n"
3751 " throw 1;\n" 3743 " throw 1;\n"
3752 "} finally {\n" 3744 "} finally {\n"
3753 "}\n"); 3745 "}\n");
3754 DebugEventCounterCheck(1, 1, 1); 3746 DebugEventCounterCheck(1, 1, 1);
3755 v8::Debug::SetDebugEventListener(isolate, nullptr); 3747 SetDebugEventListener(isolate, nullptr);
3756 isolate->RemoveMessageListeners(try_finally_original_message); 3748 isolate->RemoveMessageListeners(try_finally_original_message);
3757 } 3749 }
3758 3750
3759 3751
3760 // Test break on exception from compiler errors. When compiling using 3752 // Test break on exception from compiler errors. When compiling using
3761 // v8::Script::Compile there is no JavaScript stack whereas when compiling using 3753 // v8::Script::Compile there is no JavaScript stack whereas when compiling using
3762 // eval there are JavaScript frames. 3754 // eval there are JavaScript frames.
3763 TEST(BreakOnCompileException) { 3755 TEST(BreakOnCompileException) {
3764 DebugLocalContext env; 3756 DebugLocalContext env;
3765 v8::HandleScope scope(env->GetIsolate()); 3757 v8::HandleScope scope(env->GetIsolate());
3766 3758
3767 v8::Local<v8::Context> context = env.context(); 3759 v8::Local<v8::Context> context = env.context();
3768 // For this test, we want to break on uncaught exceptions: 3760 // For this test, we want to break on uncaught exceptions:
3769 ChangeBreakOnException(false, true); 3761 ChangeBreakOnException(false, true);
3770 3762
3771 // Create a function for checking the function when hitting a break point. 3763 // Create a function for checking the function when hitting a break point.
3772 frame_count = CompileFunction(&env, frame_count_source, "frame_count"); 3764 frame_count = CompileFunction(&env, frame_count_source, "frame_count");
3773 3765
3774 env->GetIsolate()->AddMessageListener(MessageCallbackCount); 3766 env->GetIsolate()->AddMessageListener(MessageCallbackCount);
3775 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter); 3767 SetDebugEventListener(env->GetIsolate(), DebugEventCounter);
3776 3768
3777 DebugEventCounterClear(); 3769 DebugEventCounterClear();
3778 MessageCallbackCountClear(); 3770 MessageCallbackCountClear();
3779 3771
3780 // Check initial state. 3772 // Check initial state.
3781 CHECK_EQ(0, exception_hit_count); 3773 CHECK_EQ(0, exception_hit_count);
3782 CHECK_EQ(0, uncaught_exception_hit_count); 3774 CHECK_EQ(0, uncaught_exception_hit_count);
3783 CHECK_EQ(0, message_callback_count); 3775 CHECK_EQ(0, message_callback_count);
3784 CHECK_EQ(-1, last_js_stack_height); 3776 CHECK_EQ(-1, last_js_stack_height);
3785 3777
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3829 3821
3830 // For this test, we want to break on uncaught exceptions: 3822 // For this test, we want to break on uncaught exceptions:
3831 ChangeBreakOnException(false, true); 3823 ChangeBreakOnException(false, true);
3832 3824
3833 // Create a function for checking the function when hitting a break point. 3825 // Create a function for checking the function when hitting a break point.
3834 frame_function_name = CompileFunction(&env, 3826 frame_function_name = CompileFunction(&env,
3835 frame_function_name_source, 3827 frame_function_name_source,
3836 "frame_function_name"); 3828 "frame_function_name");
3837 3829
3838 // Register a debug event listener which steps and counts. 3830 // Register a debug event listener which steps and counts.
3839 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStepSequence); 3831 SetDebugEventListener(env->GetIsolate(), DebugEventStepSequence);
3840 3832
3841 v8::Local<v8::Context> context = env.context(); 3833 v8::Local<v8::Context> context = env.context();
3842 // Create functions for testing stepping. 3834 // Create functions for testing stepping.
3843 const char* src = "function a() { n(); }; " 3835 const char* src = "function a() { n(); }; "
3844 "function b() { c(); }; " 3836 "function b() { c(); }; "
3845 "function c() { n(); }; " 3837 "function c() { n(); }; "
3846 "function d() { x = 1; try { e(); } catch(x) { x = 2; } }; " 3838 "function d() { x = 1; try { e(); } catch(x) { x = 2; } }; "
3847 "function e() { n(); }; " 3839 "function e() { n(); }; "
3848 "function f() { x = 1; try { g(); } catch(x) { x = 2; } }; " 3840 "function f() { x = 1; try { g(); } catch(x) { x = 2; } }; "
3849 "function g() { h(); }; " 3841 "function g() { h(); }; "
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3907 // Step through invocation of f + g + h now with break on caught exceptions. 3899 // Step through invocation of f + g + h now with break on caught exceptions.
3908 ChangeBreakOnException(true, true); 3900 ChangeBreakOnException(true, true);
3909 step_action = StepIn; 3901 step_action = StepIn;
3910 break_point_hit_count = 0; 3902 break_point_hit_count = 0;
3911 expected_step_sequence = "ffghhhff"; 3903 expected_step_sequence = "ffghhhff";
3912 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3904 f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3913 CHECK_EQ(StrLength(expected_step_sequence), 3905 CHECK_EQ(StrLength(expected_step_sequence),
3914 break_point_hit_count); 3906 break_point_hit_count);
3915 3907
3916 // Get rid of the debug event listener. 3908 // Get rid of the debug event listener.
3917 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 3909 SetDebugEventListener(env->GetIsolate(), nullptr);
3918 CheckDebuggerUnloaded(env->GetIsolate()); 3910 CheckDebuggerUnloaded(env->GetIsolate());
3919 } 3911 }
3920 3912
3921 3913
3922 TEST(DebugBreak) { 3914 TEST(DebugBreak) {
3923 i::FLAG_stress_compaction = false; 3915 i::FLAG_stress_compaction = false;
3924 #ifdef VERIFY_HEAP 3916 #ifdef VERIFY_HEAP
3925 i::FLAG_verify_heap = true; 3917 i::FLAG_verify_heap = true;
3926 #endif 3918 #endif
3927 DebugLocalContext env; 3919 DebugLocalContext env;
3928 v8::Isolate* isolate = env->GetIsolate(); 3920 v8::Isolate* isolate = env->GetIsolate();
3929 v8::HandleScope scope(isolate); 3921 v8::HandleScope scope(isolate);
3930 3922
3931 // Register a debug event listener which sets the break flag and counts. 3923 // Register a debug event listener which sets the break flag and counts.
3932 v8::Debug::SetDebugEventListener(isolate, DebugEventBreak); 3924 SetDebugEventListener(isolate, DebugEventBreak);
3933 3925
3934 v8::Local<v8::Context> context = env.context(); 3926 v8::Local<v8::Context> context = env.context();
3935 // Create a function for testing stepping. 3927 // Create a function for testing stepping.
3936 const char* src = "function f0() {}" 3928 const char* src = "function f0() {}"
3937 "function f1(x1) {}" 3929 "function f1(x1) {}"
3938 "function f2(x1,x2) {}" 3930 "function f2(x1,x2) {}"
3939 "function f3(x1,x2,x3) {}"; 3931 "function f3(x1,x2,x3) {}";
3940 v8::Local<v8::Function> f0 = CompileFunction(&env, src, "f0"); 3932 v8::Local<v8::Function> f0 = CompileFunction(&env, src, "f0");
3941 v8::Local<v8::Function> f1 = CompileFunction(&env, src, "f1"); 3933 v8::Local<v8::Function> f1 = CompileFunction(&env, src, "f1");
3942 v8::Local<v8::Function> f2 = CompileFunction(&env, src, "f2"); 3934 v8::Local<v8::Function> f2 = CompileFunction(&env, src, "f2");
3943 v8::Local<v8::Function> f3 = CompileFunction(&env, src, "f3"); 3935 v8::Local<v8::Function> f3 = CompileFunction(&env, src, "f3");
3944 3936
3945 // Call the function to make sure it is compiled. 3937 // Call the function to make sure it is compiled.
3946 v8::Local<v8::Value> argv[] = { 3938 v8::Local<v8::Value> argv[] = {
3947 v8::Number::New(isolate, 1), v8::Number::New(isolate, 1), 3939 v8::Number::New(isolate, 1), v8::Number::New(isolate, 1),
3948 v8::Number::New(isolate, 1), v8::Number::New(isolate, 1)}; 3940 v8::Number::New(isolate, 1), v8::Number::New(isolate, 1)};
3949 3941
3950 // Call all functions to make sure that they are compiled. 3942 // Call all functions to make sure that they are compiled.
3951 f0->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3943 f0->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3952 f1->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3944 f1->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3953 f2->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3945 f2->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3954 f3->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3946 f3->Call(context, env->Global(), 0, NULL).ToLocalChecked();
3955 3947
3956 // Set the debug break flag. 3948 // Set the debug break flag.
3957 v8::Debug::DebugBreak(env->GetIsolate()); 3949 v8::debug::DebugBreak(env->GetIsolate());
3958 3950
3959 // Call all functions with different argument count. 3951 // Call all functions with different argument count.
3960 break_point_hit_count = 0; 3952 break_point_hit_count = 0;
3961 for (unsigned int i = 0; i < arraysize(argv); i++) { 3953 for (unsigned int i = 0; i < arraysize(argv); i++) {
3962 f0->Call(context, env->Global(), i, argv).ToLocalChecked(); 3954 f0->Call(context, env->Global(), i, argv).ToLocalChecked();
3963 f1->Call(context, env->Global(), i, argv).ToLocalChecked(); 3955 f1->Call(context, env->Global(), i, argv).ToLocalChecked();
3964 f2->Call(context, env->Global(), i, argv).ToLocalChecked(); 3956 f2->Call(context, env->Global(), i, argv).ToLocalChecked();
3965 f3->Call(context, env->Global(), i, argv).ToLocalChecked(); 3957 f3->Call(context, env->Global(), i, argv).ToLocalChecked();
3966 } 3958 }
3967 3959
3968 // One break for each function called. 3960 // One break for each function called.
3969 CHECK(4 * arraysize(argv) == break_point_hit_count); 3961 CHECK(4 * arraysize(argv) == break_point_hit_count);
3970 3962
3971 // Get rid of the debug event listener. 3963 // Get rid of the debug event listener.
3972 v8::Debug::SetDebugEventListener(isolate, nullptr); 3964 SetDebugEventListener(isolate, nullptr);
3973 CheckDebuggerUnloaded(isolate); 3965 CheckDebuggerUnloaded(isolate);
3974 } 3966 }
3975 3967
3976 3968
3977 // Test to ensure that JavaScript code keeps running while the debug break 3969 // Test to ensure that JavaScript code keeps running while the debug break
3978 // through the stack limit flag is set but breaks are disabled. 3970 // through the stack limit flag is set but breaks are disabled.
3979 TEST(DisableBreak) { 3971 TEST(DisableBreak) {
3980 DebugLocalContext env; 3972 DebugLocalContext env;
3981 v8::HandleScope scope(env->GetIsolate()); 3973 v8::HandleScope scope(env->GetIsolate());
3982 3974
3983 // Register a debug event listener which sets the break flag and counts. 3975 // Register a debug event listener which sets the break flag and counts.
3984 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter); 3976 SetDebugEventListener(env->GetIsolate(), DebugEventCounter);
3985 3977
3986 v8::Local<v8::Context> context = env.context(); 3978 v8::Local<v8::Context> context = env.context();
3987 // Create a function for testing stepping. 3979 // Create a function for testing stepping.
3988 const char* src = "function f() {g()};function g(){i=0; while(i<10){i++}}"; 3980 const char* src = "function f() {g()};function g(){i=0; while(i<10){i++}}";
3989 v8::Local<v8::Function> f = CompileFunction(&env, src, "f"); 3981 v8::Local<v8::Function> f = CompileFunction(&env, src, "f");
3990 3982
3991 // Set, test and cancel debug break. 3983 // Set, test and cancel debug break.
3992 v8::Debug::DebugBreak(env->GetIsolate()); 3984 v8::debug::DebugBreak(env->GetIsolate());
3993 v8::Debug::CancelDebugBreak(env->GetIsolate()); 3985 v8::debug::CancelDebugBreak(env->GetIsolate());
3994 3986
3995 // Set the debug break flag. 3987 // Set the debug break flag.
3996 v8::Debug::DebugBreak(env->GetIsolate()); 3988 v8::debug::DebugBreak(env->GetIsolate());
3997 3989
3998 // Call all functions with different argument count. 3990 // Call all functions with different argument count.
3999 break_point_hit_count = 0; 3991 break_point_hit_count = 0;
4000 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3992 f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
4001 CHECK_EQ(1, break_point_hit_count); 3993 CHECK_EQ(1, break_point_hit_count);
4002 3994
4003 { 3995 {
4004 v8::Debug::DebugBreak(env->GetIsolate()); 3996 v8::debug::DebugBreak(env->GetIsolate());
4005 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(env->GetIsolate()); 3997 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(env->GetIsolate());
4006 v8::internal::DisableBreak disable_break(isolate->debug()); 3998 v8::internal::DisableBreak disable_break(isolate->debug());
4007 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 3999 f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
4008 CHECK_EQ(1, break_point_hit_count); 4000 CHECK_EQ(1, break_point_hit_count);
4009 } 4001 }
4010 4002
4011 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 4003 f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
4012 CHECK_EQ(2, break_point_hit_count); 4004 CHECK_EQ(2, break_point_hit_count);
4013 4005
4014 // Get rid of the debug event listener. 4006 // Get rid of the debug event listener.
4015 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 4007 SetDebugEventListener(env->GetIsolate(), nullptr);
4016 CheckDebuggerUnloaded(env->GetIsolate()); 4008 CheckDebuggerUnloaded(env->GetIsolate());
4017 } 4009 }
4018 4010
4019 TEST(DisableDebuggerStatement) { 4011 TEST(DisableDebuggerStatement) {
4020 DebugLocalContext env; 4012 DebugLocalContext env;
4021 v8::HandleScope scope(env->GetIsolate()); 4013 v8::HandleScope scope(env->GetIsolate());
4022 4014
4023 // Register a debug event listener which sets the break flag and counts. 4015 // Register a debug event listener which sets the break flag and counts.
4024 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter); 4016 SetDebugEventListener(env->GetIsolate(), DebugEventCounter);
4025 CompileRun("debugger;"); 4017 CompileRun("debugger;");
4026 CHECK_EQ(1, break_point_hit_count); 4018 CHECK_EQ(1, break_point_hit_count);
4027 4019
4028 // Check that we ignore debugger statement when breakpoints aren't active. 4020 // Check that we ignore debugger statement when breakpoints aren't active.
4029 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(env->GetIsolate()); 4021 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(env->GetIsolate());
4030 isolate->debug()->set_break_points_active(false); 4022 isolate->debug()->set_break_points_active(false);
4031 CompileRun("debugger;"); 4023 CompileRun("debugger;");
4032 CHECK_EQ(1, break_point_hit_count); 4024 CHECK_EQ(1, break_point_hit_count);
4033 } 4025 }
4034 4026
4035 static const char* kSimpleExtensionSource = 4027 static const char* kSimpleExtensionSource =
4036 "(function Foo() {" 4028 "(function Foo() {"
4037 " return 4;" 4029 " return 4;"
4038 "})() "; 4030 "})() ";
4039 4031
4040 // http://crbug.com/28933 4032 // http://crbug.com/28933
4041 // Test that debug break is disabled when bootstrapper is active. 4033 // Test that debug break is disabled when bootstrapper is active.
4042 TEST(NoBreakWhenBootstrapping) { 4034 TEST(NoBreakWhenBootstrapping) {
4043 v8::Isolate* isolate = CcTest::isolate(); 4035 v8::Isolate* isolate = CcTest::isolate();
4044 v8::HandleScope scope(isolate); 4036 v8::HandleScope scope(isolate);
4045 4037
4046 // Register a debug event listener which sets the break flag and counts. 4038 // Register a debug event listener which sets the break flag and counts.
4047 v8::Debug::SetDebugEventListener(isolate, DebugEventCounter); 4039 SetDebugEventListener(isolate, DebugEventCounter);
4048 4040
4049 // Set the debug break flag. 4041 // Set the debug break flag.
4050 v8::Debug::DebugBreak(isolate); 4042 v8::debug::DebugBreak(isolate);
4051 break_point_hit_count = 0; 4043 break_point_hit_count = 0;
4052 { 4044 {
4053 // Create a context with an extension to make sure that some JavaScript 4045 // Create a context with an extension to make sure that some JavaScript
4054 // code is executed during bootstrapping. 4046 // code is executed during bootstrapping.
4055 v8::RegisterExtension(new v8::Extension("simpletest", 4047 v8::RegisterExtension(new v8::Extension("simpletest",
4056 kSimpleExtensionSource)); 4048 kSimpleExtensionSource));
4057 const char* extension_names[] = { "simpletest" }; 4049 const char* extension_names[] = { "simpletest" };
4058 v8::ExtensionConfiguration extensions(1, extension_names); 4050 v8::ExtensionConfiguration extensions(1, extension_names);
4059 v8::HandleScope handle_scope(isolate); 4051 v8::HandleScope handle_scope(isolate);
4060 v8::Context::New(isolate, &extensions); 4052 v8::Context::New(isolate, &extensions);
4061 } 4053 }
4062 // Check that no DebugBreak events occured during the context creation. 4054 // Check that no DebugBreak events occured during the context creation.
4063 CHECK_EQ(0, break_point_hit_count); 4055 CHECK_EQ(0, break_point_hit_count);
4064 4056
4065 // Get rid of the debug event listener. 4057 // Get rid of the debug event listener.
4066 v8::Debug::SetDebugEventListener(isolate, nullptr); 4058 SetDebugEventListener(isolate, nullptr);
4067 CheckDebuggerUnloaded(isolate); 4059 CheckDebuggerUnloaded(isolate);
4068 } 4060 }
4069 4061
4070 4062
4071 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { 4063 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
4072 v8::Local<v8::Array> result = v8::Array::New(info.GetIsolate(), 3); 4064 v8::Local<v8::Array> result = v8::Array::New(info.GetIsolate(), 3);
4073 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); 4065 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
4074 CHECK(result->Set(context, v8::Integer::New(info.GetIsolate(), 0), 4066 CHECK(result->Set(context, v8::Integer::New(info.GetIsolate(), 0),
4075 v8_str(info.GetIsolate(), "a")) 4067 v8_str(info.GetIsolate(), "a"))
4076 .FromJust()); 4068 .FromJust());
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
4586 CHECK(CompileRun("obj_mirror.property('a').value().value() == 1") 4578 CHECK(CompileRun("obj_mirror.property('a').value().value() == 1")
4587 ->BooleanValue(context) 4579 ->BooleanValue(context)
4588 .FromJust()); 4580 .FromJust());
4589 CHECK(CompileRun("obj_mirror.property('b').value().value() == 2") 4581 CHECK(CompileRun("obj_mirror.property('b').value().value() == 2")
4590 ->BooleanValue(context) 4582 ->BooleanValue(context)
4591 .FromJust()); 4583 .FromJust());
4592 } 4584 }
4593 4585
4594 4586
4595 TEST(SetDebugEventListenerOnUninitializedVM) { 4587 TEST(SetDebugEventListenerOnUninitializedVM) {
4596 v8::Debug::SetDebugEventListener(CcTest::isolate(), DummyDebugEventListener); 4588 EnableDebugger(CcTest::isolate());
4597 } 4589 }
4598 4590
4599 // Source for a JavaScript function which returns the data parameter of a 4591 // 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 4592 // function called in the context of the debugger. If no data parameter is
4601 // passed it throws an exception. 4593 // passed it throws an exception.
4602 static const char* debugger_call_with_data_source = 4594 static const char* debugger_call_with_data_source =
4603 "function debugger_call_with_data(exec_state, data) {" 4595 "function debugger_call_with_data(exec_state, data) {"
4604 " if (data) return data;" 4596 " if (data) return data;"
4605 " throw 'No data!'" 4597 " throw 'No data!'"
4606 "}"; 4598 "}";
4607 v8::Local<v8::Function> debugger_call_with_data; 4599 v8::Local<v8::Function> debugger_call_with_data;
4608 4600
4609 4601
4610 // Source for a JavaScript function which returns the data parameter of a 4602 // 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 4603 // function called in the context of the debugger. If no data parameter is
4612 // passed it throws an exception. 4604 // passed it throws an exception.
4613 static const char* debugger_call_with_closure_source = 4605 static const char* debugger_call_with_closure_source =
4614 "var x = 3;" 4606 "var x = 3;"
4615 "(function (exec_state) {" 4607 "(function (exec_state) {"
4616 " if (exec_state.y) return x - 1;" 4608 " if (exec_state.y) return x - 1;"
4617 " exec_state.y = x;" 4609 " exec_state.y = x;"
4618 " return exec_state.y" 4610 " return exec_state.y"
4619 "})"; 4611 "})";
4620 v8::Local<v8::Function> debugger_call_with_closure; 4612 v8::Local<v8::Function> debugger_call_with_closure;
4621 4613
4622 // Function to retrieve the number of JavaScript frames by calling a JavaScript 4614 // Function to retrieve the number of JavaScript frames by calling a JavaScript
4623 // in the debugger. 4615 // in the debugger.
4624 static void CheckFrameCount(const v8::FunctionCallbackInfo<v8::Value>& args) { 4616 static void CheckFrameCount(const v8::FunctionCallbackInfo<v8::Value>& args) {
4625 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); 4617 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
4626 CHECK(v8::Debug::Call(context, frame_count).ToLocalChecked()->IsNumber()); 4618 CHECK(v8::debug::Call(context, frame_count).ToLocalChecked()->IsNumber());
4627 CHECK_EQ(args[0]->Int32Value(context).FromJust(), 4619 CHECK_EQ(args[0]->Int32Value(context).FromJust(),
4628 v8::Debug::Call(context, frame_count) 4620 v8::debug::Call(context, frame_count)
4629 .ToLocalChecked() 4621 .ToLocalChecked()
4630 ->Int32Value(context) 4622 ->Int32Value(context)
4631 .FromJust()); 4623 .FromJust());
4632 } 4624 }
4633 4625
4634 4626
4635 // Function to retrieve the source line of the top JavaScript frame by calling a 4627 // Function to retrieve the source line of the top JavaScript frame by calling a
4636 // JavaScript function in the debugger. 4628 // JavaScript function in the debugger.
4637 static void CheckSourceLine(const v8::FunctionCallbackInfo<v8::Value>& args) { 4629 static void CheckSourceLine(const v8::FunctionCallbackInfo<v8::Value>& args) {
4638 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); 4630 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
4639 CHECK( 4631 CHECK(
4640 v8::Debug::Call(context, frame_source_line).ToLocalChecked()->IsNumber()); 4632 v8::debug::Call(context, frame_source_line).ToLocalChecked()->IsNumber());
4641 CHECK_EQ(args[0]->Int32Value(context).FromJust(), 4633 CHECK_EQ(args[0]->Int32Value(context).FromJust(),
4642 v8::Debug::Call(context, frame_source_line) 4634 v8::debug::Call(context, frame_source_line)
4643 .ToLocalChecked() 4635 .ToLocalChecked()
4644 ->Int32Value(context) 4636 ->Int32Value(context)
4645 .FromJust()); 4637 .FromJust());
4646 } 4638 }
4647 4639
4648 4640
4649 // Function to test passing an additional parameter to a JavaScript function 4641 // 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 4642 // called in the debugger. It also tests that functions called in the debugger
4651 // can throw exceptions. 4643 // can throw exceptions.
4652 static void CheckDataParameter( 4644 static void CheckDataParameter(
4653 const v8::FunctionCallbackInfo<v8::Value>& args) { 4645 const v8::FunctionCallbackInfo<v8::Value>& args) {
4654 v8::Local<v8::String> data = v8_str(args.GetIsolate(), "Test"); 4646 v8::Local<v8::String> data = v8_str(args.GetIsolate(), "Test");
4655 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); 4647 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
4656 CHECK(v8::Debug::Call(context, debugger_call_with_data, data) 4648 CHECK(v8::debug::Call(context, debugger_call_with_data, data)
4657 .ToLocalChecked() 4649 .ToLocalChecked()
4658 ->IsString()); 4650 ->IsString());
4659 4651
4660 for (int i = 0; i < 3; i++) { 4652 for (int i = 0; i < 3; i++) {
4661 v8::TryCatch catcher(args.GetIsolate()); 4653 v8::TryCatch catcher(args.GetIsolate());
4662 CHECK(v8::Debug::Call(context, debugger_call_with_data).IsEmpty()); 4654 CHECK(v8::debug::Call(context, debugger_call_with_data).IsEmpty());
4663 CHECK(catcher.HasCaught()); 4655 CHECK(catcher.HasCaught());
4664 CHECK(catcher.Exception()->IsString()); 4656 CHECK(catcher.Exception()->IsString());
4665 } 4657 }
4666 } 4658 }
4667 4659
4668 4660
4669 // Function to test using a JavaScript with closure in the debugger. 4661 // Function to test using a JavaScript with closure in the debugger.
4670 static void CheckClosure(const v8::FunctionCallbackInfo<v8::Value>& args) { 4662 static void CheckClosure(const v8::FunctionCallbackInfo<v8::Value>& args) {
4671 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); 4663 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
4672 CHECK(v8::Debug::Call(context, debugger_call_with_closure) 4664 CHECK(v8::debug::Call(context, debugger_call_with_closure)
4673 .ToLocalChecked() 4665 .ToLocalChecked()
4674 ->IsNumber()); 4666 ->IsNumber());
4675 CHECK_EQ(3, v8::Debug::Call(context, debugger_call_with_closure) 4667 CHECK_EQ(3, v8::debug::Call(context, debugger_call_with_closure)
4676 .ToLocalChecked() 4668 .ToLocalChecked()
4677 ->Int32Value(context) 4669 ->Int32Value(context)
4678 .FromJust()); 4670 .FromJust());
4679 } 4671 }
4680 4672
4681 4673
4682 // Test functions called through the debugger. 4674 // Test functions called through the debugger.
4683 TEST(CallFunctionInDebugger) { 4675 TEST(CallFunctionInDebugger) {
4684 // Create and enter a context with the functions CheckFrameCount, 4676 // Create and enter a context with the functions CheckFrameCount,
4685 // CheckSourceLine and CheckDataParameter installed. 4677 // CheckSourceLine and CheckDataParameter installed.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4734 v8::Script::Compile(context, 4726 v8::Script::Compile(context,
4735 v8_str(isolate, debugger_call_with_closure_source)) 4727 v8_str(isolate, debugger_call_with_closure_source))
4736 .ToLocalChecked() 4728 .ToLocalChecked()
4737 ->Run(context) 4729 ->Run(context)
4738 .ToLocalChecked()); 4730 .ToLocalChecked());
4739 4731
4740 // Calling a function through the debugger returns 0 frames if there are 4732 // Calling a function through the debugger returns 0 frames if there are
4741 // no JavaScript frames. 4733 // no JavaScript frames.
4742 CHECK(v8::Integer::New(isolate, 0) 4734 CHECK(v8::Integer::New(isolate, 0)
4743 ->Equals(context, 4735 ->Equals(context,
4744 v8::Debug::Call(context, frame_count).ToLocalChecked()) 4736 v8::debug::Call(context, frame_count).ToLocalChecked())
4745 .FromJust()); 4737 .FromJust());
4746 4738
4747 // Test that the number of frames can be retrieved. 4739 // Test that the number of frames can be retrieved.
4748 v8::Script::Compile(context, v8_str(isolate, "CheckFrameCount(1)")) 4740 v8::Script::Compile(context, v8_str(isolate, "CheckFrameCount(1)"))
4749 .ToLocalChecked() 4741 .ToLocalChecked()
4750 ->Run(context) 4742 ->Run(context)
4751 .ToLocalChecked(); 4743 .ToLocalChecked();
4752 v8::Script::Compile(context, v8_str(isolate, 4744 v8::Script::Compile(context, v8_str(isolate,
4753 "function f() {" 4745 "function f() {"
4754 " CheckFrameCount(2);" 4746 " CheckFrameCount(2);"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4807 // Test that clearing the debug event listener actually clears all break points 4799 // Test that clearing the debug event listener actually clears all break points
4808 // and related information. 4800 // and related information.
4809 TEST(DebuggerUnload) { 4801 TEST(DebuggerUnload) {
4810 DebugLocalContext env; 4802 DebugLocalContext env;
4811 4803
4812 // Check debugger is unloaded before it is used. 4804 // Check debugger is unloaded before it is used.
4813 CheckDebuggerUnloaded(env->GetIsolate()); 4805 CheckDebuggerUnloaded(env->GetIsolate());
4814 4806
4815 // Set a debug event listener. 4807 // Set a debug event listener.
4816 break_point_hit_count = 0; 4808 break_point_hit_count = 0;
4817 v8::Debug::SetDebugEventListener(env->GetIsolate(), 4809 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount);
4818 DebugEventBreakPointHitCount);
4819 v8::Local<v8::Context> context = env.context(); 4810 v8::Local<v8::Context> context = env.context();
4820 { 4811 {
4821 v8::HandleScope scope(env->GetIsolate()); 4812 v8::HandleScope scope(env->GetIsolate());
4822 // Create a couple of functions for the test. 4813 // Create a couple of functions for the test.
4823 v8::Local<v8::Function> foo = 4814 v8::Local<v8::Function> foo =
4824 CompileFunction(&env, "function foo(){x=1}", "foo"); 4815 CompileFunction(&env, "function foo(){x=1}", "foo");
4825 v8::Local<v8::Function> bar = 4816 v8::Local<v8::Function> bar =
4826 CompileFunction(&env, "function bar(){y=2}", "bar"); 4817 CompileFunction(&env, "function bar(){y=2}", "bar");
4827 4818
4828 // Set some break points. 4819 // Set some break points.
4829 SetBreakPoint(foo, 0); 4820 SetBreakPoint(foo, 0);
4830 SetBreakPoint(foo, 4); 4821 SetBreakPoint(foo, 4);
4831 SetBreakPoint(bar, 0); 4822 SetBreakPoint(bar, 0);
4832 SetBreakPoint(bar, 4); 4823 SetBreakPoint(bar, 4);
4833 4824
4834 // Make sure that the break points are there. 4825 // Make sure that the break points are there.
4835 break_point_hit_count = 0; 4826 break_point_hit_count = 0;
4836 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 4827 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
4837 CHECK_EQ(2, break_point_hit_count); 4828 CHECK_EQ(2, break_point_hit_count);
4838 bar->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 4829 bar->Call(context, env->Global(), 0, NULL).ToLocalChecked();
4839 CHECK_EQ(4, break_point_hit_count); 4830 CHECK_EQ(4, break_point_hit_count);
4840 } 4831 }
4841 4832
4842 // Remove the debug event listener without clearing breakpoints. Do this 4833 // Remove the debug event listener without clearing breakpoints. Do this
4843 // outside a handle scope. 4834 // outside a handle scope.
4844 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 4835 SetDebugEventListener(env->GetIsolate(), nullptr);
4845 CheckDebuggerUnloaded(env->GetIsolate(), true); 4836 CheckDebuggerUnloaded(env->GetIsolate(), true);
4846 } 4837 }
4847 4838
4848 int event_listener_hit_count = 0; 4839 int event_listener_hit_count = 0;
4849 4840
4850 // Debugger event listener which clears itself while active. 4841 // Debugger event listener which clears itself while active.
4851 static void EventListenerClearingItself( 4842 static void EventListenerClearingItself(
4852 const v8::Debug::EventDetails& details) { 4843 const v8::Debug::EventDetails& details) {
4853 event_listener_hit_count++; 4844 event_listener_hit_count++;
4854 4845
4855 // Clear debug event listener. 4846 // Clear debug event listener.
4856 v8::Debug::SetDebugEventListener(details.GetIsolate(), nullptr); 4847 SetDebugEventListener(details.GetIsolate(), nullptr);
4857 } 4848 }
4858 4849
4859 4850
4860 // Test clearing the debug message handler while processing a debug event. 4851 // Test clearing the debug message handler while processing a debug event.
4861 TEST(DebuggerClearEventListenerWhileActive) { 4852 TEST(DebuggerClearEventListenerWhileActive) {
4862 DebugLocalContext env; 4853 DebugLocalContext env;
4863 v8::HandleScope scope(env->GetIsolate()); 4854 v8::HandleScope scope(env->GetIsolate());
4864 4855
4865 // Check debugger is unloaded before it is used. 4856 // Check debugger is unloaded before it is used.
4866 CheckDebuggerUnloaded(env->GetIsolate()); 4857 CheckDebuggerUnloaded(env->GetIsolate());
4867 4858
4868 // Set a debug event listener. 4859 // Set a debug event listener.
4869 v8::Debug::SetDebugEventListener(env->GetIsolate(), 4860 SetDebugEventListener(env->GetIsolate(), EventListenerClearingItself);
4870 EventListenerClearingItself);
4871 4861
4872 // Run code to throw an uncaught exception. This should trigger the listener. 4862 // Run code to throw an uncaught exception. This should trigger the listener.
4873 CompileRun("throw 1"); 4863 CompileRun("throw 1");
4874 4864
4875 // The event listener should have been called. 4865 // The event listener should have been called.
4876 CHECK_EQ(1, event_listener_hit_count); 4866 CHECK_EQ(1, event_listener_hit_count);
4877 4867
4878 CheckDebuggerUnloaded(env->GetIsolate(), true); 4868 CheckDebuggerUnloaded(env->GetIsolate(), true);
4879 } 4869 }
4880 4870
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
4941 DebugLocalContext env; 4931 DebugLocalContext env;
4942 v8::HandleScope scope(env->GetIsolate()); 4932 v8::HandleScope scope(env->GetIsolate());
4943 env.ExposeDebug(); 4933 env.ExposeDebug();
4944 4934
4945 // Create functions for retrieving script name and data for the function on 4935 // Create functions for retrieving script name and data for the function on
4946 // the top frame when hitting a break point. 4936 // the top frame when hitting a break point.
4947 frame_script_name = CompileFunction(&env, 4937 frame_script_name = CompileFunction(&env,
4948 frame_script_name_source, 4938 frame_script_name_source,
4949 "frame_script_name"); 4939 "frame_script_name");
4950 4940
4951 v8::Debug::SetDebugEventListener(env->GetIsolate(), 4941 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount);
4952 DebugEventBreakPointHitCount);
4953 4942
4954 v8::Local<v8::Context> context = env.context(); 4943 v8::Local<v8::Context> context = env.context();
4955 // Test function source. 4944 // Test function source.
4956 v8::Local<v8::String> script = v8_str(env->GetIsolate(), 4945 v8::Local<v8::String> script = v8_str(env->GetIsolate(),
4957 "function f() {\n" 4946 "function f() {\n"
4958 " debugger;\n" 4947 " debugger;\n"
4959 "}\n"); 4948 "}\n");
4960 4949
4961 v8::ScriptOrigin origin1 = 4950 v8::ScriptOrigin origin1 =
4962 v8::ScriptOrigin(v8_str(env->GetIsolate(), "name")); 4951 v8::ScriptOrigin(v8_str(env->GetIsolate(), "name"));
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
5045 5034
5046 // Create two contexts. 5035 // Create two contexts.
5047 v8::Local<v8::Context> context_1; 5036 v8::Local<v8::Context> context_1;
5048 v8::Local<v8::Context> context_2; 5037 v8::Local<v8::Context> context_2;
5049 v8::Local<v8::ObjectTemplate> global_template = 5038 v8::Local<v8::ObjectTemplate> global_template =
5050 v8::Local<v8::ObjectTemplate>(); 5039 v8::Local<v8::ObjectTemplate>();
5051 v8::Local<v8::Value> global_object = v8::Local<v8::Value>(); 5040 v8::Local<v8::Value> global_object = v8::Local<v8::Value>();
5052 context_1 = v8::Context::New(isolate, NULL, global_template, global_object); 5041 context_1 = v8::Context::New(isolate, NULL, global_template, global_object);
5053 context_2 = v8::Context::New(isolate, NULL, global_template, global_object); 5042 context_2 = v8::Context::New(isolate, NULL, global_template, global_object);
5054 5043
5055 v8::Debug::SetDebugEventListener(isolate, ContextCheckEventListener); 5044 SetDebugEventListener(isolate, ContextCheckEventListener);
5056 5045
5057 // Default data value is undefined. 5046 // Default data value is undefined.
5058 CHECK(context_1->GetEmbedderData(0)->IsUndefined()); 5047 CHECK(context_1->GetEmbedderData(0)->IsUndefined());
5059 CHECK(context_2->GetEmbedderData(0)->IsUndefined()); 5048 CHECK(context_2->GetEmbedderData(0)->IsUndefined());
5060 5049
5061 // Set and check different data values. 5050 // Set and check different data values.
5062 v8::Local<v8::String> data_1 = v8_str(isolate, "1"); 5051 v8::Local<v8::String> data_1 = v8_str(isolate, "1");
5063 v8::Local<v8::String> data_2 = v8_str(isolate, "2"); 5052 v8::Local<v8::String> data_2 = v8_str(isolate, "2");
5064 context_1->SetEmbedderData(0, data_1); 5053 context_1->SetEmbedderData(0, data_1);
5065 context_2->SetEmbedderData(0, data_2); 5054 context_2->SetEmbedderData(0, data_2);
(...skipping 18 matching lines...) Expand all
5084 v8::Context::Scope context_scope(context_2); 5073 v8::Context::Scope context_scope(context_2);
5085 expected_context = context_2; 5074 expected_context = context_2;
5086 expected_context_data = data_2; 5075 expected_context_data = data_2;
5087 v8::Local<v8::Function> f = CompileFunction(isolate, source, "f"); 5076 v8::Local<v8::Function> f = CompileFunction(isolate, source, "f");
5088 f->Call(context_2, context_2->Global(), 0, NULL).ToLocalChecked(); 5077 f->Call(context_2, context_2->Global(), 0, NULL).ToLocalChecked();
5089 } 5078 }
5090 5079
5091 // Two times compile event and two times break event. 5080 // Two times compile event and two times break event.
5092 CHECK_GT(event_listener_hit_count, 3); 5081 CHECK_GT(event_listener_hit_count, 3);
5093 5082
5094 v8::Debug::SetDebugEventListener(isolate, nullptr); 5083 SetDebugEventListener(isolate, nullptr);
5095 CheckDebuggerUnloaded(isolate); 5084 CheckDebuggerUnloaded(isolate);
5096 } 5085 }
5097 5086
5098 // Debug event listener which issues a debug break when it hits a break event. 5087 // Debug event listener which issues a debug break when it hits a break event.
5099 static int event_listener_break_hit_count = 0; 5088 static int event_listener_break_hit_count = 0;
5100 static void DebugBreakEventListener(const v8::Debug::EventDetails& details) { 5089 static void DebugBreakEventListener(const v8::Debug::EventDetails& details) {
5101 // Schedule a debug break for break events. 5090 // Schedule a debug break for break events.
5102 if (details.GetEvent() == v8::Break) { 5091 if (details.GetEvent() == v8::Break) {
5103 event_listener_break_hit_count++; 5092 event_listener_break_hit_count++;
5104 if (event_listener_break_hit_count == 1) { 5093 if (event_listener_break_hit_count == 1) {
5105 v8::Debug::DebugBreak(details.GetIsolate()); 5094 v8::debug::DebugBreak(details.GetIsolate());
5106 } 5095 }
5107 } 5096 }
5108 } 5097 }
5109 5098
5110 // Test that a debug break can be scheduled while in a event listener. 5099 // Test that a debug break can be scheduled while in a event listener.
5111 TEST(DebugBreakInEventListener) { 5100 TEST(DebugBreakInEventListener) {
5112 i::FLAG_turbo_inlining = false; // Make sure g is not inlined into f. 5101 i::FLAG_turbo_inlining = false; // Make sure g is not inlined into f.
5113 DebugLocalContext env; 5102 DebugLocalContext env;
5114 v8::HandleScope scope(env->GetIsolate()); 5103 v8::HandleScope scope(env->GetIsolate());
5115 5104
5116 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugBreakEventListener); 5105 SetDebugEventListener(env->GetIsolate(), DebugBreakEventListener);
5117 5106
5118 v8::Local<v8::Context> context = env.context(); 5107 v8::Local<v8::Context> context = env.context();
5119 // Test functions. 5108 // Test functions.
5120 const char* script = "function f() { debugger; g(); } function g() { }"; 5109 const char* script = "function f() { debugger; g(); } function g() { }";
5121 CompileRun(script); 5110 CompileRun(script);
5122 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( 5111 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
5123 env->Global() 5112 env->Global()
5124 ->Get(context, v8_str(env->GetIsolate(), "f")) 5113 ->Get(context, v8_str(env->GetIsolate(), "f"))
5125 .ToLocalChecked()); 5114 .ToLocalChecked());
5126 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( 5115 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
5163 } else { 5152 } else {
5164 CHECK(result->IsString()); 5153 CHECK(result->IsString());
5165 v8::Local<v8::String> function_name( 5154 v8::Local<v8::String> function_name(
5166 result->ToString(context).ToLocalChecked()); 5155 result->ToString(context).ToLocalChecked());
5167 function_name->WriteUtf8(last_function_hit); 5156 function_name->WriteUtf8(last_function_hit);
5168 } 5157 }
5169 } 5158 }
5170 5159
5171 // Keep forcing breaks. 5160 // Keep forcing breaks.
5172 if (break_point_hit_count < 20) { 5161 if (break_point_hit_count < 20) {
5173 v8::Debug::DebugBreak(CcTest::isolate()); 5162 v8::debug::DebugBreak(CcTest::isolate());
5174 } 5163 }
5175 } 5164 }
5176 } 5165 }
5177 5166
5178 5167
5179 TEST(RegExpDebugBreak) { 5168 TEST(RegExpDebugBreak) {
5180 // This test only applies to native regexps. 5169 // This test only applies to native regexps.
5181 DebugLocalContext env; 5170 DebugLocalContext env;
5182 v8::HandleScope scope(env->GetIsolate()); 5171 v8::HandleScope scope(env->GetIsolate());
5183 v8::Local<v8::Context> context = env.context(); 5172 v8::Local<v8::Context> context = env.context();
5184 // Create a function for checking the function when hitting a break point. 5173 // Create a function for checking the function when hitting a break point.
5185 frame_function_name = CompileFunction(&env, 5174 frame_function_name = CompileFunction(&env,
5186 frame_function_name_source, 5175 frame_function_name_source,
5187 "frame_function_name"); 5176 "frame_function_name");
5188 5177
5189 // Test RegExp which matches white spaces and comments at the begining of a 5178 // Test RegExp which matches white spaces and comments at the begining of a
5190 // source line. 5179 // source line.
5191 const char* script = 5180 const char* script =
5192 "var sourceLineBeginningSkip = /^(?:[ \\v\\h]*(?:\\/\\*.*?\\*\\/)*)*/;\n" 5181 "var sourceLineBeginningSkip = /^(?:[ \\v\\h]*(?:\\/\\*.*?\\*\\/)*)*/;\n"
5193 "function f(s) { return s.match(sourceLineBeginningSkip)[0].length; }"; 5182 "function f(s) { return s.match(sourceLineBeginningSkip)[0].length; }";
5194 5183
5195 v8::Local<v8::Function> f = CompileFunction(env->GetIsolate(), script, "f"); 5184 v8::Local<v8::Function> f = CompileFunction(env->GetIsolate(), script, "f");
5196 const int argc = 1; 5185 const int argc = 1;
5197 v8::Local<v8::Value> argv[argc] = { 5186 v8::Local<v8::Value> argv[argc] = {
5198 v8_str(env->GetIsolate(), " /* xxx */ a=0;")}; 5187 v8_str(env->GetIsolate(), " /* xxx */ a=0;")};
5199 v8::Local<v8::Value> result = 5188 v8::Local<v8::Value> result =
5200 f->Call(context, env->Global(), argc, argv).ToLocalChecked(); 5189 f->Call(context, env->Global(), argc, argv).ToLocalChecked();
5201 CHECK_EQ(12, result->Int32Value(context).FromJust()); 5190 CHECK_EQ(12, result->Int32Value(context).FromJust());
5202 5191
5203 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventDebugBreak); 5192 SetDebugEventListener(env->GetIsolate(), DebugEventDebugBreak);
5204 v8::Debug::DebugBreak(env->GetIsolate()); 5193 v8::debug::DebugBreak(env->GetIsolate());
5205 result = f->Call(context, env->Global(), argc, argv).ToLocalChecked(); 5194 result = f->Call(context, env->Global(), argc, argv).ToLocalChecked();
5206 5195
5207 // Check that there was only one break event. Matching RegExp should not 5196 // Check that there was only one break event. Matching RegExp should not
5208 // cause Break events. 5197 // cause Break events.
5209 CHECK_EQ(1, break_point_hit_count); 5198 CHECK_EQ(1, break_point_hit_count);
5210 CHECK_EQ(0, strcmp("f", last_function_hit)); 5199 CHECK_EQ(0, strcmp("f", last_function_hit));
5211 } 5200 }
5212 #endif // V8_INTERPRETED_REGEXP 5201 #endif // V8_INTERPRETED_REGEXP
5213 5202
5214 // Test which creates a context and sets embedder data on it. Checks that this 5203 // Test which creates a context and sets embedder data on it. Checks that this
5215 // data is set correctly and that when the debug event listener is called for 5204 // data is set correctly and that when the debug event listener is called for
5216 // break event in an eval statement the expected context is the one returned by 5205 // break event in an eval statement the expected context is the one returned by
5217 // Message.GetEventContext. 5206 // Message.GetEventContext.
5218 TEST(EvalContextData) { 5207 TEST(EvalContextData) {
5219 v8::HandleScope scope(CcTest::isolate()); 5208 v8::HandleScope scope(CcTest::isolate());
5220 5209
5221 v8::Local<v8::Context> context_1; 5210 v8::Local<v8::Context> context_1;
5222 v8::Local<v8::ObjectTemplate> global_template = 5211 v8::Local<v8::ObjectTemplate> global_template =
5223 v8::Local<v8::ObjectTemplate>(); 5212 v8::Local<v8::ObjectTemplate>();
5224 context_1 = 5213 context_1 =
5225 v8::Context::New(CcTest::isolate(), NULL, global_template); 5214 v8::Context::New(CcTest::isolate(), NULL, global_template);
5226 5215
5227 v8::Debug::SetDebugEventListener(CcTest::isolate(), 5216 SetDebugEventListener(CcTest::isolate(), ContextCheckEventListener);
5228 ContextCheckEventListener);
5229 5217
5230 // Default data value is undefined. 5218 // Default data value is undefined.
5231 CHECK(context_1->GetEmbedderData(0)->IsUndefined()); 5219 CHECK(context_1->GetEmbedderData(0)->IsUndefined());
5232 5220
5233 // Set and check a data value. 5221 // Set and check a data value.
5234 v8::Local<v8::String> data_1 = v8_str(CcTest::isolate(), "1"); 5222 v8::Local<v8::String> data_1 = v8_str(CcTest::isolate(), "1");
5235 context_1->SetEmbedderData(0, data_1); 5223 context_1->SetEmbedderData(0, data_1);
5236 CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1)); 5224 CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1));
5237 5225
5238 // Simple test function with eval that causes a break. 5226 // Simple test function with eval that causes a break.
5239 const char* source = "function f() { eval('debugger;'); }"; 5227 const char* source = "function f() { eval('debugger;'); }";
5240 5228
5241 // Enter and run function in the context. 5229 // Enter and run function in the context.
5242 { 5230 {
5243 v8::Context::Scope context_scope(context_1); 5231 v8::Context::Scope context_scope(context_1);
5244 expected_context = context_1; 5232 expected_context = context_1;
5245 expected_context_data = data_1; 5233 expected_context_data = data_1;
5246 v8::Local<v8::Function> f = CompileFunction(CcTest::isolate(), source, "f"); 5234 v8::Local<v8::Function> f = CompileFunction(CcTest::isolate(), source, "f");
5247 f->Call(context_1, context_1->Global(), 0, NULL).ToLocalChecked(); 5235 f->Call(context_1, context_1->Global(), 0, NULL).ToLocalChecked();
5248 } 5236 }
5249 5237
5250 v8::Debug::SetDebugEventListener(CcTest::isolate(), nullptr); 5238 SetDebugEventListener(CcTest::isolate(), nullptr);
5251 5239
5252 // One time compile event and one time break event. 5240 // One time compile event and one time break event.
5253 CHECK_GT(event_listener_hit_count, 2); 5241 CHECK_GT(event_listener_hit_count, 2);
5254 CheckDebuggerUnloaded(CcTest::isolate()); 5242 CheckDebuggerUnloaded(CcTest::isolate());
5255 } 5243 }
5256 5244
5257 5245
5258 // Debug event listener which counts the after compile events. 5246 // Debug event listener which counts the after compile events.
5259 int after_compile_event_count = 0; 5247 int after_compile_event_count = 0;
5260 static void AfterCompileEventListener(const v8::Debug::EventDetails& details) { 5248 static void AfterCompileEventListener(const v8::Debug::EventDetails& details) {
5261 // Count the number of scripts collected. 5249 // Count the number of scripts collected.
5262 if (details.GetEvent() == v8::AfterCompile) { 5250 if (details.GetEvent() == v8::AfterCompile) {
5263 after_compile_event_count++; 5251 after_compile_event_count++;
5264 } 5252 }
5265 } 5253 }
5266 5254
5267 5255
5268 // Tests that after compile event is sent as many times as there are scripts 5256 // Tests that after compile event is sent as many times as there are scripts
5269 // compiled. 5257 // compiled.
5270 TEST(AfterCompileEventWhenEventListenerIsReset) { 5258 TEST(AfterCompileEventWhenEventListenerIsReset) {
5271 DebugLocalContext env; 5259 DebugLocalContext env;
5272 v8::HandleScope scope(env->GetIsolate()); 5260 v8::HandleScope scope(env->GetIsolate());
5273 v8::Local<v8::Context> context = env.context(); 5261 v8::Local<v8::Context> context = env.context();
5274 const char* script = "var a=1"; 5262 const char* script = "var a=1";
5275 5263
5276 v8::Debug::SetDebugEventListener(env->GetIsolate(), 5264 SetDebugEventListener(env->GetIsolate(), AfterCompileEventListener);
5277 AfterCompileEventListener);
5278 v8::Script::Compile(context, v8_str(env->GetIsolate(), script)) 5265 v8::Script::Compile(context, v8_str(env->GetIsolate(), script))
5279 .ToLocalChecked() 5266 .ToLocalChecked()
5280 ->Run(context) 5267 ->Run(context)
5281 .ToLocalChecked(); 5268 .ToLocalChecked();
5282 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 5269 SetDebugEventListener(env->GetIsolate(), nullptr);
5283 5270
5284 v8::Debug::SetDebugEventListener(env->GetIsolate(), 5271 SetDebugEventListener(env->GetIsolate(), AfterCompileEventListener);
5285 AfterCompileEventListener); 5272 v8::debug::DebugBreak(env->GetIsolate());
5286 v8::Debug::DebugBreak(env->GetIsolate());
5287 v8::Script::Compile(context, v8_str(env->GetIsolate(), script)) 5273 v8::Script::Compile(context, v8_str(env->GetIsolate(), script))
5288 .ToLocalChecked() 5274 .ToLocalChecked()
5289 ->Run(context) 5275 ->Run(context)
5290 .ToLocalChecked(); 5276 .ToLocalChecked();
5291 5277
5292 // Setting listener to NULL should cause debugger unload. 5278 // Setting listener to NULL should cause debugger unload.
5293 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 5279 SetDebugEventListener(env->GetIsolate(), nullptr);
5294 CheckDebuggerUnloaded(env->GetIsolate()); 5280 CheckDebuggerUnloaded(env->GetIsolate());
5295 5281
5296 // Compilation cache should be disabled when debugger is active. 5282 // Compilation cache should be disabled when debugger is active.
5297 CHECK_EQ(2, after_compile_event_count); 5283 CHECK_EQ(2, after_compile_event_count);
5298 } 5284 }
5299 5285
5300 5286
5301 // Syntax error event handler which counts a number of events. 5287 // Syntax error event handler which counts a number of events.
5302 int compile_error_event_count = 0; 5288 int compile_error_event_count = 0;
5303 5289
(...skipping 13 matching lines...) Expand all
5317 5303
5318 // Tests that syntax error event is sent as many times as there are scripts 5304 // Tests that syntax error event is sent as many times as there are scripts
5319 // with syntax error compiled. 5305 // with syntax error compiled.
5320 TEST(SyntaxErrorEventOnSyntaxException) { 5306 TEST(SyntaxErrorEventOnSyntaxException) {
5321 DebugLocalContext env; 5307 DebugLocalContext env;
5322 v8::HandleScope scope(env->GetIsolate()); 5308 v8::HandleScope scope(env->GetIsolate());
5323 5309
5324 // For this test, we want to break on uncaught exceptions: 5310 // For this test, we want to break on uncaught exceptions:
5325 ChangeBreakOnException(false, true); 5311 ChangeBreakOnException(false, true);
5326 5312
5327 v8::Debug::SetDebugEventListener(env->GetIsolate(), CompileErrorEventCounter); 5313 SetDebugEventListener(env->GetIsolate(), CompileErrorEventCounter);
5328 v8::Local<v8::Context> context = env.context(); 5314 v8::Local<v8::Context> context = env.context();
5329 5315
5330 CompileErrorEventCounterClear(); 5316 CompileErrorEventCounterClear();
5331 5317
5332 // Check initial state. 5318 // Check initial state.
5333 CHECK_EQ(0, compile_error_event_count); 5319 CHECK_EQ(0, compile_error_event_count);
5334 5320
5335 // Throws SyntaxError: Unexpected end of input 5321 // Throws SyntaxError: Unexpected end of input
5336 CHECK( 5322 CHECK(
5337 v8::Script::Compile(context, v8_str(env->GetIsolate(), "+++")).IsEmpty()); 5323 v8::Script::Compile(context, v8_str(env->GetIsolate(), "+++")).IsEmpty());
(...skipping 21 matching lines...) Expand all
5359 CHECK_EQ(3, compile_error_event_count); 5345 CHECK_EQ(3, compile_error_event_count);
5360 } 5346 }
5361 5347
5362 // Tests that break event is sent when event listener is reset. 5348 // Tests that break event is sent when event listener is reset.
5363 TEST(BreakEventWhenEventListenerIsReset) { 5349 TEST(BreakEventWhenEventListenerIsReset) {
5364 DebugLocalContext env; 5350 DebugLocalContext env;
5365 v8::HandleScope scope(env->GetIsolate()); 5351 v8::HandleScope scope(env->GetIsolate());
5366 v8::Local<v8::Context> context = env.context(); 5352 v8::Local<v8::Context> context = env.context();
5367 const char* script = "function f() {};"; 5353 const char* script = "function f() {};";
5368 5354
5369 v8::Debug::SetDebugEventListener(env->GetIsolate(), 5355 SetDebugEventListener(env->GetIsolate(), AfterCompileEventListener);
5370 AfterCompileEventListener);
5371 v8::Script::Compile(context, v8_str(env->GetIsolate(), script)) 5356 v8::Script::Compile(context, v8_str(env->GetIsolate(), script))
5372 .ToLocalChecked() 5357 .ToLocalChecked()
5373 ->Run(context) 5358 ->Run(context)
5374 .ToLocalChecked(); 5359 .ToLocalChecked();
5375 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 5360 SetDebugEventListener(env->GetIsolate(), nullptr);
5376 5361
5377 v8::Debug::SetDebugEventListener(env->GetIsolate(), 5362 SetDebugEventListener(env->GetIsolate(), AfterCompileEventListener);
5378 AfterCompileEventListener); 5363 v8::debug::DebugBreak(env->GetIsolate());
5379 v8::Debug::DebugBreak(env->GetIsolate());
5380 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( 5364 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
5381 env->Global() 5365 env->Global()
5382 ->Get(context, v8_str(env->GetIsolate(), "f")) 5366 ->Get(context, v8_str(env->GetIsolate(), "f"))
5383 .ToLocalChecked()); 5367 .ToLocalChecked());
5384 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 5368 f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
5385 5369
5386 // Setting event listener to NULL should cause debugger unload. 5370 // Setting event listener to NULL should cause debugger unload.
5387 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 5371 SetDebugEventListener(env->GetIsolate(), nullptr);
5388 CheckDebuggerUnloaded(env->GetIsolate()); 5372 CheckDebuggerUnloaded(env->GetIsolate());
5389 5373
5390 // Compilation cache should be disabled when debugger is active. 5374 // Compilation cache should be disabled when debugger is active.
5391 CHECK_EQ(1, after_compile_event_count); 5375 CHECK_EQ(1, after_compile_event_count);
5392 } 5376 }
5393 5377
5394 5378
5395 static int exception_event_count = 0; 5379 static int exception_event_count = 0;
5396 static void ExceptionEventListener(const v8::Debug::EventDetails& details) { 5380 static void ExceptionEventListener(const v8::Debug::EventDetails& details) {
5397 if (details.GetEvent() == v8::Exception) exception_event_count++; 5381 if (details.GetEvent() == v8::Exception) exception_event_count++;
5398 } 5382 }
5399 5383
5400 // Tests that exception event is sent when event listener is reset. 5384 // Tests that exception event is sent when event listener is reset.
5401 TEST(ExceptionEventWhenEventListenerIsReset) { 5385 TEST(ExceptionEventWhenEventListenerIsReset) {
5402 DebugLocalContext env; 5386 DebugLocalContext env;
5403 v8::HandleScope scope(env->GetIsolate()); 5387 v8::HandleScope scope(env->GetIsolate());
5404 5388
5405 v8::Local<v8::Context> context = env.context(); 5389 v8::Local<v8::Context> context = env.context();
5406 // For this test, we want to break on uncaught exceptions: 5390 // For this test, we want to break on uncaught exceptions:
5407 ChangeBreakOnException(false, true); 5391 ChangeBreakOnException(false, true);
5408 5392
5409 exception_event_count = 0; 5393 exception_event_count = 0;
5410 const char* script = "function f() {throw new Error()};"; 5394 const char* script = "function f() {throw new Error()};";
5411 5395
5412 v8::Debug::SetDebugEventListener(env->GetIsolate(), 5396 SetDebugEventListener(env->GetIsolate(), AfterCompileEventListener);
5413 AfterCompileEventListener);
5414 v8::Script::Compile(context, v8_str(env->GetIsolate(), script)) 5397 v8::Script::Compile(context, v8_str(env->GetIsolate(), script))
5415 .ToLocalChecked() 5398 .ToLocalChecked()
5416 ->Run(context) 5399 ->Run(context)
5417 .ToLocalChecked(); 5400 .ToLocalChecked();
5418 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 5401 SetDebugEventListener(env->GetIsolate(), nullptr);
5419 5402
5420 v8::Debug::SetDebugEventListener(env->GetIsolate(), ExceptionEventListener); 5403 SetDebugEventListener(env->GetIsolate(), ExceptionEventListener);
5421 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( 5404 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
5422 env->Global() 5405 env->Global()
5423 ->Get(context, v8_str(env->GetIsolate(), "f")) 5406 ->Get(context, v8_str(env->GetIsolate(), "f"))
5424 .ToLocalChecked()); 5407 .ToLocalChecked());
5425 CHECK(f->Call(context, env->Global(), 0, NULL).IsEmpty()); 5408 CHECK(f->Call(context, env->Global(), 0, NULL).IsEmpty());
5426 5409
5427 // Setting event listener to NULL should cause debugger unload. 5410 // Setting event listener to NULL should cause debugger unload.
5428 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 5411 SetDebugEventListener(env->GetIsolate(), nullptr);
5429 CheckDebuggerUnloaded(env->GetIsolate()); 5412 CheckDebuggerUnloaded(env->GetIsolate());
5430 5413
5431 CHECK_EQ(1, exception_event_count); 5414 CHECK_EQ(1, exception_event_count);
5432 } 5415 }
5433 5416
5434 5417
5435 // Tests after compile event is sent when there are some provisional 5418 // Tests after compile event is sent when there are some provisional
5436 // breakpoints out of the scripts lines range. 5419 // breakpoints out of the scripts lines range.
5437 TEST(ProvisionalBreakpointOnLineOutOfRange) { 5420 TEST(ProvisionalBreakpointOnLineOutOfRange) {
5438 DebugLocalContext env; 5421 DebugLocalContext env;
5439 v8::HandleScope scope(env->GetIsolate()); 5422 v8::HandleScope scope(env->GetIsolate());
5440 env.ExposeDebug(); 5423 env.ExposeDebug();
5441 const char* script = "function f() {};"; 5424 const char* script = "function f() {};";
5442 const char* resource_name = "test_resource"; 5425 const char* resource_name = "test_resource";
5443 5426
5444 v8::Debug::SetDebugEventListener(env->GetIsolate(), 5427 SetDebugEventListener(env->GetIsolate(), AfterCompileEventListener);
5445 AfterCompileEventListener);
5446 v8::Local<v8::Context> context = env.context(); 5428 v8::Local<v8::Context> context = env.context();
5447 5429
5448 // Set a couple of provisional breakpoint on lines out of the script lines 5430 // Set a couple of provisional breakpoint on lines out of the script lines
5449 // range. 5431 // range.
5450 int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name, 5432 int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name,
5451 3, -1 /* no column */); 5433 3, -1 /* no column */);
5452 int sbp2 = 5434 int sbp2 =
5453 SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name, 5, 5); 5435 SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name, 5, 5);
5454 5436
5455 after_compile_event_count = 0; 5437 after_compile_event_count = 0;
5456 5438
5457 v8::ScriptOrigin origin(v8_str(env->GetIsolate(), resource_name), 5439 v8::ScriptOrigin origin(v8_str(env->GetIsolate(), resource_name),
5458 v8::Integer::New(env->GetIsolate(), 10), 5440 v8::Integer::New(env->GetIsolate(), 10),
5459 v8::Integer::New(env->GetIsolate(), 1)); 5441 v8::Integer::New(env->GetIsolate(), 1));
5460 // Compile a script whose first line number is greater than the breakpoints' 5442 // Compile a script whose first line number is greater than the breakpoints'
5461 // lines. 5443 // lines.
5462 v8::Script::Compile(context, v8_str(env->GetIsolate(), script), &origin) 5444 v8::Script::Compile(context, v8_str(env->GetIsolate(), script), &origin)
5463 .ToLocalChecked() 5445 .ToLocalChecked()
5464 ->Run(context) 5446 ->Run(context)
5465 .ToLocalChecked(); 5447 .ToLocalChecked();
5466 5448
5467 // If the script is compiled successfully there is exactly one after compile 5449 // If the script is compiled successfully there is exactly one after compile
5468 // event. In case of an exception in debugger code after compile event is not 5450 // event. In case of an exception in debugger code after compile event is not
5469 // sent. 5451 // sent.
5470 CHECK_EQ(1, after_compile_event_count); 5452 CHECK_EQ(1, after_compile_event_count);
5471 5453
5472 ClearBreakPointFromJS(env->GetIsolate(), sbp1); 5454 ClearBreakPointFromJS(env->GetIsolate(), sbp1);
5473 ClearBreakPointFromJS(env->GetIsolate(), sbp2); 5455 ClearBreakPointFromJS(env->GetIsolate(), sbp2);
5474 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 5456 SetDebugEventListener(env->GetIsolate(), nullptr);
5475 CheckDebuggerUnloaded(env->GetIsolate()); 5457 CheckDebuggerUnloaded(env->GetIsolate());
5476 } 5458 }
5477 5459
5478 static void BreakEventListener(const v8::Debug::EventDetails& details) { 5460 static void BreakEventListener(const v8::Debug::EventDetails& details) {
5479 if (details.GetEvent() == v8::Break) break_point_hit_count++; 5461 if (details.GetEvent() == v8::Break) break_point_hit_count++;
5480 } 5462 }
5481 5463
5482 5464
5483 // Test that if DebugBreak is forced it is ignored when code from 5465 // Test that if DebugBreak is forced it is ignored when code from
5484 // debug-delay.js is executed. 5466 // debug-delay.js is executed.
5485 TEST(NoDebugBreakInAfterCompileEventListener) { 5467 TEST(NoDebugBreakInAfterCompileEventListener) {
5486 DebugLocalContext env; 5468 DebugLocalContext env;
5487 v8::HandleScope scope(env->GetIsolate()); 5469 v8::HandleScope scope(env->GetIsolate());
5488 v8::Local<v8::Context> context = env.context(); 5470 v8::Local<v8::Context> context = env.context();
5489 5471
5490 // Register a debug event listener which sets the break flag and counts. 5472 // Register a debug event listener which sets the break flag and counts.
5491 v8::Debug::SetDebugEventListener(env->GetIsolate(), BreakEventListener); 5473 SetDebugEventListener(env->GetIsolate(), BreakEventListener);
5492 5474
5493 // Set the debug break flag. 5475 // Set the debug break flag.
5494 v8::Debug::DebugBreak(env->GetIsolate()); 5476 v8::debug::DebugBreak(env->GetIsolate());
5495 5477
5496 // Create a function for testing stepping. 5478 // Create a function for testing stepping.
5497 const char* src = "function f() { eval('var x = 10;'); } "; 5479 const char* src = "function f() { eval('var x = 10;'); } ";
5498 v8::Local<v8::Function> f = CompileFunction(&env, src, "f"); 5480 v8::Local<v8::Function> f = CompileFunction(&env, src, "f");
5499 5481
5500 // There should be only one break event. 5482 // There should be only one break event.
5501 CHECK_EQ(1, break_point_hit_count); 5483 CHECK_EQ(1, break_point_hit_count);
5502 5484
5503 // Set the debug break flag again. 5485 // Set the debug break flag again.
5504 v8::Debug::DebugBreak(env->GetIsolate()); 5486 v8::debug::DebugBreak(env->GetIsolate());
5505 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 5487 f->Call(context, env->Global(), 0, NULL).ToLocalChecked();
5506 // There should be one more break event when the script is evaluated in 'f'. 5488 // There should be one more break event when the script is evaluated in 'f'.
5507 CHECK_EQ(2, break_point_hit_count); 5489 CHECK_EQ(2, break_point_hit_count);
5508 5490
5509 // Get rid of the debug event listener. 5491 // Get rid of the debug event listener.
5510 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 5492 SetDebugEventListener(env->GetIsolate(), nullptr);
5511 CheckDebuggerUnloaded(env->GetIsolate()); 5493 CheckDebuggerUnloaded(env->GetIsolate());
5512 } 5494 }
5513 5495
5514 5496
5515 // Test that the debug break flag works with function.apply. 5497 // Test that the debug break flag works with function.apply.
5516 TEST(DebugBreakFunctionApply) { 5498 TEST(DebugBreakFunctionApply) {
5517 DebugLocalContext env; 5499 DebugLocalContext env;
5518 v8::HandleScope scope(env->GetIsolate()); 5500 v8::HandleScope scope(env->GetIsolate());
5519 v8::Local<v8::Context> context = env.context(); 5501 v8::Local<v8::Context> context = env.context();
5520 5502
5521 // Create a function for testing breaking in apply. 5503 // Create a function for testing breaking in apply.
5522 v8::Local<v8::Function> foo = CompileFunction( 5504 v8::Local<v8::Function> foo = CompileFunction(
5523 &env, 5505 &env,
5524 "function baz(x) { }" 5506 "function baz(x) { }"
5525 "function bar(x) { baz(); }" 5507 "function bar(x) { baz(); }"
5526 "function foo(){ bar.apply(this, [1]); }", 5508 "function foo(){ bar.apply(this, [1]); }",
5527 "foo"); 5509 "foo");
5528 5510
5529 // Register a debug event listener which steps and counts. 5511 // Register a debug event listener which steps and counts.
5530 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventBreakMax); 5512 SetDebugEventListener(env->GetIsolate(), DebugEventBreakMax);
5531 5513
5532 // Set the debug break flag before calling the code using function.apply. 5514 // Set the debug break flag before calling the code using function.apply.
5533 v8::Debug::DebugBreak(env->GetIsolate()); 5515 v8::debug::DebugBreak(env->GetIsolate());
5534 5516
5535 // Limit the number of debug breaks. This is a regression test for issue 493 5517 // Limit the number of debug breaks. This is a regression test for issue 493
5536 // where this test would enter an infinite loop. 5518 // where this test would enter an infinite loop.
5537 break_point_hit_count = 0; 5519 break_point_hit_count = 0;
5538 max_break_point_hit_count = 10000; // 10000 => infinite loop. 5520 max_break_point_hit_count = 10000; // 10000 => infinite loop.
5539 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); 5521 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked();
5540 5522
5541 // When keeping the debug break several break will happen. 5523 // When keeping the debug break several break will happen.
5542 CHECK_GT(break_point_hit_count, 1); 5524 CHECK_GT(break_point_hit_count, 1);
5543 5525
5544 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 5526 SetDebugEventListener(env->GetIsolate(), nullptr);
5545 CheckDebuggerUnloaded(env->GetIsolate()); 5527 CheckDebuggerUnloaded(env->GetIsolate());
5546 } 5528 }
5547 5529
5548 5530
5549 v8::Local<v8::Context> debugee_context; 5531 v8::Local<v8::Context> debugee_context;
5550 v8::Local<v8::Context> debugger_context; 5532 v8::Local<v8::Context> debugger_context;
5551 5533
5552 5534
5553 // Property getter that checks that current and calling contexts 5535 // Property getter that checks that current and calling contexts
5554 // are both the debugee contexts. 5536 // are both the debugee contexts.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
5602 5584
5603 // Create object with 'a' property accessor. 5585 // Create object with 'a' property accessor.
5604 v8::Local<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate); 5586 v8::Local<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
5605 named->SetAccessor(v8_str(isolate, "a"), NamedGetterWithCallingContextCheck); 5587 named->SetAccessor(v8_str(isolate, "a"), NamedGetterWithCallingContextCheck);
5606 CHECK(env->Global() 5588 CHECK(env->Global()
5607 ->Set(debugee_context, v8_str(isolate, "obj"), 5589 ->Set(debugee_context, v8_str(isolate, "obj"),
5608 named->NewInstance(debugee_context).ToLocalChecked()) 5590 named->NewInstance(debugee_context).ToLocalChecked())
5609 .FromJust()); 5591 .FromJust());
5610 5592
5611 // Register the debug event listener 5593 // Register the debug event listener
5612 v8::Debug::SetDebugEventListener(isolate, DebugEventGetAtgumentPropertyValue); 5594 SetDebugEventListener(isolate, DebugEventGetAtgumentPropertyValue);
5613 5595
5614 // Create a function that invokes debugger. 5596 // Create a function that invokes debugger.
5615 v8::Local<v8::Function> foo = CompileFunction( 5597 v8::Local<v8::Function> foo = CompileFunction(
5616 &env, 5598 &env,
5617 "function bar(x) { debugger; }" 5599 "function bar(x) { debugger; }"
5618 "function foo(){ bar(obj); }", 5600 "function foo(){ bar(obj); }",
5619 "foo"); 5601 "foo");
5620 5602
5621 break_point_hit_count = 0; 5603 break_point_hit_count = 0;
5622 foo->Call(debugee_context, env->Global(), 0, NULL).ToLocalChecked(); 5604 foo->Call(debugee_context, env->Global(), 0, NULL).ToLocalChecked();
5623 CHECK_EQ(1, break_point_hit_count); 5605 CHECK_EQ(1, break_point_hit_count);
5624 5606
5625 v8::Debug::SetDebugEventListener(isolate, nullptr); 5607 SetDebugEventListener(isolate, nullptr);
5626 debugee_context = v8::Local<v8::Context>(); 5608 debugee_context = v8::Local<v8::Context>();
5627 debugger_context = v8::Local<v8::Context>(); 5609 debugger_context = v8::Local<v8::Context>();
5628 CheckDebuggerUnloaded(isolate); 5610 CheckDebuggerUnloaded(isolate);
5629 } 5611 }
5630 5612
5631 5613
5632 static v8::Local<v8::Value> expected_callback_data; 5614 static v8::Local<v8::Value> expected_callback_data;
5633 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) { 5615 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) {
5634 CHECK(details.GetEventContext() == expected_context); 5616 CHECK(details.GetEventContext() == expected_context);
5635 CHECK(expected_callback_data->Equals(details.GetEventContext(), 5617 CHECK(expected_callback_data->Equals(details.GetEventContext(),
5636 details.GetCallbackData()) 5618 details.GetCallbackData())
5637 .FromJust()); 5619 .FromJust());
5638 } 5620 }
5639 5621
5640 5622
5641 // Check that event details contain context where debug event occured. 5623 // Check that event details contain context where debug event occured.
5642 TEST(DebugEventContext) { 5624 TEST(DebugEventContext) {
5643 v8::Isolate* isolate = CcTest::isolate(); 5625 v8::Isolate* isolate = CcTest::isolate();
5644 v8::HandleScope scope(isolate); 5626 v8::HandleScope scope(isolate);
5645 expected_context = v8::Context::New(isolate); 5627 expected_context = v8::Context::New(isolate);
5646 expected_callback_data = v8::Int32::New(isolate, 2010); 5628 expected_callback_data = v8::Int32::New(isolate, 2010);
5647 v8::Debug::SetDebugEventListener(isolate, DebugEventContextChecker, 5629 SetDebugEventListener(isolate, DebugEventContextChecker,
5648 expected_callback_data); 5630 expected_callback_data);
5649 v8::Context::Scope context_scope(expected_context); 5631 v8::Context::Scope context_scope(expected_context);
5650 v8::Script::Compile(expected_context, 5632 v8::Script::Compile(expected_context,
5651 v8_str(isolate, "(function(){debugger;})();")) 5633 v8_str(isolate, "(function(){debugger;})();"))
5652 .ToLocalChecked() 5634 .ToLocalChecked()
5653 ->Run(expected_context) 5635 ->Run(expected_context)
5654 .ToLocalChecked(); 5636 .ToLocalChecked();
5655 expected_context.Clear(); 5637 expected_context.Clear();
5656 v8::Debug::SetDebugEventListener(isolate, nullptr); 5638 SetDebugEventListener(isolate, nullptr);
5657 expected_context_data = v8::Local<v8::Value>(); 5639 expected_context_data = v8::Local<v8::Value>();
5658 CheckDebuggerUnloaded(isolate); 5640 CheckDebuggerUnloaded(isolate);
5659 } 5641 }
5660 5642
5661 5643
5662 static bool debug_event_break_deoptimize_done = false; 5644 static bool debug_event_break_deoptimize_done = false;
5663 5645
5664 static void DebugEventBreakDeoptimize( 5646 static void DebugEventBreakDeoptimize(
5665 const v8::Debug::EventDetails& event_details) { 5647 const v8::Debug::EventDetails& event_details) {
5666 v8::DebugEvent event = event_details.GetEvent(); 5648 v8::DebugEvent event = event_details.GetEvent();
(...skipping 14 matching lines...) Expand all
5681 v8::Local<v8::String> function_name( 5663 v8::Local<v8::String> function_name(
5682 result->ToString(context).ToLocalChecked()); 5664 result->ToString(context).ToLocalChecked());
5683 function_name->WriteUtf8(fn); 5665 function_name->WriteUtf8(fn);
5684 if (strcmp(fn, "bar") == 0) { 5666 if (strcmp(fn, "bar") == 0) {
5685 i::Deoptimizer::DeoptimizeAll(CcTest::i_isolate()); 5667 i::Deoptimizer::DeoptimizeAll(CcTest::i_isolate());
5686 debug_event_break_deoptimize_done = true; 5668 debug_event_break_deoptimize_done = true;
5687 } 5669 }
5688 } 5670 }
5689 } 5671 }
5690 5672
5691 v8::Debug::DebugBreak(CcTest::isolate()); 5673 v8::debug::DebugBreak(CcTest::isolate());
5692 } 5674 }
5693 } 5675 }
5694 5676
5695 5677
5696 // Test deoptimization when execution is broken using the debug break stack 5678 // Test deoptimization when execution is broken using the debug break stack
5697 // check interrupt. 5679 // check interrupt.
5698 TEST(DeoptimizeDuringDebugBreak) { 5680 TEST(DeoptimizeDuringDebugBreak) {
5699 DebugLocalContext env; 5681 DebugLocalContext env;
5700 v8::HandleScope scope(env->GetIsolate()); 5682 v8::HandleScope scope(env->GetIsolate());
5701 env.ExposeDebug(); 5683 env.ExposeDebug();
5702 v8::Local<v8::Context> context = env.context(); 5684 v8::Local<v8::Context> context = env.context();
5703 5685
5704 // Create a function for checking the function when hitting a break point. 5686 // Create a function for checking the function when hitting a break point.
5705 frame_function_name = CompileFunction(&env, 5687 frame_function_name = CompileFunction(&env,
5706 frame_function_name_source, 5688 frame_function_name_source,
5707 "frame_function_name"); 5689 "frame_function_name");
5708 5690
5709 // Set a debug event listener which will keep interrupting execution until 5691 // Set a debug event listener which will keep interrupting execution until
5710 // debug break. When inside function bar it will deoptimize all functions. 5692 // debug break. When inside function bar it will deoptimize all functions.
5711 // This tests lazy deoptimization bailout for the stack check, as the first 5693 // This tests lazy deoptimization bailout for the stack check, as the first
5712 // time in function bar when using debug break and no break points will be at 5694 // time in function bar when using debug break and no break points will be at
5713 // the initial stack check. 5695 // the initial stack check.
5714 v8::Debug::SetDebugEventListener(env->GetIsolate(), 5696 SetDebugEventListener(env->GetIsolate(), DebugEventBreakDeoptimize);
5715 DebugEventBreakDeoptimize);
5716 5697
5717 // Compile and run function bar which will optimize it for some flag settings. 5698 // Compile and run function bar which will optimize it for some flag settings.
5718 v8::Local<v8::Function> f = CompileFunction(&env, "function bar(){}", "bar"); 5699 v8::Local<v8::Function> f = CompileFunction(&env, "function bar(){}", "bar");
5719 f->Call(context, v8::Undefined(env->GetIsolate()), 0, NULL).ToLocalChecked(); 5700 f->Call(context, v8::Undefined(env->GetIsolate()), 0, NULL).ToLocalChecked();
5720 5701
5721 // Set debug break and call bar again. 5702 // Set debug break and call bar again.
5722 v8::Debug::DebugBreak(env->GetIsolate()); 5703 v8::debug::DebugBreak(env->GetIsolate());
5723 f->Call(context, v8::Undefined(env->GetIsolate()), 0, NULL).ToLocalChecked(); 5704 f->Call(context, v8::Undefined(env->GetIsolate()), 0, NULL).ToLocalChecked();
5724 5705
5725 CHECK(debug_event_break_deoptimize_done); 5706 CHECK(debug_event_break_deoptimize_done);
5726 5707
5727 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 5708 SetDebugEventListener(env->GetIsolate(), nullptr);
5728 } 5709 }
5729 5710
5730 5711
5731 static void DebugEventBreakWithOptimizedStack( 5712 static void DebugEventBreakWithOptimizedStack(
5732 const v8::Debug::EventDetails& event_details) { 5713 const v8::Debug::EventDetails& event_details) {
5733 v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate(); 5714 v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate();
5734 v8::DebugEvent event = event_details.GetEvent(); 5715 v8::DebugEvent event = event_details.GetEvent();
5735 v8::Local<v8::Object> exec_state = event_details.GetExecutionState(); 5716 v8::Local<v8::Object> exec_state = event_details.GetExecutionState();
5736 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 5717 v8::Local<v8::Context> context = isolate->GetCurrentContext();
5737 if (event == v8::Break) { 5718 if (event == v8::Break) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
5784 .ToLocalChecked(); 5765 .ToLocalChecked();
5785 CHECK(result->IsUndefined() || 5766 CHECK(result->IsUndefined() ||
5786 (result->Int32Value(context).FromJust() == 42)); 5767 (result->Int32Value(context).FromJust() == 42));
5787 } 5768 }
5788 } 5769 }
5789 } 5770 }
5790 } 5771 }
5791 5772
5792 5773
5793 static void ScheduleBreak(const v8::FunctionCallbackInfo<v8::Value>& args) { 5774 static void ScheduleBreak(const v8::FunctionCallbackInfo<v8::Value>& args) {
5794 v8::Debug::SetDebugEventListener(args.GetIsolate(), 5775 SetDebugEventListener(args.GetIsolate(), DebugEventBreakWithOptimizedStack);
5795 DebugEventBreakWithOptimizedStack); 5776 v8::debug::DebugBreak(args.GetIsolate());
5796 v8::Debug::DebugBreak(args.GetIsolate());
5797 } 5777 }
5798 5778
5799 5779
5800 TEST(DebugBreakStackInspection) { 5780 TEST(DebugBreakStackInspection) {
5801 DebugLocalContext env; 5781 DebugLocalContext env;
5802 v8::HandleScope scope(env->GetIsolate()); 5782 v8::HandleScope scope(env->GetIsolate());
5803 v8::Local<v8::Context> context = env.context(); 5783 v8::Local<v8::Context> context = env.context();
5804 5784
5805 frame_function_name = 5785 frame_function_name =
5806 CompileFunction(&env, frame_function_name_source, "frame_function_name"); 5786 CompileFunction(&env, frame_function_name_source, "frame_function_name");
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
5859 } 5839 }
5860 5840
5861 break_point_hit_count = 0; 5841 break_point_hit_count = 0;
5862 max_break_point_hit_count = kBreaksPerTest; 5842 max_break_point_hit_count = kBreaksPerTest;
5863 terminate_after_max_break_point_hit = true; 5843 terminate_after_max_break_point_hit = true;
5864 5844
5865 // Function with infinite loop. 5845 // Function with infinite loop.
5866 CompileRun(buffer.start()); 5846 CompileRun(buffer.start());
5867 5847
5868 // Set the debug break to enter the debugger as soon as possible. 5848 // Set the debug break to enter the debugger as soon as possible.
5869 v8::Debug::DebugBreak(CcTest::isolate()); 5849 v8::debug::DebugBreak(CcTest::isolate());
5870 5850
5871 // Call function with infinite loop. 5851 // Call function with infinite loop.
5872 CompileRun("f();"); 5852 CompileRun("f();");
5873 CHECK_EQ(kBreaksPerTest, break_point_hit_count); 5853 CHECK_EQ(kBreaksPerTest, break_point_hit_count);
5874 5854
5875 CHECK(!CcTest::isolate()->IsExecutionTerminating()); 5855 CHECK(!CcTest::isolate()->IsExecutionTerminating());
5876 } 5856 }
5877 } 5857 }
5878 } 5858 }
5879 5859
(...skipping 15 matching lines...) Expand all
5895 "switch (a) { case 1: continue; break; default: h() }", 5875 "switch (a) { case 1: continue; break; default: h() }",
5896 NULL}; 5876 NULL};
5897 5877
5898 5878
5899 void DebugBreakLoop(const char* loop_header, const char** loop_bodies, 5879 void DebugBreakLoop(const char* loop_header, const char** loop_bodies,
5900 const char* loop_footer) { 5880 const char* loop_footer) {
5901 DebugLocalContext env; 5881 DebugLocalContext env;
5902 v8::HandleScope scope(env->GetIsolate()); 5882 v8::HandleScope scope(env->GetIsolate());
5903 5883
5904 // Register a debug event listener which sets the break flag and counts. 5884 // Register a debug event listener which sets the break flag and counts.
5905 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventBreakMax); 5885 SetDebugEventListener(env->GetIsolate(), DebugEventBreakMax);
5906 5886
5907 CompileRun( 5887 CompileRun(
5908 "var a = 1;\n" 5888 "var a = 1;\n"
5909 "function g() { }\n" 5889 "function g() { }\n"
5910 "function h() { }"); 5890 "function h() { }");
5911 5891
5912 TestDebugBreakInLoop(loop_header, loop_bodies, loop_footer); 5892 TestDebugBreakInLoop(loop_header, loop_bodies, loop_footer);
5913 5893
5914 // Get rid of the debug event listener. 5894 // Get rid of the debug event listener.
5915 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 5895 SetDebugEventListener(env->GetIsolate(), nullptr);
5916 CheckDebuggerUnloaded(env->GetIsolate()); 5896 CheckDebuggerUnloaded(env->GetIsolate());
5917 } 5897 }
5918 5898
5919 5899
5920 TEST(DebugBreakInWhileTrue1) { 5900 TEST(DebugBreakInWhileTrue1) {
5921 DebugBreakLoop("while (true) {", loop_bodies_1, "}"); 5901 DebugBreakLoop("while (true) {", loop_bodies_1, "}");
5922 } 5902 }
5923 5903
5924 5904
5925 TEST(DebugBreakInWhileTrue2) { 5905 TEST(DebugBreakInWhileTrue2) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
5999 5979
6000 for (int i = 0; i < frame_count; i++) { 5980 for (int i = 0; i < frame_count; i++) {
6001 // The 6. element in the returned array of GetFrameDetails contains the 5981 // The 6. element in the returned array of GetFrameDetails contains the
6002 // source position of that frame. 5982 // source position of that frame.
6003 SNPrintF(script_vector, "%%GetFrameDetails(%d, %d)[6]", break_id, i); 5983 SNPrintF(script_vector, "%%GetFrameDetails(%d, %d)[6]", break_id, i);
6004 v8::Local<v8::Value> result = CompileRun(script); 5984 v8::Local<v8::Value> result = CompileRun(script);
6005 CHECK_EQ(expected_line_number[i], 5985 CHECK_EQ(expected_line_number[i],
6006 i::Script::GetLineNumber(source_script, 5986 i::Script::GetLineNumber(source_script,
6007 result->Int32Value(context).FromJust())); 5987 result->Int32Value(context).FromJust()));
6008 } 5988 }
6009 v8::Debug::SetDebugEventListener(CcTest::isolate(), nullptr); 5989 SetDebugEventListener(CcTest::isolate(), nullptr);
6010 CcTest::isolate()->TerminateExecution(); 5990 CcTest::isolate()->TerminateExecution();
6011 } 5991 }
6012 5992
6013 5993
6014 TEST(DebugBreakInline) { 5994 TEST(DebugBreakInline) {
6015 i::FLAG_allow_natives_syntax = true; 5995 i::FLAG_allow_natives_syntax = true;
6016 DebugLocalContext env; 5996 DebugLocalContext env;
6017 v8::HandleScope scope(env->GetIsolate()); 5997 v8::HandleScope scope(env->GetIsolate());
6018 v8::Local<v8::Context> context = env.context(); 5998 v8::Local<v8::Context> context = env.context();
6019 const char* source = 5999 const char* source =
6020 "function debug(b) { \n" 6000 "function debug(b) { \n"
6021 " if (b) debugger; \n" 6001 " if (b) debugger; \n"
6022 "} \n" 6002 "} \n"
6023 "function f(b) { \n" 6003 "function f(b) { \n"
6024 " debug(b) \n" 6004 " debug(b) \n"
6025 "}; \n" 6005 "}; \n"
6026 "function g(b) { \n" 6006 "function g(b) { \n"
6027 " f(b); \n" 6007 " f(b); \n"
6028 "}; \n" 6008 "}; \n"
6029 "g(false); \n" 6009 "g(false); \n"
6030 "g(false); \n" 6010 "g(false); \n"
6031 "%OptimizeFunctionOnNextCall(g); \n" 6011 "%OptimizeFunctionOnNextCall(g); \n"
6032 "g(true);"; 6012 "g(true);";
6033 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugBreakInlineListener); 6013 SetDebugEventListener(env->GetIsolate(), DebugBreakInlineListener);
6034 inline_script = 6014 inline_script =
6035 v8::Script::Compile(context, v8_str(env->GetIsolate(), source)) 6015 v8::Script::Compile(context, v8_str(env->GetIsolate(), source))
6036 .ToLocalChecked(); 6016 .ToLocalChecked();
6037 inline_script->Run(context).ToLocalChecked(); 6017 inline_script->Run(context).ToLocalChecked();
6038 } 6018 }
6039 6019
6040 6020
6041 static void DebugEventStepNext( 6021 static void DebugEventStepNext(
6042 const v8::Debug::EventDetails& event_details) { 6022 const v8::Debug::EventDetails& event_details) {
6043 v8::DebugEvent event = event_details.GetEvent(); 6023 v8::DebugEvent event = event_details.GetEvent();
(...skipping 14 matching lines...) Expand all
6058 // Bug description: 6038 // Bug description:
6059 // When doing StepNext through the first script, the debugger is not reset 6039 // When doing StepNext through the first script, the debugger is not reset
6060 // after exiting through exception. A flawed implementation enabling the 6040 // after exiting through exception. A flawed implementation enabling the
6061 // debugger to step into Array.prototype.forEach breaks inside the callback 6041 // debugger to step into Array.prototype.forEach breaks inside the callback
6062 // for forEach in the second script under the assumption that we are in a 6042 // for forEach in the second script under the assumption that we are in a
6063 // recursive call. In an attempt to step out, we crawl the stack using the 6043 // recursive call. In an attempt to step out, we crawl the stack using the
6064 // recorded frame pointer from the first script and fail when not finding it 6044 // recorded frame pointer from the first script and fail when not finding it
6065 // on the stack. 6045 // on the stack.
6066 DebugLocalContext env; 6046 DebugLocalContext env;
6067 v8::HandleScope scope(env->GetIsolate()); 6047 v8::HandleScope scope(env->GetIsolate());
6068 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventStepNext); 6048 SetDebugEventListener(env->GetIsolate(), DebugEventStepNext);
6069 6049
6070 // We step through the first script. It exits through an exception. We run 6050 // We step through the first script. It exits through an exception. We run
6071 // this inside a new frame to record a different FP than the second script 6051 // this inside a new frame to record a different FP than the second script
6072 // would expect. 6052 // would expect.
6073 const char* script_1 = "debugger; throw new Error();"; 6053 const char* script_1 = "debugger; throw new Error();";
6074 RunScriptInANewCFrame(script_1); 6054 RunScriptInANewCFrame(script_1);
6075 6055
6076 // The second script uses forEach. 6056 // The second script uses forEach.
6077 const char* script_2 = "[0].forEach(function() { });"; 6057 const char* script_2 = "[0].forEach(function() { });";
6078 CompileRun(script_2); 6058 CompileRun(script_2);
6079 6059
6080 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 6060 SetDebugEventListener(env->GetIsolate(), nullptr);
6081 } 6061 }
6082 6062
6083 6063
6084 // Import from test-heap.cc 6064 // Import from test-heap.cc
6085 namespace v8 { 6065 namespace v8 {
6086 namespace internal { 6066 namespace internal {
6087 6067
6088 int CountNativeContexts(); 6068 int CountNativeContexts();
6089 } 6069 }
6090 } 6070 }
6091 6071
6092 6072
6093 static void NopListener(const v8::Debug::EventDetails& event_details) { 6073 static void NopListener(const v8::Debug::EventDetails& event_details) {
6094 } 6074 }
6095 6075
6096 6076
6097 TEST(DebuggerCreatesContextIffActive) { 6077 TEST(DebuggerCreatesContextIffActive) {
6098 DebugLocalContext env; 6078 DebugLocalContext env;
6099 v8::HandleScope scope(env->GetIsolate()); 6079 v8::HandleScope scope(env->GetIsolate());
6100 CHECK_EQ(1, v8::internal::CountNativeContexts()); 6080 CHECK_EQ(1, v8::internal::CountNativeContexts());
6101 6081
6102 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 6082 SetDebugEventListener(env->GetIsolate(), nullptr);
6103 CompileRun("debugger;"); 6083 CompileRun("debugger;");
6104 CHECK_EQ(1, v8::internal::CountNativeContexts()); 6084 CHECK_EQ(1, v8::internal::CountNativeContexts());
6105 6085
6106 v8::Debug::SetDebugEventListener(env->GetIsolate(), NopListener); 6086 SetDebugEventListener(env->GetIsolate(), NopListener);
6107 CompileRun("debugger;"); 6087 CompileRun("debugger;");
6108 CHECK_EQ(2, v8::internal::CountNativeContexts()); 6088 CHECK_EQ(2, v8::internal::CountNativeContexts());
6109 6089
6110 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 6090 SetDebugEventListener(env->GetIsolate(), nullptr);
6111 } 6091 }
6112 6092
6113 6093
6114 TEST(LiveEditEnabled) { 6094 TEST(LiveEditEnabled) {
6115 v8::internal::FLAG_allow_natives_syntax = true; 6095 v8::internal::FLAG_allow_natives_syntax = true;
6116 LocalContext env; 6096 LocalContext env;
6117 v8::HandleScope scope(env->GetIsolate()); 6097 v8::HandleScope scope(env->GetIsolate());
6118 v8::Debug::SetLiveEditEnabled(env->GetIsolate(), true); 6098 v8::debug::SetLiveEditEnabled(env->GetIsolate(), true);
6119 CompileRun("%LiveEditCompareStrings('', '')"); 6099 CompileRun("%LiveEditCompareStrings('', '')");
6120 } 6100 }
6121 6101
6122 6102
6123 TEST(LiveEditDisabled) { 6103 TEST(LiveEditDisabled) {
6124 v8::internal::FLAG_allow_natives_syntax = true; 6104 v8::internal::FLAG_allow_natives_syntax = true;
6125 LocalContext env; 6105 LocalContext env;
6126 v8::HandleScope scope(env->GetIsolate()); 6106 v8::HandleScope scope(env->GetIsolate());
6127 v8::Debug::SetLiveEditEnabled(env->GetIsolate(), false); 6107 v8::debug::SetLiveEditEnabled(env->GetIsolate(), false);
6128 CompileRun("%LiveEditCompareStrings('', '')"); 6108 CompileRun("%LiveEditCompareStrings('', '')");
6129 } 6109 }
6130 6110
6131 6111
6132 TEST(PrecompiledFunction) { 6112 TEST(PrecompiledFunction) {
6133 // Regression test for crbug.com/346207. If we have preparse data, parsing the 6113 // 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 6114 // 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 6115 // succeed. The bug was that preparsing was done lazily and parsing was done
6136 // eagerly, so, the symbol streams didn't match. 6116 // eagerly, so, the symbol streams didn't match.
6137 DebugLocalContext env; 6117 DebugLocalContext env;
6138 v8::HandleScope scope(env->GetIsolate()); 6118 v8::HandleScope scope(env->GetIsolate());
6139 env.ExposeDebug(); 6119 env.ExposeDebug();
6140 v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugBreakInlineListener); 6120 SetDebugEventListener(env->GetIsolate(), DebugBreakInlineListener);
6141 6121
6142 v8::Local<v8::Function> break_here = 6122 v8::Local<v8::Function> break_here =
6143 CompileFunction(&env, "function break_here(){}", "break_here"); 6123 CompileFunction(&env, "function break_here(){}", "break_here");
6144 SetBreakPoint(break_here, 0); 6124 SetBreakPoint(break_here, 0);
6145 6125
6146 const char* source = 6126 const char* source =
6147 "var a = b = c = 1; \n" 6127 "var a = b = c = 1; \n"
6148 "function this_is_lazy() { \n" 6128 "function this_is_lazy() { \n"
6149 // This symbol won't appear in the preparse data. 6129 // This symbol won't appear in the preparse data.
6150 " var a; \n" 6130 " var a; \n"
6151 "} \n" 6131 "} \n"
6152 "function bar() { \n" 6132 "function bar() { \n"
6153 " return \"bar\"; \n" 6133 " return \"bar\"; \n"
6154 "}; \n" 6134 "}; \n"
6155 "a = b = c = 2; \n" 6135 "a = b = c = 2; \n"
6156 "bar(); \n"; 6136 "bar(); \n";
6157 v8::Local<v8::Value> result = ParserCacheCompileRun(source); 6137 v8::Local<v8::Value> result = ParserCacheCompileRun(source);
6158 CHECK(result->IsString()); 6138 CHECK(result->IsString());
6159 v8::String::Utf8Value utf8(result); 6139 v8::String::Utf8Value utf8(result);
6160 CHECK_EQ(0, strcmp("bar", *utf8)); 6140 CHECK_EQ(0, strcmp("bar", *utf8));
6161 6141
6162 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 6142 SetDebugEventListener(env->GetIsolate(), nullptr);
6163 CheckDebuggerUnloaded(env->GetIsolate()); 6143 CheckDebuggerUnloaded(env->GetIsolate());
6164 } 6144 }
6165 6145
6166 6146
6167 static void DebugBreakStackTraceListener( 6147 static void DebugBreakStackTraceListener(
6168 const v8::Debug::EventDetails& event_details) { 6148 const v8::Debug::EventDetails& event_details) {
6169 v8::StackTrace::CurrentStackTrace(CcTest::isolate(), 10); 6149 v8::StackTrace::CurrentStackTrace(CcTest::isolate(), 10);
6170 } 6150 }
6171 6151
6172 6152
6173 static void AddDebugBreak(const v8::FunctionCallbackInfo<v8::Value>& args) { 6153 static void AddDebugBreak(const v8::FunctionCallbackInfo<v8::Value>& args) {
6174 v8::Debug::DebugBreak(args.GetIsolate()); 6154 v8::debug::DebugBreak(args.GetIsolate());
6175 } 6155 }
6176 6156
6177 6157
6178 TEST(DebugBreakStackTrace) { 6158 TEST(DebugBreakStackTrace) {
6179 DebugLocalContext env; 6159 DebugLocalContext env;
6180 v8::HandleScope scope(env->GetIsolate()); 6160 v8::HandleScope scope(env->GetIsolate());
6181 v8::Debug::SetDebugEventListener(env->GetIsolate(), 6161 SetDebugEventListener(env->GetIsolate(), DebugBreakStackTraceListener);
6182 DebugBreakStackTraceListener);
6183 v8::Local<v8::Context> context = env.context(); 6162 v8::Local<v8::Context> context = env.context();
6184 v8::Local<v8::FunctionTemplate> add_debug_break_template = 6163 v8::Local<v8::FunctionTemplate> add_debug_break_template =
6185 v8::FunctionTemplate::New(env->GetIsolate(), AddDebugBreak); 6164 v8::FunctionTemplate::New(env->GetIsolate(), AddDebugBreak);
6186 v8::Local<v8::Function> add_debug_break = 6165 v8::Local<v8::Function> add_debug_break =
6187 add_debug_break_template->GetFunction(context).ToLocalChecked(); 6166 add_debug_break_template->GetFunction(context).ToLocalChecked();
6188 CHECK(env->Global() 6167 CHECK(env->Global()
6189 ->Set(context, v8_str("add_debug_break"), add_debug_break) 6168 ->Set(context, v8_str("add_debug_break"), add_debug_break)
6190 .FromJust()); 6169 .FromJust());
6191 6170
6192 CompileRun("(function loop() {" 6171 CompileRun("(function loop() {"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
6227 6206
6228 private: 6207 private:
6229 v8::Isolate* isolate_; 6208 v8::Isolate* isolate_;
6230 }; 6209 };
6231 6210
6232 6211
6233 TEST(DebugBreakOffThreadTerminate) { 6212 TEST(DebugBreakOffThreadTerminate) {
6234 DebugLocalContext env; 6213 DebugLocalContext env;
6235 v8::Isolate* isolate = env->GetIsolate(); 6214 v8::Isolate* isolate = env->GetIsolate();
6236 v8::HandleScope scope(isolate); 6215 v8::HandleScope scope(isolate);
6237 v8::Debug::SetDebugEventListener(isolate, DebugBreakTriggerTerminate); 6216 SetDebugEventListener(isolate, DebugBreakTriggerTerminate);
6238 TerminationThread terminator(isolate); 6217 TerminationThread terminator(isolate);
6239 terminator.Start(); 6218 terminator.Start();
6240 v8::TryCatch try_catch(env->GetIsolate()); 6219 v8::TryCatch try_catch(env->GetIsolate());
6241 v8::Debug::DebugBreak(isolate); 6220 v8::debug::DebugBreak(isolate);
6242 CompileRun("while (true);"); 6221 CompileRun("while (true);");
6243 CHECK(try_catch.HasTerminated()); 6222 CHECK(try_catch.HasTerminated());
6244 } 6223 }
6245 6224
6246 6225
6247 static void DebugEventExpectNoException( 6226 static void DebugEventExpectNoException(
6248 const v8::Debug::EventDetails& event_details) { 6227 const v8::Debug::EventDetails& event_details) {
6249 v8::DebugEvent event = event_details.GetEvent(); 6228 v8::DebugEvent event = event_details.GetEvent();
6250 CHECK_NE(v8::Exception, event); 6229 CHECK_NE(v8::Exception, event);
6251 } 6230 }
6252 6231
6253 6232
6254 static void TryCatchWrappedThrowCallback( 6233 static void TryCatchWrappedThrowCallback(
6255 const v8::FunctionCallbackInfo<v8::Value>& args) { 6234 const v8::FunctionCallbackInfo<v8::Value>& args) {
6256 v8::TryCatch try_catch(args.GetIsolate()); 6235 v8::TryCatch try_catch(args.GetIsolate());
6257 CompileRun("throw 'rejection';"); 6236 CompileRun("throw 'rejection';");
6258 CHECK(try_catch.HasCaught()); 6237 CHECK(try_catch.HasCaught());
6259 } 6238 }
6260 6239
6261 6240
6262 TEST(DebugPromiseInterceptedByTryCatch) { 6241 TEST(DebugPromiseInterceptedByTryCatch) {
6263 DebugLocalContext env; 6242 DebugLocalContext env;
6264 v8::Isolate* isolate = env->GetIsolate(); 6243 v8::Isolate* isolate = env->GetIsolate();
6265 v8::HandleScope scope(isolate); 6244 v8::HandleScope scope(isolate);
6266 v8::Debug::SetDebugEventListener(isolate, &DebugEventExpectNoException); 6245 SetDebugEventListener(isolate, &DebugEventExpectNoException);
6267 v8::Local<v8::Context> context = env.context(); 6246 v8::Local<v8::Context> context = env.context();
6268 ChangeBreakOnException(false, true); 6247 ChangeBreakOnException(false, true);
6269 6248
6270 v8::Local<v8::FunctionTemplate> fun = 6249 v8::Local<v8::FunctionTemplate> fun =
6271 v8::FunctionTemplate::New(isolate, TryCatchWrappedThrowCallback); 6250 v8::FunctionTemplate::New(isolate, TryCatchWrappedThrowCallback);
6272 CHECK(env->Global() 6251 CHECK(env->Global()
6273 ->Set(context, v8_str("fun"), 6252 ->Set(context, v8_str("fun"),
6274 fun->GetFunction(context).ToLocalChecked()) 6253 fun->GetFunction(context).ToLocalChecked())
6275 .FromJust()); 6254 .FromJust());
6276 6255
(...skipping 18 matching lines...) Expand all
6295 6274
6296 static void ThrowCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { 6275 static void ThrowCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
6297 CompileRun("throw 'rejection';"); 6276 CompileRun("throw 'rejection';");
6298 } 6277 }
6299 6278
6300 6279
6301 TEST(DebugPromiseRejectedByCallback) { 6280 TEST(DebugPromiseRejectedByCallback) {
6302 DebugLocalContext env; 6281 DebugLocalContext env;
6303 v8::Isolate* isolate = env->GetIsolate(); 6282 v8::Isolate* isolate = env->GetIsolate();
6304 v8::HandleScope scope(isolate); 6283 v8::HandleScope scope(isolate);
6305 v8::Debug::SetDebugEventListener(isolate, &DebugEventCountException); 6284 SetDebugEventListener(isolate, &DebugEventCountException);
6306 v8::Local<v8::Context> context = env.context(); 6285 v8::Local<v8::Context> context = env.context();
6307 ChangeBreakOnException(false, true); 6286 ChangeBreakOnException(false, true);
6308 exception_event_counter = 0; 6287 exception_event_counter = 0;
6309 6288
6310 v8::Local<v8::FunctionTemplate> fun = 6289 v8::Local<v8::FunctionTemplate> fun =
6311 v8::FunctionTemplate::New(isolate, ThrowCallback); 6290 v8::FunctionTemplate::New(isolate, ThrowCallback);
6312 CHECK(env->Global() 6291 CHECK(env->Global()
6313 ->Set(context, v8_str("fun"), 6292 ->Set(context, v8_str("fun"),
6314 fun->GetFunction(context).ToLocalChecked()) 6293 fun->GetFunction(context).ToLocalChecked())
6315 .FromJust()); 6294 .FromJust());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
6356 ExpectInt32("frame.evaluate('x + y').value_", 11); 6335 ExpectInt32("frame.evaluate('x + y').value_", 11);
6357 } 6336 }
6358 6337
6359 6338
6360 TEST(DebugBreakInLexicalScopes) { 6339 TEST(DebugBreakInLexicalScopes) {
6361 i::FLAG_allow_natives_syntax = true; 6340 i::FLAG_allow_natives_syntax = true;
6362 6341
6363 DebugLocalContext env; 6342 DebugLocalContext env;
6364 v8::Isolate* isolate = env->GetIsolate(); 6343 v8::Isolate* isolate = env->GetIsolate();
6365 v8::HandleScope scope(isolate); 6344 v8::HandleScope scope(isolate);
6366 v8::Debug::SetDebugEventListener(isolate, DebugHarmonyScopingListener); 6345 SetDebugEventListener(isolate, DebugHarmonyScopingListener);
6367 6346
6368 CompileRun( 6347 CompileRun(
6369 "'use strict'; \n" 6348 "'use strict'; \n"
6370 "let x = 1; \n"); 6349 "let x = 1; \n");
6371 ExpectInt32( 6350 ExpectInt32(
6372 "'use strict'; \n" 6351 "'use strict'; \n"
6373 "let y = 2; \n" 6352 "let y = 2; \n"
6374 "debugger; \n" 6353 "debugger; \n"
6375 "x * y", 6354 "x * y",
6376 30); 6355 30);
(...skipping 16 matching lines...) Expand all
6393 // Do not allow nested AfterCompile events. 6372 // Do not allow nested AfterCompile events.
6394 CHECK(after_compile_handler_depth <= 1); 6373 CHECK(after_compile_handler_depth <= 1);
6395 v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate(); 6374 v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate();
6396 isolate->RequestInterrupt(&HandleInterrupt, nullptr); 6375 isolate->RequestInterrupt(&HandleInterrupt, nullptr);
6397 CompileRun("function foo() {}; foo();"); 6376 CompileRun("function foo() {}; foo();");
6398 --after_compile_handler_depth; 6377 --after_compile_handler_depth;
6399 } 6378 }
6400 6379
6401 TEST(NoInterruptsInDebugListener) { 6380 TEST(NoInterruptsInDebugListener) {
6402 DebugLocalContext env; 6381 DebugLocalContext env;
6403 v8::Debug::SetDebugEventListener(env->GetIsolate(), NoInterruptsOnDebugEvent); 6382 SetDebugEventListener(env->GetIsolate(), NoInterruptsOnDebugEvent);
6404 CompileRun("void(0);"); 6383 CompileRun("void(0);");
6405 } 6384 }
6406 6385
6407 TEST(BreakLocationIterator) { 6386 TEST(BreakLocationIterator) {
6408 DebugLocalContext env; 6387 DebugLocalContext env;
6409 v8::Isolate* isolate = env->GetIsolate(); 6388 v8::Isolate* isolate = env->GetIsolate();
6410 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6389 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6411 v8::HandleScope scope(isolate); 6390 v8::HandleScope scope(isolate);
6412 6391
6413 v8::Local<v8::Value> result = CompileRun( 6392 v8::Local<v8::Value> result = CompileRun(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
6452 6431
6453 TEST(DisableTailCallElimination) { 6432 TEST(DisableTailCallElimination) {
6454 i::FLAG_allow_natives_syntax = true; 6433 i::FLAG_allow_natives_syntax = true;
6455 i::FLAG_harmony_tailcalls = true; 6434 i::FLAG_harmony_tailcalls = true;
6456 // TODO(ishell, 4698): Investigate why TurboFan in --always-opt mode makes 6435 // TODO(ishell, 4698): Investigate why TurboFan in --always-opt mode makes
6457 // stack[2].getFunctionName() return null. 6436 // stack[2].getFunctionName() return null.
6458 i::FLAG_turbo_inlining = false; 6437 i::FLAG_turbo_inlining = false;
6459 6438
6460 DebugLocalContext env; 6439 DebugLocalContext env;
6461 v8::Isolate* isolate = env->GetIsolate(); 6440 v8::Isolate* isolate = env->GetIsolate();
6441 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6462 v8::HandleScope scope(isolate); 6442 v8::HandleScope scope(isolate);
6463 CHECK(v8::Debug::IsTailCallEliminationEnabled(isolate)); 6443 CHECK(i_isolate->is_tail_call_elimination_enabled());
6464 6444
6465 CompileRun( 6445 CompileRun(
6466 "'use strict'; \n" 6446 "'use strict'; \n"
6467 "Error.prepareStackTrace = (error,stack) => { \n" 6447 "Error.prepareStackTrace = (error,stack) => { \n"
6468 " error.strace = stack; \n" 6448 " error.strace = stack; \n"
6469 " return error.message + \"\\n at \" + stack.join(\"\\n at \"); \n" 6449 " return error.message + \"\\n at \" + stack.join(\"\\n at \"); \n"
6470 "} \n" 6450 "} \n"
6471 " \n" 6451 " \n"
6472 "function getCaller() { \n" 6452 "function getCaller() { \n"
6473 " var e = new Error(); \n" 6453 " var e = new Error(); \n"
(...skipping 16 matching lines...) Expand all
6490 "function h() { \n" 6470 "function h() { \n"
6491 " var result = g(); \n" 6471 " var result = g(); \n"
6492 " return result; \n" 6472 " return result; \n"
6493 "} \n" 6473 "} \n"
6494 "%NeverOptimizeFunction(getCaller); \n" 6474 "%NeverOptimizeFunction(getCaller); \n"
6495 "%NeverOptimizeFunction(f); \n" 6475 "%NeverOptimizeFunction(f); \n"
6496 "%NeverOptimizeFunction(h); \n" 6476 "%NeverOptimizeFunction(h); \n"
6497 ""); 6477 "");
6498 ExpectInt32("h();", 2); 6478 ExpectInt32("h();", 2);
6499 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 2); 6479 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 2);
6500 v8::Debug::SetTailCallEliminationEnabled(isolate, false); 6480 i_isolate->SetTailCallEliminationEnabled(false);
6501 CHECK(!v8::Debug::IsTailCallEliminationEnabled(isolate)); 6481 CHECK(!i_isolate->is_tail_call_elimination_enabled());
6502 ExpectInt32("h();", 1); 6482 ExpectInt32("h();", 1);
6503 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 1); 6483 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 1);
6504 v8::Debug::SetTailCallEliminationEnabled(isolate, true); 6484 i_isolate->SetTailCallEliminationEnabled(true);
6505 CHECK(v8::Debug::IsTailCallEliminationEnabled(isolate)); 6485 CHECK(i_isolate->is_tail_call_elimination_enabled());
6506 ExpectInt32("h();", 2); 6486 ExpectInt32("h();", 2);
6507 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 2); 6487 ExpectInt32("h(); %OptimizeFunctionOnNextCall(g); h();", 2);
6508 } 6488 }
6509 6489
6510 TEST(DebugStepNextTailCallEliminiation) { 6490 TEST(DebugStepNextTailCallEliminiation) {
6511 i::FLAG_allow_natives_syntax = true; 6491 i::FLAG_allow_natives_syntax = true;
6512 i::FLAG_harmony_tailcalls = true; 6492 i::FLAG_harmony_tailcalls = true;
6513 // TODO(ishell, 4698): Investigate why TurboFan in --always-opt mode makes 6493 // TODO(ishell, 4698): Investigate why TurboFan in --always-opt mode makes
6514 // stack[2].getFunctionName() return null. 6494 // stack[2].getFunctionName() return null.
6515 i::FLAG_turbo_inlining = false; 6495 i::FLAG_turbo_inlining = false;
6516 6496
6517 DebugLocalContext env; 6497 DebugLocalContext env;
6518 env.ExposeDebug(); 6498 env.ExposeDebug();
6519 v8::Isolate* isolate = env->GetIsolate(); 6499 v8::Isolate* isolate = env->GetIsolate();
6500 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6520 v8::HandleScope scope(isolate); 6501 v8::HandleScope scope(isolate);
6521 CHECK(v8::Debug::IsTailCallEliminationEnabled(isolate)); 6502 CHECK(i_isolate->is_tail_call_elimination_enabled());
6522 6503
6523 const char* source = 6504 const char* source =
6524 "'use strict'; \n" 6505 "'use strict'; \n"
6525 "var Debug = debug.Debug; \n" 6506 "var Debug = debug.Debug; \n"
6526 "var exception = null; \n" 6507 "var exception = null; \n"
6527 "var breaks = 0; \n" 6508 "var breaks = 0; \n"
6528 "var log = []; \n" 6509 "var log = []; \n"
6529 "function f(x) { \n" 6510 "function f(x) { \n"
6530 " if (x == 2) { \n" 6511 " if (x == 2) { \n"
6531 " debugger; // Break a \n" 6512 " debugger; // Break a \n"
(...skipping 15 matching lines...) Expand all
6547 " }; \n" 6528 " }; \n"
6548 "}; \n" 6529 "}; \n"
6549 "Debug.setListener(listener); \n" 6530 "Debug.setListener(listener); \n"
6550 "f(4); \n" 6531 "f(4); \n"
6551 "Debug.setListener(null); // Break d \n"; 6532 "Debug.setListener(null); // Break d \n";
6552 6533
6553 CompileRun(source); 6534 CompileRun(source);
6554 ExpectNull("exception"); 6535 ExpectNull("exception");
6555 ExpectString("JSON.stringify(log)", "[\"a4\",\"b2\",\"c4\",\"c11\",\"d0\"]"); 6536 ExpectString("JSON.stringify(log)", "[\"a4\",\"b2\",\"c4\",\"c11\",\"d0\"]");
6556 6537
6557 v8::Debug::SetTailCallEliminationEnabled(isolate, false); 6538 i_isolate->SetTailCallEliminationEnabled(false);
6558 CompileRun( 6539 CompileRun(
6559 "log = []; \n" 6540 "log = []; \n"
6560 "Debug.setListener(listener); \n" 6541 "Debug.setListener(listener); \n"
6561 "f(5); \n" 6542 "f(5); \n"
6562 "Debug.setListener(null); // Break f \n"); 6543 "Debug.setListener(null); // Break f \n");
6563 ExpectNull("exception"); 6544 ExpectNull("exception");
6564 ExpectString("JSON.stringify(log)", 6545 ExpectString("JSON.stringify(log)",
6565 "[\"a4\",\"b2\",\"c4\",\"e0\",\"e0\",\"e0\",\"e0\",\"f0\"]"); 6546 "[\"a4\",\"b2\",\"c4\",\"e0\",\"e0\",\"e0\",\"e0\",\"f0\"]");
6566 } 6547 }
6567 6548
6568 size_t current_action = 0; 6549 size_t current_action = 0;
6569 StepAction actions[] = {StepNext, StepNext}; 6550 StepAction actions[] = {StepNext, StepNext};
6570 static void DebugStepOverFunctionWithCaughtExceptionListener( 6551 static void DebugStepOverFunctionWithCaughtExceptionListener(
6571 const v8::Debug::EventDetails& event_details) { 6552 const v8::Debug::EventDetails& event_details) {
6572 v8::DebugEvent event = event_details.GetEvent(); 6553 v8::DebugEvent event = event_details.GetEvent();
6573 if (event != v8::Break) return; 6554 if (event != v8::Break) return;
6574 ++break_point_hit_count; 6555 ++break_point_hit_count;
6575 if (current_action >= 2) return; 6556 if (current_action >= 2) return;
6576 PrepareStep(actions[current_action]); 6557 PrepareStep(actions[current_action]);
6577 } 6558 }
6578 6559
6579 TEST(DebugStepOverFunctionWithCaughtException) { 6560 TEST(DebugStepOverFunctionWithCaughtException) {
6580 i::FLAG_allow_natives_syntax = true; 6561 i::FLAG_allow_natives_syntax = true;
6581 6562
6582 DebugLocalContext env; 6563 DebugLocalContext env;
6583 v8::Isolate* isolate = env->GetIsolate(); 6564 v8::Isolate* isolate = env->GetIsolate();
6584 v8::HandleScope scope(isolate); 6565 v8::HandleScope scope(isolate);
6585 v8::Debug::SetDebugEventListener( 6566 SetDebugEventListener(isolate,
6586 isolate, DebugStepOverFunctionWithCaughtExceptionListener); 6567 DebugStepOverFunctionWithCaughtExceptionListener);
6587 6568
6588 break_point_hit_count = 0; 6569 break_point_hit_count = 0;
6589 CompileRun( 6570 CompileRun(
6590 "function foo() {\n" 6571 "function foo() {\n"
6591 " try { throw new Error(); } catch (e) {}\n" 6572 " try { throw new Error(); } catch (e) {}\n"
6592 "}\n" 6573 "}\n"
6593 "debugger;\n" 6574 "debugger;\n"
6594 "foo();\n" 6575 "foo();\n"
6595 "foo();\n"); 6576 "foo();\n");
6596 6577
6597 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); 6578 SetDebugEventListener(env->GetIsolate(), nullptr);
6598 CHECK_EQ(4, break_point_hit_count); 6579 CHECK_EQ(4, break_point_hit_count);
6599 } 6580 }
6600 6581
6601 bool out_of_memory_callback_called = false; 6582 bool out_of_memory_callback_called = false;
6602 void OutOfMemoryCallback(void* data) { 6583 void OutOfMemoryCallback(void* data) {
6603 out_of_memory_callback_called = true; 6584 out_of_memory_callback_called = true;
6604 reinterpret_cast<v8::Isolate*>(data)->IncreaseHeapLimitForDebugging(); 6585 reinterpret_cast<v8::Isolate*>(data)->IncreaseHeapLimitForDebugging();
6605 } 6586 }
6606 6587
6607 UNINITIALIZED_TEST(DebugSetOutOfMemoryListener) { 6588 UNINITIALIZED_TEST(DebugSetOutOfMemoryListener) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
6662 6643
6663 function_data = script_data.GetFunctionData(1); 6644 function_data = script_data.GetFunctionData(1);
6664 start = script->GetSourceLocation(function_data.StartOffset()); 6645 start = script->GetSourceLocation(function_data.StartOffset());
6665 end = script->GetSourceLocation(function_data.EndOffset()); 6646 end = script->GetSourceLocation(function_data.EndOffset());
6666 CHECK_EQ(0, start.GetLineNumber()); 6647 CHECK_EQ(0, start.GetLineNumber());
6667 CHECK_EQ(0, start.GetColumnNumber()); 6648 CHECK_EQ(0, start.GetColumnNumber());
6668 CHECK_EQ(1, end.GetLineNumber()); 6649 CHECK_EQ(1, end.GetLineNumber());
6669 CHECK_EQ(1, end.GetColumnNumber()); 6650 CHECK_EQ(1, end.GetColumnNumber());
6670 CHECK_EQ(2, function_data.Count()); 6651 CHECK_EQ(2, function_data.Count());
6671 } 6652 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-run-bytecode-graph-builder.cc ('k') | test/cctest/wasm/test-wasm-breakpoints.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698