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

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

Issue 157543002: A64: Synchronize with r18581. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-cpu-profiler.cc ('k') | test/cctest/test-declarative-accessors.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 Debug* debug = isolate->debug(); 637 Debug* debug = isolate->debug();
638 // When hitting a debug event listener there must be a break set. 638 // When hitting a debug event listener there must be a break set.
639 CHECK_NE(debug->break_id(), 0); 639 CHECK_NE(debug->break_id(), 0);
640 640
641 // Count the number of breaks. 641 // Count the number of breaks.
642 if (event == v8::Break) { 642 if (event == v8::Break) {
643 break_point_hit_count++; 643 break_point_hit_count++;
644 if (!frame_function_name.IsEmpty()) { 644 if (!frame_function_name.IsEmpty()) {
645 // Get the name of the function. 645 // Get the name of the function.
646 const int argc = 2; 646 const int argc = 2;
647 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(0) }; 647 v8::Handle<v8::Value> argv[argc] = {
648 exec_state, v8::Integer::New(CcTest::isolate(), 0)
649 };
648 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state, 650 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state,
649 argc, argv); 651 argc, argv);
650 if (result->IsUndefined()) { 652 if (result->IsUndefined()) {
651 last_function_hit[0] = '\0'; 653 last_function_hit[0] = '\0';
652 } else { 654 } else {
653 CHECK(result->IsString()); 655 CHECK(result->IsString());
654 v8::Handle<v8::String> function_name(result->ToString()); 656 v8::Handle<v8::String> function_name(result->ToString());
655 function_name->WriteUtf8(last_function_hit); 657 function_name->WriteUtf8(last_function_hit);
656 } 658 }
657 } 659 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 886 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
885 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); 887 v8::internal::Debug* debug = CcTest::i_isolate()->debug();
886 // When hitting a debug event listener there must be a break set. 888 // When hitting a debug event listener there must be a break set.
887 CHECK_NE(debug->break_id(), 0); 889 CHECK_NE(debug->break_id(), 0);
888 890
889 if (event == v8::Break || event == v8::Exception) { 891 if (event == v8::Break || event == v8::Exception) {
890 // Check that the current function is the expected. 892 // Check that the current function is the expected.
891 CHECK(break_point_hit_count < 893 CHECK(break_point_hit_count <
892 StrLength(expected_step_sequence)); 894 StrLength(expected_step_sequence));
893 const int argc = 2; 895 const int argc = 2;
894 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(0) }; 896 v8::Handle<v8::Value> argv[argc] = {
897 exec_state, v8::Integer::New(CcTest::isolate(), 0)
898 };
895 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state, 899 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state,
896 argc, argv); 900 argc, argv);
897 CHECK(result->IsString()); 901 CHECK(result->IsString());
898 v8::String::Utf8Value function_name(result->ToString()); 902 v8::String::Utf8Value function_name(result->ToString());
899 CHECK_EQ(1, StrLength(*function_name)); 903 CHECK_EQ(1, StrLength(*function_name));
900 CHECK_EQ((*function_name)[0], 904 CHECK_EQ((*function_name)[0],
901 expected_step_sequence[break_point_hit_count]); 905 expected_step_sequence[break_point_hit_count]);
902 906
903 // Perform step. 907 // Perform step.
904 break_point_hit_count++; 908 break_point_hit_count++;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 v8::HandleScope scope(env->GetIsolate()); 1033 v8::HandleScope scope(env->GetIsolate());
1030 1034
1031 CheckDebugBreakFunction(&env, 1035 CheckDebugBreakFunction(&env,
1032 "function f1(){}", "f1", 1036 "function f1(){}", "f1",
1033 0, 1037 0,
1034 v8::internal::RelocInfo::JS_RETURN, 1038 v8::internal::RelocInfo::JS_RETURN,
1035 NULL); 1039 NULL);
1036 CheckDebugBreakFunction(&env, 1040 CheckDebugBreakFunction(&env,
1037 "function f2(){x=1;}", "f2", 1041 "function f2(){x=1;}", "f2",
1038 0, 1042 0,
1039 v8::internal::RelocInfo::CODE_TARGET_CONTEXT, 1043 v8::internal::RelocInfo::CODE_TARGET,
1040 CcTest::i_isolate()->builtins()->builtin( 1044 CcTest::i_isolate()->builtins()->builtin(
1041 Builtins::kStoreIC_DebugBreak)); 1045 Builtins::kStoreIC_DebugBreak));
1042 CheckDebugBreakFunction(&env, 1046 CheckDebugBreakFunction(&env,
1043 "function f3(){var a=x;}", "f3", 1047 "function f3(){var a=x;}", "f3",
1044 0, 1048 0,
1045 v8::internal::RelocInfo::CODE_TARGET_CONTEXT, 1049 v8::internal::RelocInfo::CODE_TARGET,
1046 CcTest::i_isolate()->builtins()->builtin( 1050 CcTest::i_isolate()->builtins()->builtin(
1047 Builtins::kLoadIC_DebugBreak)); 1051 Builtins::kLoadIC_DebugBreak));
1048 1052
1049 // TODO(1240753): Make the test architecture independent or split 1053 // TODO(1240753): Make the test architecture independent or split
1050 // parts of the debugger into architecture dependent files. This 1054 // parts of the debugger into architecture dependent files. This
1051 // part currently disabled as it is not portable between IA32/ARM. 1055 // part currently disabled as it is not portable between IA32/ARM.
1052 // Currently on ICs for keyed store/load on ARM. 1056 // Currently on ICs for keyed store/load on ARM.
1053 #if !defined (__arm__) && !defined(__thumb__) 1057 #if !defined (__arm__) && !defined(__thumb__)
1054 CheckDebugBreakFunction( 1058 CheckDebugBreakFunction(
1055 &env, 1059 &env,
(...skipping 24 matching lines...) Expand all
1080 1084
1081 // Check the debug break code stubs for call ICs with different number of 1085 // Check the debug break code stubs for call ICs with different number of
1082 // parameters. 1086 // parameters.
1083 Handle<Code> debug_break_0 = v8::internal::ComputeCallDebugBreak(0); 1087 Handle<Code> debug_break_0 = v8::internal::ComputeCallDebugBreak(0);
1084 Handle<Code> debug_break_1 = v8::internal::ComputeCallDebugBreak(1); 1088 Handle<Code> debug_break_1 = v8::internal::ComputeCallDebugBreak(1);
1085 Handle<Code> debug_break_4 = v8::internal::ComputeCallDebugBreak(4); 1089 Handle<Code> debug_break_4 = v8::internal::ComputeCallDebugBreak(4);
1086 1090
1087 CheckDebugBreakFunction(&env, 1091 CheckDebugBreakFunction(&env,
1088 "function f4_0(){x();}", "f4_0", 1092 "function f4_0(){x();}", "f4_0",
1089 0, 1093 0,
1090 v8::internal::RelocInfo::CODE_TARGET_CONTEXT, 1094 v8::internal::RelocInfo::CODE_TARGET,
1091 *debug_break_0); 1095 *debug_break_0);
1092 1096
1093 CheckDebugBreakFunction(&env, 1097 CheckDebugBreakFunction(&env,
1094 "function f4_1(){x(1);}", "f4_1", 1098 "function f4_1(){x(1);}", "f4_1",
1095 0, 1099 0,
1096 v8::internal::RelocInfo::CODE_TARGET_CONTEXT, 1100 v8::internal::RelocInfo::CODE_TARGET,
1097 *debug_break_1); 1101 *debug_break_1);
1098 1102
1099 CheckDebugBreakFunction(&env, 1103 CheckDebugBreakFunction(&env,
1100 "function f4_4(){x(1,2,3,4);}", "f4_4", 1104 "function f4_4(){x(1,2,3,4);}", "f4_4",
1101 0, 1105 0,
1102 v8::internal::RelocInfo::CODE_TARGET_CONTEXT, 1106 v8::internal::RelocInfo::CODE_TARGET,
1103 *debug_break_4); 1107 *debug_break_4);
1104 } 1108 }
1105 1109
1106 1110
1107 // Test that the debug info in the VM is in sync with the functions being 1111 // Test that the debug info in the VM is in sync with the functions being
1108 // debugged. 1112 // debugged.
1109 TEST(DebugInfo) { 1113 TEST(DebugInfo) {
1110 DebugLocalContext env; 1114 DebugLocalContext env;
1111 v8::HandleScope scope(env->GetIsolate()); 1115 v8::HandleScope scope(env->GetIsolate());
1112 // Create a couple of functions for the test. 1116 // Create a couple of functions for the test.
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
2089 v8::Local<v8::String> script = v8::String::NewFromUtf8( 2093 v8::Local<v8::String> script = v8::String::NewFromUtf8(
2090 env->GetIsolate(), 2094 env->GetIsolate(),
2091 "function f() {\n" 2095 "function f() {\n"
2092 " a = 0; // line 8 as this script has line offset 7\n" 2096 " a = 0; // line 8 as this script has line offset 7\n"
2093 " b = 0; // line 9 as this script has line offset 7\n" 2097 " b = 0; // line 9 as this script has line offset 7\n"
2094 "}"); 2098 "}");
2095 2099
2096 // Create script origin both name and line offset. 2100 // Create script origin both name and line offset.
2097 v8::ScriptOrigin origin( 2101 v8::ScriptOrigin origin(
2098 v8::String::NewFromUtf8(env->GetIsolate(), "test.html"), 2102 v8::String::NewFromUtf8(env->GetIsolate(), "test.html"),
2099 v8::Integer::New(7)); 2103 v8::Integer::New(env->GetIsolate(), 7));
2100 2104
2101 // Set two script break points before the script is loaded. 2105 // Set two script break points before the script is loaded.
2102 int sbp1 = 2106 int sbp1 =
2103 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 8, 0); 2107 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 8, 0);
2104 int sbp2 = 2108 int sbp2 =
2105 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 9, 0); 2109 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 9, 0);
2106 2110
2107 // Compile the script and get the function. 2111 // Compile the script and get the function.
2108 v8::Script::Compile(script, &origin)->Run(); 2112 v8::Script::Compile(script, &origin)->Run();
2109 f = v8::Local<v8::Function>::Cast( 2113 f = v8::Local<v8::Function>::Cast(
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2172 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 0, -1); 2176 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 0, -1);
2173 int sbp2 = 2177 int sbp2 =
2174 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 1, -1); 2178 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 1, -1);
2175 int sbp3 = 2179 int sbp3 =
2176 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 5, -1); 2180 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 5, -1);
2177 2181
2178 // Compile the script and get the function. 2182 // Compile the script and get the function.
2179 break_point_hit_count = 0; 2183 break_point_hit_count = 0;
2180 v8::ScriptOrigin origin( 2184 v8::ScriptOrigin origin(
2181 v8::String::NewFromUtf8(env->GetIsolate(), "test.html"), 2185 v8::String::NewFromUtf8(env->GetIsolate(), "test.html"),
2182 v8::Integer::New(0)); 2186 v8::Integer::New(env->GetIsolate(), 0));
2183 v8::Script::Compile(script, &origin)->Run(); 2187 v8::Script::Compile(script, &origin)->Run();
2184 f = v8::Local<v8::Function>::Cast( 2188 f = v8::Local<v8::Function>::Cast(
2185 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 2189 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
2186 g = v8::Local<v8::Function>::Cast( 2190 g = v8::Local<v8::Function>::Cast(
2187 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); 2191 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g")));
2188 2192
2189 // Check that a break point was hit when the script was run. 2193 // Check that a break point was hit when the script was run.
2190 CHECK_EQ(1, break_point_hit_count); 2194 CHECK_EQ(1, break_point_hit_count);
2191 CHECK_EQ(0, StrLength(last_function_hit)); 2195 CHECK_EQ(0, StrLength(last_function_hit));
2192 2196
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
2507 " y=0;a=x;" 2511 " y=0;a=x;"
2508 "}", 2512 "}",
2509 "bar"); 2513 "bar");
2510 const int barbar_break_position = 8; 2514 const int barbar_break_position = 8;
2511 2515
2512 // Call bar setting breakpoint before a=x in barbar and undefined as 2516 // Call bar setting breakpoint before a=x in barbar and undefined as
2513 // parameter. 2517 // parameter.
2514 checks = checks_uu; 2518 checks = checks_uu;
2515 v8::Handle<v8::Value> argv_bar_1[2] = { 2519 v8::Handle<v8::Value> argv_bar_1[2] = {
2516 v8::Undefined(isolate), 2520 v8::Undefined(isolate),
2517 v8::Number::New(barbar_break_position) 2521 v8::Number::New(isolate, barbar_break_position)
2518 }; 2522 };
2519 bar->Call(env->Global(), 2, argv_bar_1); 2523 bar->Call(env->Global(), 2, argv_bar_1);
2520 2524
2521 // Call bar setting breakpoint before a=x in barbar and parameter 2525 // Call bar setting breakpoint before a=x in barbar and parameter
2522 // "Hello, world!". 2526 // "Hello, world!".
2523 checks = checks_hu; 2527 checks = checks_hu;
2524 v8::Handle<v8::Value> argv_bar_2[2] = { 2528 v8::Handle<v8::Value> argv_bar_2[2] = {
2525 v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!"), 2529 v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!"),
2526 v8::Number::New(barbar_break_position) 2530 v8::Number::New(env->GetIsolate(), barbar_break_position)
2527 }; 2531 };
2528 bar->Call(env->Global(), 2, argv_bar_2); 2532 bar->Call(env->Global(), 2, argv_bar_2);
2529 2533
2530 // Call bar setting breakpoint after a=x in barbar and parameter 2534 // Call bar setting breakpoint after a=x in barbar and parameter
2531 // "Hello, world!". 2535 // "Hello, world!".
2532 checks = checks_hh; 2536 checks = checks_hh;
2533 v8::Handle<v8::Value> argv_bar_3[2] = { 2537 v8::Handle<v8::Value> argv_bar_3[2] = {
2534 v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!"), 2538 v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!"),
2535 v8::Number::New(barbar_break_position + 1) 2539 v8::Number::New(env->GetIsolate(), barbar_break_position + 1)
2536 }; 2540 };
2537 bar->Call(env->Global(), 2, argv_bar_3); 2541 bar->Call(env->Global(), 2, argv_bar_3);
2538 2542
2539 v8::Debug::SetDebugEventListener2(NULL); 2543 v8::Debug::SetDebugEventListener2(NULL);
2540 CheckDebuggerUnloaded(); 2544 CheckDebuggerUnloaded();
2541 } 2545 }
2542 2546
2543 2547
2544 int debugEventCount = 0; 2548 int debugEventCount = 0;
2545 static void CheckDebugEvent(const v8::Debug::EventDetails& eventDetails) { 2549 static void CheckDebugEvent(const v8::Debug::EventDetails& eventDetails) {
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
2858 " y = 1;\n" 2862 " y = 1;\n"
2859 " x = a[i];\n" 2863 " x = a[i];\n"
2860 " }\n" 2864 " }\n"
2861 "}\n" 2865 "}\n"
2862 "y=0\n", 2866 "y=0\n",
2863 "foo"); 2867 "foo");
2864 2868
2865 // Create array [0,1,2,3,4,5,6,7,8,9] 2869 // Create array [0,1,2,3,4,5,6,7,8,9]
2866 v8::Local<v8::Array> a = v8::Array::New(env->GetIsolate(), 10); 2870 v8::Local<v8::Array> a = v8::Array::New(env->GetIsolate(), 10);
2867 for (int i = 0; i < 10; i++) { 2871 for (int i = 0; i < 10; i++) {
2868 a->Set(v8::Number::New(i), v8::Number::New(i)); 2872 a->Set(v8::Number::New(env->GetIsolate(), i),
2873 v8::Number::New(env->GetIsolate(), i));
2869 } 2874 }
2870 2875
2871 // Call function without any break points to ensure inlining is in place. 2876 // Call function without any break points to ensure inlining is in place.
2872 const int kArgc = 1; 2877 const int kArgc = 1;
2873 v8::Handle<v8::Value> args[kArgc] = { a }; 2878 v8::Handle<v8::Value> args[kArgc] = { a };
2874 foo->Call(env->Global(), kArgc, args); 2879 foo->Call(env->Global(), kArgc, args);
2875 2880
2876 // Set up break point and step through the function. 2881 // Set up break point and step through the function.
2877 SetBreakPoint(foo, 3); 2882 SetBreakPoint(foo, 3);
2878 step_action = StepNext; 2883 step_action = StepNext;
(...skipping 26 matching lines...) Expand all
2905 " y = 1;\n" 2910 " y = 1;\n"
2906 " a[i] = 42;\n" 2911 " a[i] = 42;\n"
2907 " }\n" 2912 " }\n"
2908 "}\n" 2913 "}\n"
2909 "y=0\n", 2914 "y=0\n",
2910 "foo"); 2915 "foo");
2911 2916
2912 // Create array [0,1,2,3,4,5,6,7,8,9] 2917 // Create array [0,1,2,3,4,5,6,7,8,9]
2913 v8::Local<v8::Array> a = v8::Array::New(env->GetIsolate(), 10); 2918 v8::Local<v8::Array> a = v8::Array::New(env->GetIsolate(), 10);
2914 for (int i = 0; i < 10; i++) { 2919 for (int i = 0; i < 10; i++) {
2915 a->Set(v8::Number::New(i), v8::Number::New(i)); 2920 a->Set(v8::Number::New(env->GetIsolate(), i),
2921 v8::Number::New(env->GetIsolate(), i));
2916 } 2922 }
2917 2923
2918 // Call function without any break points to ensure inlining is in place. 2924 // Call function without any break points to ensure inlining is in place.
2919 const int kArgc = 1; 2925 const int kArgc = 1;
2920 v8::Handle<v8::Value> args[kArgc] = { a }; 2926 v8::Handle<v8::Value> args[kArgc] = { a };
2921 foo->Call(env->Global(), kArgc, args); 2927 foo->Call(env->Global(), kArgc, args);
2922 2928
2923 // Set up break point and step through the function. 2929 // Set up break point and step through the function.
2924 SetBreakPoint(foo, 3); 2930 SetBreakPoint(foo, 3);
2925 step_action = StepNext; 2931 step_action = StepNext;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
3171 CHECK_EQ(5, break_point_hit_count); 3177 CHECK_EQ(5, break_point_hit_count);
3172 3178
3173 // Get rid of the debug event listener. 3179 // Get rid of the debug event listener.
3174 v8::Debug::SetDebugEventListener2(NULL); 3180 v8::Debug::SetDebugEventListener2(NULL);
3175 CheckDebuggerUnloaded(); 3181 CheckDebuggerUnloaded();
3176 } 3182 }
3177 3183
3178 3184
3179 TEST(DebugStepSwitch) { 3185 TEST(DebugStepSwitch) {
3180 DebugLocalContext env; 3186 DebugLocalContext env;
3181 v8::HandleScope scope(env->GetIsolate()); 3187 v8::Isolate* isolate = env->GetIsolate();
3188 v8::HandleScope scope(isolate);
3182 3189
3183 // Register a debug event listener which steps and counts. 3190 // Register a debug event listener which steps and counts.
3184 v8::Debug::SetDebugEventListener2(DebugEventStep); 3191 v8::Debug::SetDebugEventListener2(DebugEventStep);
3185 3192
3186 // Create a function for testing stepping. Run it to allow it to get 3193 // Create a function for testing stepping. Run it to allow it to get
3187 // optimized. 3194 // optimized.
3188 const int argc = 1; 3195 const int argc = 1;
3189 const char* src = "function foo(x) { " 3196 const char* src = "function foo(x) { "
3190 " a = 1;" 3197 " a = 1;"
3191 " switch (x) {" 3198 " switch (x) {"
3192 " case 1:" 3199 " case 1:"
3193 " b = 1;" 3200 " b = 1;"
3194 " case 2:" 3201 " case 2:"
3195 " c = 1;" 3202 " c = 1;"
3196 " break;" 3203 " break;"
3197 " case 3:" 3204 " case 3:"
3198 " d = 1;" 3205 " d = 1;"
3199 " e = 1;" 3206 " e = 1;"
3200 " f = 1;" 3207 " f = 1;"
3201 " break;" 3208 " break;"
3202 " }" 3209 " }"
3203 "}" 3210 "}"
3204 "a=0; b=0; c=0; d=0; e=0; f=0; foo()"; 3211 "a=0; b=0; c=0; d=0; e=0; f=0; foo()";
3205 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3212 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3206 SetBreakPoint(foo, 0); 3213 SetBreakPoint(foo, 0);
3207 3214
3208 // One case with fall-through. 3215 // One case with fall-through.
3209 step_action = StepIn; 3216 step_action = StepIn;
3210 break_point_hit_count = 0; 3217 break_point_hit_count = 0;
3211 v8::Handle<v8::Value> argv_1[argc] = { v8::Number::New(1) }; 3218 v8::Handle<v8::Value> argv_1[argc] = { v8::Number::New(isolate, 1) };
3212 foo->Call(env->Global(), argc, argv_1); 3219 foo->Call(env->Global(), argc, argv_1);
3213 CHECK_EQ(6, break_point_hit_count); 3220 CHECK_EQ(6, break_point_hit_count);
3214 3221
3215 // Another case. 3222 // Another case.
3216 step_action = StepIn; 3223 step_action = StepIn;
3217 break_point_hit_count = 0; 3224 break_point_hit_count = 0;
3218 v8::Handle<v8::Value> argv_2[argc] = { v8::Number::New(2) }; 3225 v8::Handle<v8::Value> argv_2[argc] = { v8::Number::New(isolate, 2) };
3219 foo->Call(env->Global(), argc, argv_2); 3226 foo->Call(env->Global(), argc, argv_2);
3220 CHECK_EQ(5, break_point_hit_count); 3227 CHECK_EQ(5, break_point_hit_count);
3221 3228
3222 // Last case. 3229 // Last case.
3223 step_action = StepIn; 3230 step_action = StepIn;
3224 break_point_hit_count = 0; 3231 break_point_hit_count = 0;
3225 v8::Handle<v8::Value> argv_3[argc] = { v8::Number::New(3) }; 3232 v8::Handle<v8::Value> argv_3[argc] = { v8::Number::New(isolate, 3) };
3226 foo->Call(env->Global(), argc, argv_3); 3233 foo->Call(env->Global(), argc, argv_3);
3227 CHECK_EQ(7, break_point_hit_count); 3234 CHECK_EQ(7, break_point_hit_count);
3228 3235
3229 // Get rid of the debug event listener. 3236 // Get rid of the debug event listener.
3230 v8::Debug::SetDebugEventListener2(NULL); 3237 v8::Debug::SetDebugEventListener2(NULL);
3231 CheckDebuggerUnloaded(); 3238 CheckDebuggerUnloaded();
3232 } 3239 }
3233 3240
3234 3241
3235 TEST(DebugStepWhile) { 3242 TEST(DebugStepWhile) {
3236 DebugLocalContext env; 3243 DebugLocalContext env;
3237 v8::HandleScope scope(env->GetIsolate()); 3244 v8::Isolate* isolate = env->GetIsolate();
3245 v8::HandleScope scope(isolate);
3238 3246
3239 // Register a debug event listener which steps and counts. 3247 // Register a debug event listener which steps and counts.
3240 v8::Debug::SetDebugEventListener2(DebugEventStep); 3248 v8::Debug::SetDebugEventListener2(DebugEventStep);
3241 3249
3242 // Create a function for testing stepping. Run it to allow it to get 3250 // Create a function for testing stepping. Run it to allow it to get
3243 // optimized. 3251 // optimized.
3244 const int argc = 1; 3252 const int argc = 1;
3245 const char* src = "function foo(x) { " 3253 const char* src = "function foo(x) { "
3246 " var a = 0;" 3254 " var a = 0;"
3247 " while (a < x) {" 3255 " while (a < x) {"
3248 " a++;" 3256 " a++;"
3249 " }" 3257 " }"
3250 "}" 3258 "}"
3251 "foo()"; 3259 "foo()";
3252 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3260 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3253 SetBreakPoint(foo, 8); // "var a = 0;" 3261 SetBreakPoint(foo, 8); // "var a = 0;"
3254 3262
3255 // Looping 10 times. 3263 // Looping 10 times.
3256 step_action = StepIn; 3264 step_action = StepIn;
3257 break_point_hit_count = 0; 3265 break_point_hit_count = 0;
3258 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) }; 3266 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
3259 foo->Call(env->Global(), argc, argv_10); 3267 foo->Call(env->Global(), argc, argv_10);
3260 CHECK_EQ(22, break_point_hit_count); 3268 CHECK_EQ(22, break_point_hit_count);
3261 3269
3262 // Looping 100 times. 3270 // Looping 100 times.
3263 step_action = StepIn; 3271 step_action = StepIn;
3264 break_point_hit_count = 0; 3272 break_point_hit_count = 0;
3265 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) }; 3273 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
3266 foo->Call(env->Global(), argc, argv_100); 3274 foo->Call(env->Global(), argc, argv_100);
3267 CHECK_EQ(202, break_point_hit_count); 3275 CHECK_EQ(202, break_point_hit_count);
3268 3276
3269 // Get rid of the debug event listener. 3277 // Get rid of the debug event listener.
3270 v8::Debug::SetDebugEventListener2(NULL); 3278 v8::Debug::SetDebugEventListener2(NULL);
3271 CheckDebuggerUnloaded(); 3279 CheckDebuggerUnloaded();
3272 } 3280 }
3273 3281
3274 3282
3275 TEST(DebugStepDoWhile) { 3283 TEST(DebugStepDoWhile) {
3276 DebugLocalContext env; 3284 DebugLocalContext env;
3277 v8::HandleScope scope(env->GetIsolate()); 3285 v8::Isolate* isolate = env->GetIsolate();
3286 v8::HandleScope scope(isolate);
3278 3287
3279 // Register a debug event listener which steps and counts. 3288 // Register a debug event listener which steps and counts.
3280 v8::Debug::SetDebugEventListener2(DebugEventStep); 3289 v8::Debug::SetDebugEventListener2(DebugEventStep);
3281 3290
3282 // Create a function for testing stepping. Run it to allow it to get 3291 // Create a function for testing stepping. Run it to allow it to get
3283 // optimized. 3292 // optimized.
3284 const int argc = 1; 3293 const int argc = 1;
3285 const char* src = "function foo(x) { " 3294 const char* src = "function foo(x) { "
3286 " var a = 0;" 3295 " var a = 0;"
3287 " do {" 3296 " do {"
3288 " a++;" 3297 " a++;"
3289 " } while (a < x)" 3298 " } while (a < x)"
3290 "}" 3299 "}"
3291 "foo()"; 3300 "foo()";
3292 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3301 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3293 SetBreakPoint(foo, 8); // "var a = 0;" 3302 SetBreakPoint(foo, 8); // "var a = 0;"
3294 3303
3295 // Looping 10 times. 3304 // Looping 10 times.
3296 step_action = StepIn; 3305 step_action = StepIn;
3297 break_point_hit_count = 0; 3306 break_point_hit_count = 0;
3298 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) }; 3307 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
3299 foo->Call(env->Global(), argc, argv_10); 3308 foo->Call(env->Global(), argc, argv_10);
3300 CHECK_EQ(22, break_point_hit_count); 3309 CHECK_EQ(22, break_point_hit_count);
3301 3310
3302 // Looping 100 times. 3311 // Looping 100 times.
3303 step_action = StepIn; 3312 step_action = StepIn;
3304 break_point_hit_count = 0; 3313 break_point_hit_count = 0;
3305 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) }; 3314 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
3306 foo->Call(env->Global(), argc, argv_100); 3315 foo->Call(env->Global(), argc, argv_100);
3307 CHECK_EQ(202, break_point_hit_count); 3316 CHECK_EQ(202, break_point_hit_count);
3308 3317
3309 // Get rid of the debug event listener. 3318 // Get rid of the debug event listener.
3310 v8::Debug::SetDebugEventListener2(NULL); 3319 v8::Debug::SetDebugEventListener2(NULL);
3311 CheckDebuggerUnloaded(); 3320 CheckDebuggerUnloaded();
3312 } 3321 }
3313 3322
3314 3323
3315 TEST(DebugStepFor) { 3324 TEST(DebugStepFor) {
3316 DebugLocalContext env; 3325 DebugLocalContext env;
3317 v8::HandleScope scope(env->GetIsolate()); 3326 v8::Isolate* isolate = env->GetIsolate();
3327 v8::HandleScope scope(isolate);
3318 3328
3319 // Register a debug event listener which steps and counts. 3329 // Register a debug event listener which steps and counts.
3320 v8::Debug::SetDebugEventListener2(DebugEventStep); 3330 v8::Debug::SetDebugEventListener2(DebugEventStep);
3321 3331
3322 // Create a function for testing stepping. Run it to allow it to get 3332 // Create a function for testing stepping. Run it to allow it to get
3323 // optimized. 3333 // optimized.
3324 const int argc = 1; 3334 const int argc = 1;
3325 const char* src = "function foo(x) { " 3335 const char* src = "function foo(x) { "
3326 " a = 1;" 3336 " a = 1;"
3327 " for (i = 0; i < x; i++) {" 3337 " for (i = 0; i < x; i++) {"
3328 " b = 1;" 3338 " b = 1;"
3329 " }" 3339 " }"
3330 "}" 3340 "}"
3331 "a=0; b=0; i=0; foo()"; 3341 "a=0; b=0; i=0; foo()";
3332 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3342 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3333 3343
3334 SetBreakPoint(foo, 8); // "a = 1;" 3344 SetBreakPoint(foo, 8); // "a = 1;"
3335 3345
3336 // Looping 10 times. 3346 // Looping 10 times.
3337 step_action = StepIn; 3347 step_action = StepIn;
3338 break_point_hit_count = 0; 3348 break_point_hit_count = 0;
3339 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) }; 3349 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
3340 foo->Call(env->Global(), argc, argv_10); 3350 foo->Call(env->Global(), argc, argv_10);
3341 CHECK_EQ(23, break_point_hit_count); 3351 CHECK_EQ(23, break_point_hit_count);
3342 3352
3343 // Looping 100 times. 3353 // Looping 100 times.
3344 step_action = StepIn; 3354 step_action = StepIn;
3345 break_point_hit_count = 0; 3355 break_point_hit_count = 0;
3346 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) }; 3356 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
3347 foo->Call(env->Global(), argc, argv_100); 3357 foo->Call(env->Global(), argc, argv_100);
3348 CHECK_EQ(203, break_point_hit_count); 3358 CHECK_EQ(203, break_point_hit_count);
3349 3359
3350 // Get rid of the debug event listener. 3360 // Get rid of the debug event listener.
3351 v8::Debug::SetDebugEventListener2(NULL); 3361 v8::Debug::SetDebugEventListener2(NULL);
3352 CheckDebuggerUnloaded(); 3362 CheckDebuggerUnloaded();
3353 } 3363 }
3354 3364
3355 3365
3356 TEST(DebugStepForContinue) { 3366 TEST(DebugStepForContinue) {
3357 DebugLocalContext env; 3367 DebugLocalContext env;
3358 v8::HandleScope scope(env->GetIsolate()); 3368 v8::Isolate* isolate = env->GetIsolate();
3369 v8::HandleScope scope(isolate);
3359 3370
3360 // Register a debug event listener which steps and counts. 3371 // Register a debug event listener which steps and counts.
3361 v8::Debug::SetDebugEventListener2(DebugEventStep); 3372 v8::Debug::SetDebugEventListener2(DebugEventStep);
3362 3373
3363 // Create a function for testing stepping. Run it to allow it to get 3374 // Create a function for testing stepping. Run it to allow it to get
3364 // optimized. 3375 // optimized.
3365 const int argc = 1; 3376 const int argc = 1;
3366 const char* src = "function foo(x) { " 3377 const char* src = "function foo(x) { "
3367 " var a = 0;" 3378 " var a = 0;"
3368 " var b = 0;" 3379 " var b = 0;"
3369 " var c = 0;" 3380 " var c = 0;"
3370 " for (var i = 0; i < x; i++) {" 3381 " for (var i = 0; i < x; i++) {"
3371 " a++;" 3382 " a++;"
3372 " if (a % 2 == 0) continue;" 3383 " if (a % 2 == 0) continue;"
3373 " b++;" 3384 " b++;"
3374 " c++;" 3385 " c++;"
3375 " }" 3386 " }"
3376 " return b;" 3387 " return b;"
3377 "}" 3388 "}"
3378 "foo()"; 3389 "foo()";
3379 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3390 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3380 v8::Handle<v8::Value> result; 3391 v8::Handle<v8::Value> result;
3381 SetBreakPoint(foo, 8); // "var a = 0;" 3392 SetBreakPoint(foo, 8); // "var a = 0;"
3382 3393
3383 // Each loop generates 4 or 5 steps depending on whether a is equal. 3394 // Each loop generates 4 or 5 steps depending on whether a is equal.
3384 3395
3385 // Looping 10 times. 3396 // Looping 10 times.
3386 step_action = StepIn; 3397 step_action = StepIn;
3387 break_point_hit_count = 0; 3398 break_point_hit_count = 0;
3388 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) }; 3399 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
3389 result = foo->Call(env->Global(), argc, argv_10); 3400 result = foo->Call(env->Global(), argc, argv_10);
3390 CHECK_EQ(5, result->Int32Value()); 3401 CHECK_EQ(5, result->Int32Value());
3391 CHECK_EQ(52, break_point_hit_count); 3402 CHECK_EQ(52, break_point_hit_count);
3392 3403
3393 // Looping 100 times. 3404 // Looping 100 times.
3394 step_action = StepIn; 3405 step_action = StepIn;
3395 break_point_hit_count = 0; 3406 break_point_hit_count = 0;
3396 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) }; 3407 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
3397 result = foo->Call(env->Global(), argc, argv_100); 3408 result = foo->Call(env->Global(), argc, argv_100);
3398 CHECK_EQ(50, result->Int32Value()); 3409 CHECK_EQ(50, result->Int32Value());
3399 CHECK_EQ(457, break_point_hit_count); 3410 CHECK_EQ(457, break_point_hit_count);
3400 3411
3401 // Get rid of the debug event listener. 3412 // Get rid of the debug event listener.
3402 v8::Debug::SetDebugEventListener2(NULL); 3413 v8::Debug::SetDebugEventListener2(NULL);
3403 CheckDebuggerUnloaded(); 3414 CheckDebuggerUnloaded();
3404 } 3415 }
3405 3416
3406 3417
3407 TEST(DebugStepForBreak) { 3418 TEST(DebugStepForBreak) {
3408 DebugLocalContext env; 3419 DebugLocalContext env;
3409 v8::HandleScope scope(env->GetIsolate()); 3420 v8::Isolate* isolate = env->GetIsolate();
3421 v8::HandleScope scope(isolate);
3410 3422
3411 // Register a debug event listener which steps and counts. 3423 // Register a debug event listener which steps and counts.
3412 v8::Debug::SetDebugEventListener2(DebugEventStep); 3424 v8::Debug::SetDebugEventListener2(DebugEventStep);
3413 3425
3414 // Create a function for testing stepping. Run it to allow it to get 3426 // Create a function for testing stepping. Run it to allow it to get
3415 // optimized. 3427 // optimized.
3416 const int argc = 1; 3428 const int argc = 1;
3417 const char* src = "function foo(x) { " 3429 const char* src = "function foo(x) { "
3418 " var a = 0;" 3430 " var a = 0;"
3419 " var b = 0;" 3431 " var b = 0;"
(...skipping 10 matching lines...) Expand all
3430 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3442 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3431 v8::Handle<v8::Value> result; 3443 v8::Handle<v8::Value> result;
3432 SetBreakPoint(foo, 8); // "var a = 0;" 3444 SetBreakPoint(foo, 8); // "var a = 0;"
3433 3445
3434 // Each loop generates 5 steps except for the last (when break is executed) 3446 // Each loop generates 5 steps except for the last (when break is executed)
3435 // which only generates 4. 3447 // which only generates 4.
3436 3448
3437 // Looping 10 times. 3449 // Looping 10 times.
3438 step_action = StepIn; 3450 step_action = StepIn;
3439 break_point_hit_count = 0; 3451 break_point_hit_count = 0;
3440 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) }; 3452 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
3441 result = foo->Call(env->Global(), argc, argv_10); 3453 result = foo->Call(env->Global(), argc, argv_10);
3442 CHECK_EQ(9, result->Int32Value()); 3454 CHECK_EQ(9, result->Int32Value());
3443 CHECK_EQ(55, break_point_hit_count); 3455 CHECK_EQ(55, break_point_hit_count);
3444 3456
3445 // Looping 100 times. 3457 // Looping 100 times.
3446 step_action = StepIn; 3458 step_action = StepIn;
3447 break_point_hit_count = 0; 3459 break_point_hit_count = 0;
3448 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) }; 3460 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
3449 result = foo->Call(env->Global(), argc, argv_100); 3461 result = foo->Call(env->Global(), argc, argv_100);
3450 CHECK_EQ(99, result->Int32Value()); 3462 CHECK_EQ(99, result->Int32Value());
3451 CHECK_EQ(505, break_point_hit_count); 3463 CHECK_EQ(505, break_point_hit_count);
3452 3464
3453 // Get rid of the debug event listener. 3465 // Get rid of the debug event listener.
3454 v8::Debug::SetDebugEventListener2(NULL); 3466 v8::Debug::SetDebugEventListener2(NULL);
3455 CheckDebuggerUnloaded(); 3467 CheckDebuggerUnloaded();
3456 } 3468 }
3457 3469
3458 3470
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3513 3525
3514 // Create a function for testing stepping. Run it to allow it to get 3526 // Create a function for testing stepping. Run it to allow it to get
3515 // optimized. 3527 // optimized.
3516 const char* src = "function foo(x) { " 3528 const char* src = "function foo(x) { "
3517 " var a = {};" 3529 " var a = {};"
3518 " with (a) {}" 3530 " with (a) {}"
3519 " with (b) {}" 3531 " with (b) {}"
3520 "}" 3532 "}"
3521 "foo()"; 3533 "foo()";
3522 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "b"), 3534 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "b"),
3523 v8::Object::New()); 3535 v8::Object::New(env->GetIsolate()));
3524 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3536 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3525 v8::Handle<v8::Value> result; 3537 v8::Handle<v8::Value> result;
3526 SetBreakPoint(foo, 8); // "var a = {};" 3538 SetBreakPoint(foo, 8); // "var a = {};"
3527 3539
3528 step_action = StepIn; 3540 step_action = StepIn;
3529 break_point_hit_count = 0; 3541 break_point_hit_count = 0;
3530 foo->Call(env->Global(), 0, NULL); 3542 foo->Call(env->Global(), 0, NULL);
3531 CHECK_EQ(4, break_point_hit_count); 3543 CHECK_EQ(4, break_point_hit_count);
3532 3544
3533 // Get rid of the debug event listener. 3545 // Get rid of the debug event listener.
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
3852 // Create a script that returns a function. 3864 // Create a script that returns a function.
3853 const char* src = "(function (evt) {})"; 3865 const char* src = "(function (evt) {})";
3854 const char* script_name = "StepInHandlerTest"; 3866 const char* script_name = "StepInHandlerTest";
3855 3867
3856 // Set breakpoint in the script. 3868 // Set breakpoint in the script.
3857 SetScriptBreakPointByNameFromJS(env->GetIsolate(), script_name, 0, -1); 3869 SetScriptBreakPointByNameFromJS(env->GetIsolate(), script_name, 0, -1);
3858 break_point_hit_count = 0; 3870 break_point_hit_count = 0;
3859 3871
3860 v8::ScriptOrigin origin( 3872 v8::ScriptOrigin origin(
3861 v8::String::NewFromUtf8(env->GetIsolate(), script_name), 3873 v8::String::NewFromUtf8(env->GetIsolate(), script_name),
3862 v8::Integer::New(0)); 3874 v8::Integer::New(env->GetIsolate(), 0));
3863 v8::Handle<v8::Script> script = v8::Script::Compile( 3875 v8::Handle<v8::Script> script = v8::Script::Compile(
3864 v8::String::NewFromUtf8(env->GetIsolate(), src), &origin); 3876 v8::String::NewFromUtf8(env->GetIsolate(), src), &origin);
3865 v8::Local<v8::Value> r = script->Run(); 3877 v8::Local<v8::Value> r = script->Run();
3866 3878
3867 CHECK(r->IsFunction()); 3879 CHECK(r->IsFunction());
3868 CHECK_EQ(1, break_point_hit_count); 3880 CHECK_EQ(1, break_point_hit_count);
3869 3881
3870 // Get rid of the debug event listener. 3882 // Get rid of the debug event listener.
3871 v8::Debug::SetDebugEventListener2(NULL); 3883 v8::Debug::SetDebugEventListener2(NULL);
3872 CheckDebuggerUnloaded(); 3884 CheckDebuggerUnloaded();
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
4164 CheckDebuggerUnloaded(); 4176 CheckDebuggerUnloaded();
4165 } 4177 }
4166 4178
4167 4179
4168 TEST(DebugBreak) { 4180 TEST(DebugBreak) {
4169 i::FLAG_stress_compaction = false; 4181 i::FLAG_stress_compaction = false;
4170 #ifdef VERIFY_HEAP 4182 #ifdef VERIFY_HEAP
4171 i::FLAG_verify_heap = true; 4183 i::FLAG_verify_heap = true;
4172 #endif 4184 #endif
4173 DebugLocalContext env; 4185 DebugLocalContext env;
4174 v8::HandleScope scope(env->GetIsolate()); 4186 v8::Isolate* isolate = env->GetIsolate();
4187 v8::HandleScope scope(isolate);
4175 4188
4176 // Register a debug event listener which sets the break flag and counts. 4189 // Register a debug event listener which sets the break flag and counts.
4177 v8::Debug::SetDebugEventListener2(DebugEventBreak); 4190 v8::Debug::SetDebugEventListener2(DebugEventBreak);
4178 4191
4179 // Create a function for testing stepping. 4192 // Create a function for testing stepping.
4180 const char* src = "function f0() {}" 4193 const char* src = "function f0() {}"
4181 "function f1(x1) {}" 4194 "function f1(x1) {}"
4182 "function f2(x1,x2) {}" 4195 "function f2(x1,x2) {}"
4183 "function f3(x1,x2,x3) {}"; 4196 "function f3(x1,x2,x3) {}";
4184 v8::Local<v8::Function> f0 = CompileFunction(&env, src, "f0"); 4197 v8::Local<v8::Function> f0 = CompileFunction(&env, src, "f0");
4185 v8::Local<v8::Function> f1 = CompileFunction(&env, src, "f1"); 4198 v8::Local<v8::Function> f1 = CompileFunction(&env, src, "f1");
4186 v8::Local<v8::Function> f2 = CompileFunction(&env, src, "f2"); 4199 v8::Local<v8::Function> f2 = CompileFunction(&env, src, "f2");
4187 v8::Local<v8::Function> f3 = CompileFunction(&env, src, "f3"); 4200 v8::Local<v8::Function> f3 = CompileFunction(&env, src, "f3");
4188 4201
4189 // Call the function to make sure it is compiled. 4202 // Call the function to make sure it is compiled.
4190 v8::Handle<v8::Value> argv[] = { v8::Number::New(1), 4203 v8::Handle<v8::Value> argv[] = { v8::Number::New(isolate, 1),
4191 v8::Number::New(1), 4204 v8::Number::New(isolate, 1),
4192 v8::Number::New(1), 4205 v8::Number::New(isolate, 1),
4193 v8::Number::New(1) }; 4206 v8::Number::New(isolate, 1) };
4194 4207
4195 // Call all functions to make sure that they are compiled. 4208 // Call all functions to make sure that they are compiled.
4196 f0->Call(env->Global(), 0, NULL); 4209 f0->Call(env->Global(), 0, NULL);
4197 f1->Call(env->Global(), 0, NULL); 4210 f1->Call(env->Global(), 0, NULL);
4198 f2->Call(env->Global(), 0, NULL); 4211 f2->Call(env->Global(), 0, NULL);
4199 f3->Call(env->Global(), 0, NULL); 4212 f3->Call(env->Global(), 0, NULL);
4200 4213
4201 // Set the debug break flag. 4214 // Set the debug break flag.
4202 v8::Debug::DebugBreak(env->GetIsolate()); 4215 v8::Debug::DebugBreak(env->GetIsolate());
4203 4216
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
4287 CHECK_EQ(0, break_point_hit_count); 4300 CHECK_EQ(0, break_point_hit_count);
4288 4301
4289 // Get rid of the debug event listener. 4302 // Get rid of the debug event listener.
4290 v8::Debug::SetDebugEventListener2(NULL); 4303 v8::Debug::SetDebugEventListener2(NULL);
4291 CheckDebuggerUnloaded(); 4304 CheckDebuggerUnloaded();
4292 } 4305 }
4293 4306
4294 4307
4295 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { 4308 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
4296 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 3); 4309 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 3);
4297 result->Set(v8::Integer::New(0), 4310 result->Set(v8::Integer::New(info.GetIsolate(), 0),
4298 v8::String::NewFromUtf8(info.GetIsolate(), "a")); 4311 v8::String::NewFromUtf8(info.GetIsolate(), "a"));
4299 result->Set(v8::Integer::New(1), 4312 result->Set(v8::Integer::New(info.GetIsolate(), 1),
4300 v8::String::NewFromUtf8(info.GetIsolate(), "b")); 4313 v8::String::NewFromUtf8(info.GetIsolate(), "b"));
4301 result->Set(v8::Integer::New(2), 4314 result->Set(v8::Integer::New(info.GetIsolate(), 2),
4302 v8::String::NewFromUtf8(info.GetIsolate(), "c")); 4315 v8::String::NewFromUtf8(info.GetIsolate(), "c"));
4303 info.GetReturnValue().Set(result); 4316 info.GetReturnValue().Set(result);
4304 } 4317 }
4305 4318
4306 4319
4307 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { 4320 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
4308 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); 4321 v8::Isolate* isolate = info.GetIsolate();
4309 result->Set(v8::Integer::New(0), v8::Number::New(1)); 4322 v8::Handle<v8::Array> result = v8::Array::New(isolate, 2);
4310 result->Set(v8::Integer::New(1), v8::Number::New(10)); 4323 result->Set(v8::Integer::New(isolate, 0), v8::Number::New(isolate, 1));
4324 result->Set(v8::Integer::New(isolate, 1), v8::Number::New(isolate, 10));
4311 info.GetReturnValue().Set(result); 4325 info.GetReturnValue().Set(result);
4312 } 4326 }
4313 4327
4314 4328
4315 static void NamedGetter(v8::Local<v8::String> name, 4329 static void NamedGetter(v8::Local<v8::String> name,
4316 const v8::PropertyCallbackInfo<v8::Value>& info) { 4330 const v8::PropertyCallbackInfo<v8::Value>& info) {
4317 v8::String::Utf8Value n(name); 4331 v8::String::Utf8Value n(name);
4318 if (strcmp(*n, "a") == 0) { 4332 if (strcmp(*n, "a") == 0) {
4319 info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "AA")); 4333 info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "AA"));
4320 return; 4334 return;
(...skipping 13 matching lines...) Expand all
4334 4348
4335 static void IndexedGetter(uint32_t index, 4349 static void IndexedGetter(uint32_t index,
4336 const v8::PropertyCallbackInfo<v8::Value>& info) { 4350 const v8::PropertyCallbackInfo<v8::Value>& info) {
4337 info.GetReturnValue().Set(static_cast<double>(index + 1)); 4351 info.GetReturnValue().Set(static_cast<double>(index + 1));
4338 } 4352 }
4339 4353
4340 4354
4341 TEST(InterceptorPropertyMirror) { 4355 TEST(InterceptorPropertyMirror) {
4342 // Create a V8 environment with debug access. 4356 // Create a V8 environment with debug access.
4343 DebugLocalContext env; 4357 DebugLocalContext env;
4344 v8::HandleScope scope(env->GetIsolate()); 4358 v8::Isolate* isolate = env->GetIsolate();
4359 v8::HandleScope scope(isolate);
4345 env.ExposeDebug(); 4360 env.ExposeDebug();
4346 4361
4347 // Create object with named interceptor. 4362 // Create object with named interceptor.
4348 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); 4363 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
4349 named->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum); 4364 named->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum);
4350 env->Global()->Set( 4365 env->Global()->Set(
4351 v8::String::NewFromUtf8(env->GetIsolate(), "intercepted_named"), 4366 v8::String::NewFromUtf8(isolate, "intercepted_named"),
4352 named->NewInstance()); 4367 named->NewInstance());
4353 4368
4354 // Create object with indexed interceptor. 4369 // Create object with indexed interceptor.
4355 v8::Handle<v8::ObjectTemplate> indexed = v8::ObjectTemplate::New(); 4370 v8::Handle<v8::ObjectTemplate> indexed = v8::ObjectTemplate::New(isolate);
4356 indexed->SetIndexedPropertyHandler(IndexedGetter, 4371 indexed->SetIndexedPropertyHandler(IndexedGetter,
4357 NULL, 4372 NULL,
4358 NULL, 4373 NULL,
4359 NULL, 4374 NULL,
4360 IndexedEnum); 4375 IndexedEnum);
4361 env->Global()->Set( 4376 env->Global()->Set(
4362 v8::String::NewFromUtf8(env->GetIsolate(), "intercepted_indexed"), 4377 v8::String::NewFromUtf8(isolate, "intercepted_indexed"),
4363 indexed->NewInstance()); 4378 indexed->NewInstance());
4364 4379
4365 // Create object with both named and indexed interceptor. 4380 // Create object with both named and indexed interceptor.
4366 v8::Handle<v8::ObjectTemplate> both = v8::ObjectTemplate::New(); 4381 v8::Handle<v8::ObjectTemplate> both = v8::ObjectTemplate::New(isolate);
4367 both->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum); 4382 both->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum);
4368 both->SetIndexedPropertyHandler(IndexedGetter, NULL, NULL, NULL, IndexedEnum); 4383 both->SetIndexedPropertyHandler(IndexedGetter, NULL, NULL, NULL, IndexedEnum);
4369 env->Global()->Set( 4384 env->Global()->Set(
4370 v8::String::NewFromUtf8(env->GetIsolate(), "intercepted_both"), 4385 v8::String::NewFromUtf8(isolate, "intercepted_both"),
4371 both->NewInstance()); 4386 both->NewInstance());
4372 4387
4373 // Get mirrors for the three objects with interceptor. 4388 // Get mirrors for the three objects with interceptor.
4374 CompileRun( 4389 CompileRun(
4375 "var named_mirror = debug.MakeMirror(intercepted_named);" 4390 "var named_mirror = debug.MakeMirror(intercepted_named);"
4376 "var indexed_mirror = debug.MakeMirror(intercepted_indexed);" 4391 "var indexed_mirror = debug.MakeMirror(intercepted_indexed);"
4377 "var both_mirror = debug.MakeMirror(intercepted_both)"); 4392 "var both_mirror = debug.MakeMirror(intercepted_both)");
4378 CHECK(CompileRun( 4393 CHECK(CompileRun(
4379 "named_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4394 "named_mirror instanceof debug.ObjectMirror")->BooleanValue());
4380 CHECK(CompileRun( 4395 CHECK(CompileRun(
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
4475 4490
4476 TEST(HiddenPrototypePropertyMirror) { 4491 TEST(HiddenPrototypePropertyMirror) {
4477 // Create a V8 environment with debug access. 4492 // Create a V8 environment with debug access.
4478 DebugLocalContext env; 4493 DebugLocalContext env;
4479 v8::Isolate* isolate = env->GetIsolate(); 4494 v8::Isolate* isolate = env->GetIsolate();
4480 v8::HandleScope scope(isolate); 4495 v8::HandleScope scope(isolate);
4481 env.ExposeDebug(); 4496 env.ExposeDebug();
4482 4497
4483 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate); 4498 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
4484 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "x"), 4499 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "x"),
4485 v8::Number::New(0)); 4500 v8::Number::New(isolate, 0));
4486 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); 4501 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
4487 t1->SetHiddenPrototype(true); 4502 t1->SetHiddenPrototype(true);
4488 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "y"), 4503 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "y"),
4489 v8::Number::New(1)); 4504 v8::Number::New(isolate, 1));
4490 v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate); 4505 v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate);
4491 t2->SetHiddenPrototype(true); 4506 t2->SetHiddenPrototype(true);
4492 t2->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "z"), 4507 t2->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "z"),
4493 v8::Number::New(2)); 4508 v8::Number::New(isolate, 2));
4494 v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate); 4509 v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate);
4495 t3->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "u"), 4510 t3->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "u"),
4496 v8::Number::New(3)); 4511 v8::Number::New(isolate, 3));
4497 4512
4498 // Create object and set them on the global object. 4513 // Create object and set them on the global object.
4499 v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance(); 4514 v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance();
4500 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o0"), o0); 4515 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o0"), o0);
4501 v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance(); 4516 v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance();
4502 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o1"), o1); 4517 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o1"), o1);
4503 v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance(); 4518 v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance();
4504 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o2"), o2); 4519 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o2"), o2);
4505 v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance(); 4520 v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance();
4506 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o3"), o3); 4521 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o3"), o3);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
4576 static void ProtperyXNativeGetter( 4591 static void ProtperyXNativeGetter(
4577 v8::Local<v8::String> property, 4592 v8::Local<v8::String> property,
4578 const v8::PropertyCallbackInfo<v8::Value>& info) { 4593 const v8::PropertyCallbackInfo<v8::Value>& info) {
4579 info.GetReturnValue().Set(10); 4594 info.GetReturnValue().Set(10);
4580 } 4595 }
4581 4596
4582 4597
4583 TEST(NativeGetterPropertyMirror) { 4598 TEST(NativeGetterPropertyMirror) {
4584 // Create a V8 environment with debug access. 4599 // Create a V8 environment with debug access.
4585 DebugLocalContext env; 4600 DebugLocalContext env;
4586 v8::HandleScope scope(env->GetIsolate()); 4601 v8::Isolate* isolate = env->GetIsolate();
4602 v8::HandleScope scope(isolate);
4587 env.ExposeDebug(); 4603 env.ExposeDebug();
4588 4604
4589 v8::Handle<v8::String> name = v8::String::NewFromUtf8(env->GetIsolate(), "x"); 4605 v8::Handle<v8::String> name = v8::String::NewFromUtf8(isolate, "x");
4590 // Create object with named accessor. 4606 // Create object with named accessor.
4591 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); 4607 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
4592 named->SetAccessor(name, &ProtperyXNativeGetter, NULL, 4608 named->SetAccessor(name, &ProtperyXNativeGetter, NULL,
4593 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None); 4609 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None);
4594 4610
4595 // Create object with named property getter. 4611 // Create object with named property getter.
4596 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"), 4612 env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
4597 named->NewInstance()); 4613 named->NewInstance());
4598 CHECK_EQ(10, CompileRun("instance.x")->Int32Value()); 4614 CHECK_EQ(10, CompileRun("instance.x")->Int32Value());
4599 4615
4600 // Get mirror for the object with property getter. 4616 // Get mirror for the object with property getter.
4601 CompileRun("var instance_mirror = debug.MakeMirror(instance);"); 4617 CompileRun("var instance_mirror = debug.MakeMirror(instance);");
4602 CHECK(CompileRun( 4618 CHECK(CompileRun(
4603 "instance_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4619 "instance_mirror instanceof debug.ObjectMirror")->BooleanValue());
4604 4620
4605 CompileRun("var named_names = instance_mirror.propertyNames();"); 4621 CompileRun("var named_names = instance_mirror.propertyNames();");
4606 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); 4622 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value());
4607 CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue()); 4623 CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue());
4608 CHECK(CompileRun( 4624 CHECK(CompileRun(
4609 "instance_mirror.property('x').value().isNumber()")->BooleanValue()); 4625 "instance_mirror.property('x').value().isNumber()")->BooleanValue());
4610 CHECK(CompileRun( 4626 CHECK(CompileRun(
4611 "instance_mirror.property('x').value().value() == 10")->BooleanValue()); 4627 "instance_mirror.property('x').value().value() == 10")->BooleanValue());
4612 } 4628 }
4613 4629
4614 4630
4615 static void ProtperyXNativeGetterThrowingError( 4631 static void ProtperyXNativeGetterThrowingError(
4616 v8::Local<v8::String> property, 4632 v8::Local<v8::String> property,
4617 const v8::PropertyCallbackInfo<v8::Value>& info) { 4633 const v8::PropertyCallbackInfo<v8::Value>& info) {
4618 CompileRun("throw new Error('Error message');"); 4634 CompileRun("throw new Error('Error message');");
4619 } 4635 }
4620 4636
4621 4637
4622 TEST(NativeGetterThrowingErrorPropertyMirror) { 4638 TEST(NativeGetterThrowingErrorPropertyMirror) {
4623 // Create a V8 environment with debug access. 4639 // Create a V8 environment with debug access.
4624 DebugLocalContext env; 4640 DebugLocalContext env;
4625 v8::HandleScope scope(env->GetIsolate()); 4641 v8::Isolate* isolate = env->GetIsolate();
4642 v8::HandleScope scope(isolate);
4626 env.ExposeDebug(); 4643 env.ExposeDebug();
4627 4644
4628 v8::Handle<v8::String> name = v8::String::NewFromUtf8(env->GetIsolate(), "x"); 4645 v8::Handle<v8::String> name = v8::String::NewFromUtf8(isolate, "x");
4629 // Create object with named accessor. 4646 // Create object with named accessor.
4630 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); 4647 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
4631 named->SetAccessor(name, &ProtperyXNativeGetterThrowingError, NULL, 4648 named->SetAccessor(name, &ProtperyXNativeGetterThrowingError, NULL,
4632 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None); 4649 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None);
4633 4650
4634 // Create object with named property getter. 4651 // Create object with named property getter.
4635 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"), 4652 env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
4636 named->NewInstance()); 4653 named->NewInstance());
4637 4654
4638 // Get mirror for the object with property getter. 4655 // Get mirror for the object with property getter.
4639 CompileRun("var instance_mirror = debug.MakeMirror(instance);"); 4656 CompileRun("var instance_mirror = debug.MakeMirror(instance);");
4640 CHECK(CompileRun( 4657 CHECK(CompileRun(
4641 "instance_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4658 "instance_mirror instanceof debug.ObjectMirror")->BooleanValue());
4642 CompileRun("named_names = instance_mirror.propertyNames();"); 4659 CompileRun("named_names = instance_mirror.propertyNames();");
4643 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); 4660 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value());
4644 CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue()); 4661 CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue());
4645 CHECK(CompileRun( 4662 CHECK(CompileRun(
(...skipping 18 matching lines...) Expand all
4664 4681
4665 // Create an object in the global scope. 4682 // Create an object in the global scope.
4666 const char* source = "var obj = {a: 1};"; 4683 const char* source = "var obj = {a: 1};";
4667 v8::Script::Compile(v8::String::NewFromUtf8(isolate, source)) 4684 v8::Script::Compile(v8::String::NewFromUtf8(isolate, source))
4668 ->Run(); 4685 ->Run();
4669 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast( 4686 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(
4670 env->Global()->Get(v8::String::NewFromUtf8(isolate, "obj"))); 4687 env->Global()->Get(v8::String::NewFromUtf8(isolate, "obj")));
4671 // Set a hidden property on the object. 4688 // Set a hidden property on the object.
4672 obj->SetHiddenValue( 4689 obj->SetHiddenValue(
4673 v8::String::NewFromUtf8(isolate, "v8::test-debug::a"), 4690 v8::String::NewFromUtf8(isolate, "v8::test-debug::a"),
4674 v8::Int32::New(11)); 4691 v8::Int32::New(isolate, 11));
4675 4692
4676 // Get mirror for the object with property getter. 4693 // Get mirror for the object with property getter.
4677 CompileRun("var obj_mirror = debug.MakeMirror(obj);"); 4694 CompileRun("var obj_mirror = debug.MakeMirror(obj);");
4678 CHECK(CompileRun( 4695 CHECK(CompileRun(
4679 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4696 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue());
4680 CompileRun("var named_names = obj_mirror.propertyNames();"); 4697 CompileRun("var named_names = obj_mirror.propertyNames();");
4681 // There should be exactly one property. But there is also an unnamed 4698 // There should be exactly one property. But there is also an unnamed
4682 // property whose value is hidden properties dictionary. The latter 4699 // property whose value is hidden properties dictionary. The latter
4683 // property should not be in the list of reguar properties. 4700 // property should not be in the list of reguar properties.
4684 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); 4701 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value());
4685 CHECK(CompileRun("named_names[0] == 'a'")->BooleanValue()); 4702 CHECK(CompileRun("named_names[0] == 'a'")->BooleanValue());
4686 CHECK(CompileRun( 4703 CHECK(CompileRun(
4687 "obj_mirror.property('a').value().value() == 1")->BooleanValue()); 4704 "obj_mirror.property('a').value().value() == 1")->BooleanValue());
4688 4705
4689 // Object created by t0 will become hidden prototype of object 'obj'. 4706 // Object created by t0 will become hidden prototype of object 'obj'.
4690 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate); 4707 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
4691 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "b"), 4708 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "b"),
4692 v8::Number::New(2)); 4709 v8::Number::New(isolate, 2));
4693 t0->SetHiddenPrototype(true); 4710 t0->SetHiddenPrototype(true);
4694 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); 4711 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
4695 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "c"), 4712 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "c"),
4696 v8::Number::New(3)); 4713 v8::Number::New(isolate, 3));
4697 4714
4698 // Create proto objects, add hidden properties to them and set them on 4715 // Create proto objects, add hidden properties to them and set them on
4699 // the global object. 4716 // the global object.
4700 v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance(); 4717 v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance();
4701 protoObj->SetHiddenValue( 4718 protoObj->SetHiddenValue(
4702 v8::String::NewFromUtf8(isolate, "v8::test-debug::b"), 4719 v8::String::NewFromUtf8(isolate, "v8::test-debug::b"),
4703 v8::Int32::New(12)); 4720 v8::Int32::New(isolate, 12));
4704 env->Global()->Set(v8::String::NewFromUtf8(isolate, "protoObj"), 4721 env->Global()->Set(v8::String::NewFromUtf8(isolate, "protoObj"),
4705 protoObj); 4722 protoObj);
4706 v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance(); 4723 v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance();
4707 grandProtoObj->SetHiddenValue( 4724 grandProtoObj->SetHiddenValue(
4708 v8::String::NewFromUtf8(isolate, "v8::test-debug::c"), 4725 v8::String::NewFromUtf8(isolate, "v8::test-debug::c"),
4709 v8::Int32::New(13)); 4726 v8::Int32::New(isolate, 13));
4710 env->Global()->Set( 4727 env->Global()->Set(
4711 v8::String::NewFromUtf8(isolate, "grandProtoObj"), 4728 v8::String::NewFromUtf8(isolate, "grandProtoObj"),
4712 grandProtoObj); 4729 grandProtoObj);
4713 4730
4714 // Setting prototypes: obj->protoObj->grandProtoObj 4731 // Setting prototypes: obj->protoObj->grandProtoObj
4715 protoObj->Set(v8::String::NewFromUtf8(isolate, "__proto__"), 4732 protoObj->Set(v8::String::NewFromUtf8(isolate, "__proto__"),
4716 grandProtoObj); 4733 grandProtoObj);
4717 obj->Set(v8::String::NewFromUtf8(isolate, "__proto__"), protoObj); 4734 obj->Set(v8::String::NewFromUtf8(isolate, "__proto__"), protoObj);
4718 4735
4719 // Get mirror for the object with property getter. 4736 // Get mirror for the object with property getter.
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
5195 " while ( flag == true ) {\n" 5212 " while ( flag == true ) {\n"
5196 " if ( x == 1 ) {\n" 5213 " if ( x == 1 ) {\n"
5197 " ThreadedAtBarrier1();\n" 5214 " ThreadedAtBarrier1();\n"
5198 " }\n" 5215 " }\n"
5199 " x = x + 1;\n" 5216 " x = x + 1;\n"
5200 " }\n" 5217 " }\n"
5201 "}\n" 5218 "}\n"
5202 "\n" 5219 "\n"
5203 "foo();\n"; 5220 "foo();\n";
5204 5221
5205 v8::Isolate::Scope isolate_scope(CcTest::isolate()); 5222 v8::Isolate* isolate = CcTest::isolate();
5223 v8::Isolate::Scope isolate_scope(isolate);
5206 DebugLocalContext env; 5224 DebugLocalContext env;
5207 v8::HandleScope scope(env->GetIsolate()); 5225 v8::HandleScope scope(env->GetIsolate());
5208 v8::Debug::SetMessageHandler2(&ThreadedMessageHandler); 5226 v8::Debug::SetMessageHandler2(&ThreadedMessageHandler);
5209 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); 5227 v8::Handle<v8::ObjectTemplate> global_template =
5228 v8::ObjectTemplate::New(env->GetIsolate());
5210 global_template->Set( 5229 global_template->Set(
5211 v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"), 5230 v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"),
5212 v8::FunctionTemplate::New(CcTest::isolate(), ThreadedAtBarrier1)); 5231 v8::FunctionTemplate::New(isolate, ThreadedAtBarrier1));
5213 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), 5232 v8::Handle<v8::Context> context = v8::Context::New(isolate,
5214 NULL, 5233 NULL,
5215 global_template); 5234 global_template);
5216 v8::Context::Scope context_scope(context); 5235 v8::Context::Scope context_scope(context);
5217 5236
5218 CompileRun(source); 5237 CompileRun(source);
5219 } 5238 }
5220 5239
5221 5240
5222 void DebuggerThread::Run() { 5241 void DebuggerThread::Run() {
5223 const int kBufSize = 1000; 5242 const int kBufSize = 1000;
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
5559 static void CheckClosure(const v8::FunctionCallbackInfo<v8::Value>& args) { 5578 static void CheckClosure(const v8::FunctionCallbackInfo<v8::Value>& args) {
5560 CHECK(v8::Debug::Call(debugger_call_with_closure)->IsNumber()); 5579 CHECK(v8::Debug::Call(debugger_call_with_closure)->IsNumber());
5561 CHECK_EQ(3, v8::Debug::Call(debugger_call_with_closure)->Int32Value()); 5580 CHECK_EQ(3, v8::Debug::Call(debugger_call_with_closure)->Int32Value());
5562 } 5581 }
5563 5582
5564 5583
5565 // Test functions called through the debugger. 5584 // Test functions called through the debugger.
5566 TEST(CallFunctionInDebugger) { 5585 TEST(CallFunctionInDebugger) {
5567 // Create and enter a context with the functions CheckFrameCount, 5586 // Create and enter a context with the functions CheckFrameCount,
5568 // CheckSourceLine and CheckDataParameter installed. 5587 // CheckSourceLine and CheckDataParameter installed.
5569 v8::HandleScope scope(CcTest::isolate()); 5588 v8::Isolate* isolate = CcTest::isolate();
5570 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); 5589 v8::HandleScope scope(isolate);
5590 v8::Handle<v8::ObjectTemplate> global_template =
5591 v8::ObjectTemplate::New(isolate);
5571 global_template->Set( 5592 global_template->Set(
5572 v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount"), 5593 v8::String::NewFromUtf8(isolate, "CheckFrameCount"),
5573 v8::FunctionTemplate::New(CcTest::isolate(), CheckFrameCount)); 5594 v8::FunctionTemplate::New(isolate, CheckFrameCount));
5574 global_template->Set( 5595 global_template->Set(
5575 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine"), 5596 v8::String::NewFromUtf8(isolate, "CheckSourceLine"),
5576 v8::FunctionTemplate::New(CcTest::isolate(), CheckSourceLine)); 5597 v8::FunctionTemplate::New(isolate, CheckSourceLine));
5577 global_template->Set( 5598 global_template->Set(
5578 v8::String::NewFromUtf8(CcTest::isolate(), "CheckDataParameter"), 5599 v8::String::NewFromUtf8(isolate, "CheckDataParameter"),
5579 v8::FunctionTemplate::New(CcTest::isolate(), CheckDataParameter)); 5600 v8::FunctionTemplate::New(isolate, CheckDataParameter));
5580 global_template->Set( 5601 global_template->Set(
5581 v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure"), 5602 v8::String::NewFromUtf8(isolate, "CheckClosure"),
5582 v8::FunctionTemplate::New(CcTest::isolate(), CheckClosure)); 5603 v8::FunctionTemplate::New(isolate, CheckClosure));
5583 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), 5604 v8::Handle<v8::Context> context = v8::Context::New(isolate,
5584 NULL, 5605 NULL,
5585 global_template); 5606 global_template);
5586 v8::Context::Scope context_scope(context); 5607 v8::Context::Scope context_scope(context);
5587 5608
5588 // Compile a function for checking the number of JavaScript frames. 5609 // Compile a function for checking the number of JavaScript frames.
5589 v8::Script::Compile( 5610 v8::Script::Compile(
5590 v8::String::NewFromUtf8(CcTest::isolate(), frame_count_source))->Run(); 5611 v8::String::NewFromUtf8(isolate, frame_count_source))->Run();
5591 frame_count = v8::Local<v8::Function>::Cast(context->Global()->Get( 5612 frame_count = v8::Local<v8::Function>::Cast(context->Global()->Get(
5592 v8::String::NewFromUtf8(CcTest::isolate(), "frame_count"))); 5613 v8::String::NewFromUtf8(isolate, "frame_count")));
5593 5614
5594 // Compile a function for returning the source line for the top frame. 5615 // Compile a function for returning the source line for the top frame.
5595 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5616 v8::Script::Compile(v8::String::NewFromUtf8(isolate,
5596 frame_source_line_source))->Run(); 5617 frame_source_line_source))->Run();
5597 frame_source_line = v8::Local<v8::Function>::Cast(context->Global()->Get( 5618 frame_source_line = v8::Local<v8::Function>::Cast(context->Global()->Get(
5598 v8::String::NewFromUtf8(CcTest::isolate(), "frame_source_line"))); 5619 v8::String::NewFromUtf8(isolate, "frame_source_line")));
5599 5620
5600 // Compile a function returning the data parameter. 5621 // Compile a function returning the data parameter.
5601 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5622 v8::Script::Compile(v8::String::NewFromUtf8(isolate,
5602 debugger_call_with_data_source)) 5623 debugger_call_with_data_source))
5603 ->Run(); 5624 ->Run();
5604 debugger_call_with_data = v8::Local<v8::Function>::Cast( 5625 debugger_call_with_data = v8::Local<v8::Function>::Cast(
5605 context->Global()->Get(v8::String::NewFromUtf8( 5626 context->Global()->Get(v8::String::NewFromUtf8(
5606 CcTest::isolate(), "debugger_call_with_data"))); 5627 isolate, "debugger_call_with_data")));
5607 5628
5608 // Compile a function capturing closure. 5629 // Compile a function capturing closure.
5609 debugger_call_with_closure = 5630 debugger_call_with_closure =
5610 v8::Local<v8::Function>::Cast(v8::Script::Compile( 5631 v8::Local<v8::Function>::Cast(v8::Script::Compile(
5611 v8::String::NewFromUtf8(CcTest::isolate(), 5632 v8::String::NewFromUtf8(isolate,
5612 debugger_call_with_closure_source))->Run()); 5633 debugger_call_with_closure_source))->Run());
5613 5634
5614 // Calling a function through the debugger returns 0 frames if there are 5635 // Calling a function through the debugger returns 0 frames if there are
5615 // no JavaScript frames. 5636 // no JavaScript frames.
5616 CHECK_EQ(v8::Integer::New(0), v8::Debug::Call(frame_count)); 5637 CHECK_EQ(v8::Integer::New(isolate, 0),
5638 v8::Debug::Call(frame_count));
5617 5639
5618 // Test that the number of frames can be retrieved. 5640 // Test that the number of frames can be retrieved.
5619 v8::Script::Compile( 5641 v8::Script::Compile(
5620 v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount(1)"))->Run(); 5642 v8::String::NewFromUtf8(isolate, "CheckFrameCount(1)"))->Run();
5621 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5643 v8::Script::Compile(v8::String::NewFromUtf8(isolate,
5622 "function f() {" 5644 "function f() {"
5623 " CheckFrameCount(2);" 5645 " CheckFrameCount(2);"
5624 "}; f()"))->Run(); 5646 "}; f()"))->Run();
5625 5647
5626 // Test that the source line can be retrieved. 5648 // Test that the source line can be retrieved.
5627 v8::Script::Compile( 5649 v8::Script::Compile(
5628 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine(0)"))->Run(); 5650 v8::String::NewFromUtf8(isolate, "CheckSourceLine(0)"))->Run();
5629 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5651 v8::Script::Compile(v8::String::NewFromUtf8(isolate,
5630 "function f() {\n" 5652 "function f() {\n"
5631 " CheckSourceLine(1)\n" 5653 " CheckSourceLine(1)\n"
5632 " CheckSourceLine(2)\n" 5654 " CheckSourceLine(2)\n"
5633 " CheckSourceLine(3)\n" 5655 " CheckSourceLine(3)\n"
5634 "}; f()"))->Run(); 5656 "}; f()"))->Run();
5635 5657
5636 // Test that a parameter can be passed to a function called in the debugger. 5658 // Test that a parameter can be passed to a function called in the debugger.
5637 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5659 v8::Script::Compile(v8::String::NewFromUtf8(isolate,
5638 "CheckDataParameter()"))->Run(); 5660 "CheckDataParameter()"))->Run();
5639 5661
5640 // Test that a function with closure can be run in the debugger. 5662 // Test that a function with closure can be run in the debugger.
5641 v8::Script::Compile( 5663 v8::Script::Compile(
5642 v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure()"))->Run(); 5664 v8::String::NewFromUtf8(isolate, "CheckClosure()"))->Run();
5643 5665
5644 // Test that the source line is correct when there is a line offset. 5666 // Test that the source line is correct when there is a line offset.
5645 v8::ScriptOrigin origin(v8::String::NewFromUtf8(CcTest::isolate(), "test"), 5667 v8::ScriptOrigin origin(v8::String::NewFromUtf8(isolate, "test"),
5646 v8::Integer::New(7)); 5668 v8::Integer::New(isolate, 7));
5647 v8::Script::Compile( 5669 v8::Script::Compile(
5648 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine(7)"), &origin) 5670 v8::String::NewFromUtf8(isolate, "CheckSourceLine(7)"), &origin)
5649 ->Run(); 5671 ->Run();
5650 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5672 v8::Script::Compile(v8::String::NewFromUtf8(isolate,
5651 "function f() {\n" 5673 "function f() {\n"
5652 " CheckSourceLine(8)\n" 5674 " CheckSourceLine(8)\n"
5653 " CheckSourceLine(9)\n" 5675 " CheckSourceLine(9)\n"
5654 " CheckSourceLine(10)\n" 5676 " CheckSourceLine(10)\n"
5655 "}; f()"), 5677 "}; f()"),
5656 &origin)->Run(); 5678 &origin)->Run();
5657 } 5679 }
5658 5680
5659 5681
5660 // Debugger message handler which counts the number of breaks. 5682 // Debugger message handler which counts the number of breaks.
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
6437 v8::DebugEvent event = event_details.GetEvent(); 6459 v8::DebugEvent event = event_details.GetEvent();
6438 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 6460 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
6439 6461
6440 if (event == v8::Break) { 6462 if (event == v8::Break) {
6441 break_point_hit_count++; 6463 break_point_hit_count++;
6442 6464
6443 // Get the name of the top frame function. 6465 // Get the name of the top frame function.
6444 if (!frame_function_name.IsEmpty()) { 6466 if (!frame_function_name.IsEmpty()) {
6445 // Get the name of the function. 6467 // Get the name of the function.
6446 const int argc = 2; 6468 const int argc = 2;
6447 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(0) }; 6469 v8::Handle<v8::Value> argv[argc] = {
6470 exec_state, v8::Integer::New(CcTest::isolate(), 0)
6471 };
6448 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state, 6472 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state,
6449 argc, argv); 6473 argc, argv);
6450 if (result->IsUndefined()) { 6474 if (result->IsUndefined()) {
6451 last_function_hit[0] = '\0'; 6475 last_function_hit[0] = '\0';
6452 } else { 6476 } else {
6453 CHECK(result->IsString()); 6477 CHECK(result->IsString());
6454 v8::Handle<v8::String> function_name(result->ToString()); 6478 v8::Handle<v8::String> function_name(result->ToString());
6455 function_name->WriteUtf8(last_function_hit); 6479 function_name->WriteUtf8(last_function_hit);
6456 } 6480 }
6457 } 6481 }
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
6853 int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name, 6877 int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name,
6854 3, -1 /* no column */); 6878 3, -1 /* no column */);
6855 int sbp2 = 6879 int sbp2 =
6856 SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name, 5, 5); 6880 SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name, 5, 5);
6857 6881
6858 after_compile_message_count = 0; 6882 after_compile_message_count = 0;
6859 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); 6883 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
6860 6884
6861 v8::ScriptOrigin origin( 6885 v8::ScriptOrigin origin(
6862 v8::String::NewFromUtf8(env->GetIsolate(), resource_name), 6886 v8::String::NewFromUtf8(env->GetIsolate(), resource_name),
6863 v8::Integer::New(10), 6887 v8::Integer::New(env->GetIsolate(), 10),
6864 v8::Integer::New(1)); 6888 v8::Integer::New(env->GetIsolate(), 1));
6865 // Compile a script whose first line number is greater than the breakpoints' 6889 // Compile a script whose first line number is greater than the breakpoints'
6866 // lines. 6890 // lines.
6867 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script), 6891 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script),
6868 &origin)->Run(); 6892 &origin)->Run();
6869 6893
6870 // If the script is compiled successfully there is exactly one after compile 6894 // If the script is compiled successfully there is exactly one after compile
6871 // event. In case of an exception in debugger code after compile event is not 6895 // event. In case of an exception in debugger code after compile event is not
6872 // sent. 6896 // sent.
6873 CHECK_EQ(1, after_compile_message_count); 6897 CHECK_EQ(1, after_compile_message_count);
6874 6898
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
7143 v8::Handle<v8::Value> result = func->Call(exec_state, argc, argv); 7167 v8::Handle<v8::Value> result = func->Call(exec_state, argc, argv);
7144 CHECK(result->IsTrue()); 7168 CHECK(result->IsTrue());
7145 } 7169 }
7146 } 7170 }
7147 7171
7148 7172
7149 TEST(CallingContextIsNotDebugContext) { 7173 TEST(CallingContextIsNotDebugContext) {
7150 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); 7174 v8::internal::Debug* debug = CcTest::i_isolate()->debug();
7151 // Create and enter a debugee context. 7175 // Create and enter a debugee context.
7152 DebugLocalContext env; 7176 DebugLocalContext env;
7153 v8::HandleScope scope(env->GetIsolate()); 7177 v8::Isolate* isolate = env->GetIsolate();
7178 v8::HandleScope scope(isolate);
7154 env.ExposeDebug(); 7179 env.ExposeDebug();
7155 7180
7156 // Save handles to the debugger and debugee contexts to be used in 7181 // Save handles to the debugger and debugee contexts to be used in
7157 // NamedGetterWithCallingContextCheck. 7182 // NamedGetterWithCallingContextCheck.
7158 debugee_context = env.context(); 7183 debugee_context = env.context();
7159 debugger_context = v8::Utils::ToLocal(debug->debug_context()); 7184 debugger_context = v8::Utils::ToLocal(debug->debug_context());
7160 7185
7161 // Create object with 'a' property accessor. 7186 // Create object with 'a' property accessor.
7162 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); 7187 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
7163 named->SetAccessor(v8::String::NewFromUtf8(env->GetIsolate(), "a"), 7188 named->SetAccessor(v8::String::NewFromUtf8(isolate, "a"),
7164 NamedGetterWithCallingContextCheck); 7189 NamedGetterWithCallingContextCheck);
7165 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "obj"), 7190 env->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"),
7166 named->NewInstance()); 7191 named->NewInstance());
7167 7192
7168 // Register the debug event listener 7193 // Register the debug event listener
7169 v8::Debug::SetDebugEventListener2(DebugEventGetAtgumentPropertyValue); 7194 v8::Debug::SetDebugEventListener2(DebugEventGetAtgumentPropertyValue);
7170 7195
7171 // Create a function that invokes debugger. 7196 // Create a function that invokes debugger.
7172 v8::Local<v8::Function> foo = CompileFunction( 7197 v8::Local<v8::Function> foo = CompileFunction(
7173 &env, 7198 &env,
7174 "function bar(x) { debugger; }" 7199 "function bar(x) { debugger; }"
7175 "function foo(){ bar(obj); }", 7200 "function foo(){ bar(obj); }",
(...skipping 22 matching lines...) Expand all
7198 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) { 7223 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) {
7199 CHECK(details.GetEventContext() == expected_context); 7224 CHECK(details.GetEventContext() == expected_context);
7200 CHECK_EQ(expected_callback_data, details.GetCallbackData()); 7225 CHECK_EQ(expected_callback_data, details.GetCallbackData());
7201 } 7226 }
7202 7227
7203 7228
7204 // Check that event details contain context where debug event occured. 7229 // Check that event details contain context where debug event occured.
7205 TEST(DebugEventContext) { 7230 TEST(DebugEventContext) {
7206 v8::Isolate* isolate = CcTest::isolate(); 7231 v8::Isolate* isolate = CcTest::isolate();
7207 v8::HandleScope scope(isolate); 7232 v8::HandleScope scope(isolate);
7208 expected_callback_data = v8::Int32::New(2010);
7209 expected_context = v8::Context::New(isolate); 7233 expected_context = v8::Context::New(isolate);
7234 expected_callback_data = v8::Int32::New(isolate, 2010);
7210 v8::Debug::SetDebugEventListener2(DebugEventContextChecker, 7235 v8::Debug::SetDebugEventListener2(DebugEventContextChecker,
7211 expected_callback_data); 7236 expected_callback_data);
7212 v8::Context::Scope context_scope(expected_context); 7237 v8::Context::Scope context_scope(expected_context);
7213 v8::Script::Compile( 7238 v8::Script::Compile(
7214 v8::String::NewFromUtf8(isolate, "(function(){debugger;})();"))->Run(); 7239 v8::String::NewFromUtf8(isolate, "(function(){debugger;})();"))->Run();
7215 expected_context.Clear(); 7240 expected_context.Clear();
7216 v8::Debug::SetDebugEventListener2(NULL); 7241 v8::Debug::SetDebugEventListener2(NULL);
7217 expected_context_data = v8::Handle<v8::Value>(); 7242 expected_context_data = v8::Handle<v8::Value>();
7218 CheckDebuggerUnloaded(); 7243 CheckDebuggerUnloaded();
7219 } 7244 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
7296 static bool debug_event_break_deoptimize_done = false; 7321 static bool debug_event_break_deoptimize_done = false;
7297 7322
7298 static void DebugEventBreakDeoptimize( 7323 static void DebugEventBreakDeoptimize(
7299 const v8::Debug::EventDetails& event_details) { 7324 const v8::Debug::EventDetails& event_details) {
7300 v8::DebugEvent event = event_details.GetEvent(); 7325 v8::DebugEvent event = event_details.GetEvent();
7301 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 7326 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
7302 if (event == v8::Break) { 7327 if (event == v8::Break) {
7303 if (!frame_function_name.IsEmpty()) { 7328 if (!frame_function_name.IsEmpty()) {
7304 // Get the name of the function. 7329 // Get the name of the function.
7305 const int argc = 2; 7330 const int argc = 2;
7306 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(0) }; 7331 v8::Handle<v8::Value> argv[argc] = {
7332 exec_state, v8::Integer::New(CcTest::isolate(), 0)
7333 };
7307 v8::Handle<v8::Value> result = 7334 v8::Handle<v8::Value> result =
7308 frame_function_name->Call(exec_state, argc, argv); 7335 frame_function_name->Call(exec_state, argc, argv);
7309 if (!result->IsUndefined()) { 7336 if (!result->IsUndefined()) {
7310 char fn[80]; 7337 char fn[80];
7311 CHECK(result->IsString()); 7338 CHECK(result->IsString());
7312 v8::Handle<v8::String> function_name(result->ToString()); 7339 v8::Handle<v8::String> function_name(result->ToString());
7313 function_name->WriteUtf8(fn); 7340 function_name->WriteUtf8(fn);
7314 if (strcmp(fn, "bar") == 0) { 7341 if (strcmp(fn, "bar") == 0) {
7315 i::Deoptimizer::DeoptimizeAll(CcTest::i_isolate()); 7342 i::Deoptimizer::DeoptimizeAll(CcTest::i_isolate());
7316 debug_event_break_deoptimize_done = true; 7343 debug_event_break_deoptimize_done = true;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
7360 7387
7361 static void DebugEventBreakWithOptimizedStack( 7388 static void DebugEventBreakWithOptimizedStack(
7362 const v8::Debug::EventDetails& event_details) { 7389 const v8::Debug::EventDetails& event_details) {
7363 v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate(); 7390 v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate();
7364 v8::DebugEvent event = event_details.GetEvent(); 7391 v8::DebugEvent event = event_details.GetEvent();
7365 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 7392 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
7366 if (event == v8::Break) { 7393 if (event == v8::Break) {
7367 if (!frame_function_name.IsEmpty()) { 7394 if (!frame_function_name.IsEmpty()) {
7368 for (int i = 0; i < 2; i++) { 7395 for (int i = 0; i < 2; i++) {
7369 const int argc = 2; 7396 const int argc = 2;
7370 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(i) }; 7397 v8::Handle<v8::Value> argv[argc] = {
7398 exec_state, v8::Integer::New(isolate, i)
7399 };
7371 // Get the name of the function in frame i. 7400 // Get the name of the function in frame i.
7372 v8::Handle<v8::Value> result = 7401 v8::Handle<v8::Value> result =
7373 frame_function_name->Call(exec_state, argc, argv); 7402 frame_function_name->Call(exec_state, argc, argv);
7374 CHECK(result->IsString()); 7403 CHECK(result->IsString());
7375 v8::Handle<v8::String> function_name(result->ToString()); 7404 v8::Handle<v8::String> function_name(result->ToString());
7376 CHECK(function_name->Equals(v8::String::NewFromUtf8(isolate, "loop"))); 7405 CHECK(function_name->Equals(v8::String::NewFromUtf8(isolate, "loop")));
7377 // Get the name of the first argument in frame i. 7406 // Get the name of the first argument in frame i.
7378 result = frame_argument_name->Call(exec_state, argc, argv); 7407 result = frame_argument_name->Call(exec_state, argc, argv);
7379 CHECK(result->IsString()); 7408 CHECK(result->IsString());
7380 v8::Handle<v8::String> argument_name(result->ToString()); 7409 v8::Handle<v8::String> argument_name(result->ToString());
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
7670 TEST(LiveEditDisabled) { 7699 TEST(LiveEditDisabled) {
7671 v8::internal::FLAG_allow_natives_syntax = true; 7700 v8::internal::FLAG_allow_natives_syntax = true;
7672 LocalContext env; 7701 LocalContext env;
7673 v8::HandleScope scope(env->GetIsolate()); 7702 v8::HandleScope scope(env->GetIsolate());
7674 v8::Debug::SetLiveEditEnabled(false, env->GetIsolate()); 7703 v8::Debug::SetLiveEditEnabled(false, env->GetIsolate());
7675 CompileRun("%LiveEditCompareStrings('', '')"); 7704 CompileRun("%LiveEditCompareStrings('', '')");
7676 } 7705 }
7677 7706
7678 7707
7679 #endif // ENABLE_DEBUGGER_SUPPORT 7708 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « test/cctest/test-cpu-profiler.cc ('k') | test/cctest/test-declarative-accessors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698