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

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

Issue 119753008: Revert r18451 "Revert r18449 "Reland r18383: More API cleanup." and r18450 "Unbreak build."" since … (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 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 1184 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
4475 4489
4476 TEST(HiddenPrototypePropertyMirror) { 4490 TEST(HiddenPrototypePropertyMirror) {
4477 // Create a V8 environment with debug access. 4491 // Create a V8 environment with debug access.
4478 DebugLocalContext env; 4492 DebugLocalContext env;
4479 v8::Isolate* isolate = env->GetIsolate(); 4493 v8::Isolate* isolate = env->GetIsolate();
4480 v8::HandleScope scope(isolate); 4494 v8::HandleScope scope(isolate);
4481 env.ExposeDebug(); 4495 env.ExposeDebug();
4482 4496
4483 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate); 4497 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
4484 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "x"), 4498 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "x"),
4485 v8::Number::New(0)); 4499 v8::Number::New(isolate, 0));
4486 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); 4500 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
4487 t1->SetHiddenPrototype(true); 4501 t1->SetHiddenPrototype(true);
4488 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "y"), 4502 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "y"),
4489 v8::Number::New(1)); 4503 v8::Number::New(isolate, 1));
4490 v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate); 4504 v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate);
4491 t2->SetHiddenPrototype(true); 4505 t2->SetHiddenPrototype(true);
4492 t2->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "z"), 4506 t2->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "z"),
4493 v8::Number::New(2)); 4507 v8::Number::New(isolate, 2));
4494 v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate); 4508 v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate);
4495 t3->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "u"), 4509 t3->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "u"),
4496 v8::Number::New(3)); 4510 v8::Number::New(isolate, 3));
4497 4511
4498 // Create object and set them on the global object. 4512 // Create object and set them on the global object.
4499 v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance(); 4513 v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance();
4500 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o0"), o0); 4514 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o0"), o0);
4501 v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance(); 4515 v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance();
4502 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o1"), o1); 4516 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o1"), o1);
4503 v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance(); 4517 v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance();
4504 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o2"), o2); 4518 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o2"), o2);
4505 v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance(); 4519 v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance();
4506 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o3"), o3); 4520 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o3"), o3);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
4664 4678
4665 // Create an object in the global scope. 4679 // Create an object in the global scope.
4666 const char* source = "var obj = {a: 1};"; 4680 const char* source = "var obj = {a: 1};";
4667 v8::Script::Compile(v8::String::NewFromUtf8(isolate, source)) 4681 v8::Script::Compile(v8::String::NewFromUtf8(isolate, source))
4668 ->Run(); 4682 ->Run();
4669 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast( 4683 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(
4670 env->Global()->Get(v8::String::NewFromUtf8(isolate, "obj"))); 4684 env->Global()->Get(v8::String::NewFromUtf8(isolate, "obj")));
4671 // Set a hidden property on the object. 4685 // Set a hidden property on the object.
4672 obj->SetHiddenValue( 4686 obj->SetHiddenValue(
4673 v8::String::NewFromUtf8(isolate, "v8::test-debug::a"), 4687 v8::String::NewFromUtf8(isolate, "v8::test-debug::a"),
4674 v8::Int32::New(11)); 4688 v8::Int32::New(isolate, 11));
4675 4689
4676 // Get mirror for the object with property getter. 4690 // Get mirror for the object with property getter.
4677 CompileRun("var obj_mirror = debug.MakeMirror(obj);"); 4691 CompileRun("var obj_mirror = debug.MakeMirror(obj);");
4678 CHECK(CompileRun( 4692 CHECK(CompileRun(
4679 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4693 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue());
4680 CompileRun("var named_names = obj_mirror.propertyNames();"); 4694 CompileRun("var named_names = obj_mirror.propertyNames();");
4681 // There should be exactly one property. But there is also an unnamed 4695 // There should be exactly one property. But there is also an unnamed
4682 // property whose value is hidden properties dictionary. The latter 4696 // property whose value is hidden properties dictionary. The latter
4683 // property should not be in the list of reguar properties. 4697 // property should not be in the list of reguar properties.
4684 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); 4698 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value());
4685 CHECK(CompileRun("named_names[0] == 'a'")->BooleanValue()); 4699 CHECK(CompileRun("named_names[0] == 'a'")->BooleanValue());
4686 CHECK(CompileRun( 4700 CHECK(CompileRun(
4687 "obj_mirror.property('a').value().value() == 1")->BooleanValue()); 4701 "obj_mirror.property('a').value().value() == 1")->BooleanValue());
4688 4702
4689 // Object created by t0 will become hidden prototype of object 'obj'. 4703 // Object created by t0 will become hidden prototype of object 'obj'.
4690 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate); 4704 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
4691 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "b"), 4705 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "b"),
4692 v8::Number::New(2)); 4706 v8::Number::New(isolate, 2));
4693 t0->SetHiddenPrototype(true); 4707 t0->SetHiddenPrototype(true);
4694 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); 4708 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
4695 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "c"), 4709 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "c"),
4696 v8::Number::New(3)); 4710 v8::Number::New(isolate, 3));
4697 4711
4698 // Create proto objects, add hidden properties to them and set them on 4712 // Create proto objects, add hidden properties to them and set them on
4699 // the global object. 4713 // the global object.
4700 v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance(); 4714 v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance();
4701 protoObj->SetHiddenValue( 4715 protoObj->SetHiddenValue(
4702 v8::String::NewFromUtf8(isolate, "v8::test-debug::b"), 4716 v8::String::NewFromUtf8(isolate, "v8::test-debug::b"),
4703 v8::Int32::New(12)); 4717 v8::Int32::New(isolate, 12));
4704 env->Global()->Set(v8::String::NewFromUtf8(isolate, "protoObj"), 4718 env->Global()->Set(v8::String::NewFromUtf8(isolate, "protoObj"),
4705 protoObj); 4719 protoObj);
4706 v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance(); 4720 v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance();
4707 grandProtoObj->SetHiddenValue( 4721 grandProtoObj->SetHiddenValue(
4708 v8::String::NewFromUtf8(isolate, "v8::test-debug::c"), 4722 v8::String::NewFromUtf8(isolate, "v8::test-debug::c"),
4709 v8::Int32::New(13)); 4723 v8::Int32::New(isolate, 13));
4710 env->Global()->Set( 4724 env->Global()->Set(
4711 v8::String::NewFromUtf8(isolate, "grandProtoObj"), 4725 v8::String::NewFromUtf8(isolate, "grandProtoObj"),
4712 grandProtoObj); 4726 grandProtoObj);
4713 4727
4714 // Setting prototypes: obj->protoObj->grandProtoObj 4728 // Setting prototypes: obj->protoObj->grandProtoObj
4715 protoObj->Set(v8::String::NewFromUtf8(isolate, "__proto__"), 4729 protoObj->Set(v8::String::NewFromUtf8(isolate, "__proto__"),
4716 grandProtoObj); 4730 grandProtoObj);
4717 obj->Set(v8::String::NewFromUtf8(isolate, "__proto__"), protoObj); 4731 obj->Set(v8::String::NewFromUtf8(isolate, "__proto__"), protoObj);
4718 4732
4719 // Get mirror for the object with property getter. 4733 // Get mirror for the object with property getter.
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
5606 CcTest::isolate(), "debugger_call_with_data"))); 5620 CcTest::isolate(), "debugger_call_with_data")));
5607 5621
5608 // Compile a function capturing closure. 5622 // Compile a function capturing closure.
5609 debugger_call_with_closure = 5623 debugger_call_with_closure =
5610 v8::Local<v8::Function>::Cast(v8::Script::Compile( 5624 v8::Local<v8::Function>::Cast(v8::Script::Compile(
5611 v8::String::NewFromUtf8(CcTest::isolate(), 5625 v8::String::NewFromUtf8(CcTest::isolate(),
5612 debugger_call_with_closure_source))->Run()); 5626 debugger_call_with_closure_source))->Run());
5613 5627
5614 // Calling a function through the debugger returns 0 frames if there are 5628 // Calling a function through the debugger returns 0 frames if there are
5615 // no JavaScript frames. 5629 // no JavaScript frames.
5616 CHECK_EQ(v8::Integer::New(0), v8::Debug::Call(frame_count)); 5630 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 0),
5631 v8::Debug::Call(frame_count));
5617 5632
5618 // Test that the number of frames can be retrieved. 5633 // Test that the number of frames can be retrieved.
5619 v8::Script::Compile( 5634 v8::Script::Compile(
5620 v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount(1)"))->Run(); 5635 v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount(1)"))->Run();
5621 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5636 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(),
5622 "function f() {" 5637 "function f() {"
5623 " CheckFrameCount(2);" 5638 " CheckFrameCount(2);"
5624 "}; f()"))->Run(); 5639 "}; f()"))->Run();
5625 5640
5626 // Test that the source line can be retrieved. 5641 // Test that the source line can be retrieved.
5627 v8::Script::Compile( 5642 v8::Script::Compile(
5628 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine(0)"))->Run(); 5643 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine(0)"))->Run();
5629 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5644 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(),
5630 "function f() {\n" 5645 "function f() {\n"
5631 " CheckSourceLine(1)\n" 5646 " CheckSourceLine(1)\n"
5632 " CheckSourceLine(2)\n" 5647 " CheckSourceLine(2)\n"
5633 " CheckSourceLine(3)\n" 5648 " CheckSourceLine(3)\n"
5634 "}; f()"))->Run(); 5649 "}; f()"))->Run();
5635 5650
5636 // Test that a parameter can be passed to a function called in the debugger. 5651 // Test that a parameter can be passed to a function called in the debugger.
5637 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5652 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(),
5638 "CheckDataParameter()"))->Run(); 5653 "CheckDataParameter()"))->Run();
5639 5654
5640 // Test that a function with closure can be run in the debugger. 5655 // Test that a function with closure can be run in the debugger.
5641 v8::Script::Compile( 5656 v8::Script::Compile(
5642 v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure()"))->Run(); 5657 v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure()"))->Run();
5643 5658
5644 // Test that the source line is correct when there is a line offset. 5659 // Test that the source line is correct when there is a line offset.
5645 v8::ScriptOrigin origin(v8::String::NewFromUtf8(CcTest::isolate(), "test"), 5660 v8::ScriptOrigin origin(v8::String::NewFromUtf8(CcTest::isolate(), "test"),
5646 v8::Integer::New(7)); 5661 v8::Integer::New(CcTest::isolate(), 7));
5647 v8::Script::Compile( 5662 v8::Script::Compile(
5648 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine(7)"), &origin) 5663 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine(7)"), &origin)
5649 ->Run(); 5664 ->Run();
5650 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5665 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(),
5651 "function f() {\n" 5666 "function f() {\n"
5652 " CheckSourceLine(8)\n" 5667 " CheckSourceLine(8)\n"
5653 " CheckSourceLine(9)\n" 5668 " CheckSourceLine(9)\n"
5654 " CheckSourceLine(10)\n" 5669 " CheckSourceLine(10)\n"
5655 "}; f()"), 5670 "}; f()"),
5656 &origin)->Run(); 5671 &origin)->Run();
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
6437 v8::DebugEvent event = event_details.GetEvent(); 6452 v8::DebugEvent event = event_details.GetEvent();
6438 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 6453 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
6439 6454
6440 if (event == v8::Break) { 6455 if (event == v8::Break) {
6441 break_point_hit_count++; 6456 break_point_hit_count++;
6442 6457
6443 // Get the name of the top frame function. 6458 // Get the name of the top frame function.
6444 if (!frame_function_name.IsEmpty()) { 6459 if (!frame_function_name.IsEmpty()) {
6445 // Get the name of the function. 6460 // Get the name of the function.
6446 const int argc = 2; 6461 const int argc = 2;
6447 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(0) }; 6462 v8::Handle<v8::Value> argv[argc] = {
6463 exec_state, v8::Integer::New(CcTest::isolate(), 0)
6464 };
6448 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state, 6465 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state,
6449 argc, argv); 6466 argc, argv);
6450 if (result->IsUndefined()) { 6467 if (result->IsUndefined()) {
6451 last_function_hit[0] = '\0'; 6468 last_function_hit[0] = '\0';
6452 } else { 6469 } else {
6453 CHECK(result->IsString()); 6470 CHECK(result->IsString());
6454 v8::Handle<v8::String> function_name(result->ToString()); 6471 v8::Handle<v8::String> function_name(result->ToString());
6455 function_name->WriteUtf8(last_function_hit); 6472 function_name->WriteUtf8(last_function_hit);
6456 } 6473 }
6457 } 6474 }
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
6853 int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name, 6870 int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name,
6854 3, -1 /* no column */); 6871 3, -1 /* no column */);
6855 int sbp2 = 6872 int sbp2 =
6856 SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name, 5, 5); 6873 SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name, 5, 5);
6857 6874
6858 after_compile_message_count = 0; 6875 after_compile_message_count = 0;
6859 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); 6876 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
6860 6877
6861 v8::ScriptOrigin origin( 6878 v8::ScriptOrigin origin(
6862 v8::String::NewFromUtf8(env->GetIsolate(), resource_name), 6879 v8::String::NewFromUtf8(env->GetIsolate(), resource_name),
6863 v8::Integer::New(10), 6880 v8::Integer::New(env->GetIsolate(), 10),
6864 v8::Integer::New(1)); 6881 v8::Integer::New(env->GetIsolate(), 1));
6865 // Compile a script whose first line number is greater than the breakpoints' 6882 // Compile a script whose first line number is greater than the breakpoints'
6866 // lines. 6883 // lines.
6867 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script), 6884 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script),
6868 &origin)->Run(); 6885 &origin)->Run();
6869 6886
6870 // If the script is compiled successfully there is exactly one after compile 6887 // 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 6888 // event. In case of an exception in debugger code after compile event is not
6872 // sent. 6889 // sent.
6873 CHECK_EQ(1, after_compile_message_count); 6890 CHECK_EQ(1, after_compile_message_count);
6874 6891
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
7198 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) { 7215 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) {
7199 CHECK(details.GetEventContext() == expected_context); 7216 CHECK(details.GetEventContext() == expected_context);
7200 CHECK_EQ(expected_callback_data, details.GetCallbackData()); 7217 CHECK_EQ(expected_callback_data, details.GetCallbackData());
7201 } 7218 }
7202 7219
7203 7220
7204 // Check that event details contain context where debug event occured. 7221 // Check that event details contain context where debug event occured.
7205 TEST(DebugEventContext) { 7222 TEST(DebugEventContext) {
7206 v8::Isolate* isolate = CcTest::isolate(); 7223 v8::Isolate* isolate = CcTest::isolate();
7207 v8::HandleScope scope(isolate); 7224 v8::HandleScope scope(isolate);
7208 expected_callback_data = v8::Int32::New(2010);
7209 expected_context = v8::Context::New(isolate); 7225 expected_context = v8::Context::New(isolate);
7226 expected_callback_data = v8::Int32::New(isolate, 2010);
7210 v8::Debug::SetDebugEventListener2(DebugEventContextChecker, 7227 v8::Debug::SetDebugEventListener2(DebugEventContextChecker,
7211 expected_callback_data); 7228 expected_callback_data);
7212 v8::Context::Scope context_scope(expected_context); 7229 v8::Context::Scope context_scope(expected_context);
7213 v8::Script::Compile( 7230 v8::Script::Compile(
7214 v8::String::NewFromUtf8(isolate, "(function(){debugger;})();"))->Run(); 7231 v8::String::NewFromUtf8(isolate, "(function(){debugger;})();"))->Run();
7215 expected_context.Clear(); 7232 expected_context.Clear();
7216 v8::Debug::SetDebugEventListener2(NULL); 7233 v8::Debug::SetDebugEventListener2(NULL);
7217 expected_context_data = v8::Handle<v8::Value>(); 7234 expected_context_data = v8::Handle<v8::Value>();
7218 CheckDebuggerUnloaded(); 7235 CheckDebuggerUnloaded();
7219 } 7236 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
7296 static bool debug_event_break_deoptimize_done = false; 7313 static bool debug_event_break_deoptimize_done = false;
7297 7314
7298 static void DebugEventBreakDeoptimize( 7315 static void DebugEventBreakDeoptimize(
7299 const v8::Debug::EventDetails& event_details) { 7316 const v8::Debug::EventDetails& event_details) {
7300 v8::DebugEvent event = event_details.GetEvent(); 7317 v8::DebugEvent event = event_details.GetEvent();
7301 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 7318 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
7302 if (event == v8::Break) { 7319 if (event == v8::Break) {
7303 if (!frame_function_name.IsEmpty()) { 7320 if (!frame_function_name.IsEmpty()) {
7304 // Get the name of the function. 7321 // Get the name of the function.
7305 const int argc = 2; 7322 const int argc = 2;
7306 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(0) }; 7323 v8::Handle<v8::Value> argv[argc] = {
7324 exec_state, v8::Integer::New(CcTest::isolate(), 0)
7325 };
7307 v8::Handle<v8::Value> result = 7326 v8::Handle<v8::Value> result =
7308 frame_function_name->Call(exec_state, argc, argv); 7327 frame_function_name->Call(exec_state, argc, argv);
7309 if (!result->IsUndefined()) { 7328 if (!result->IsUndefined()) {
7310 char fn[80]; 7329 char fn[80];
7311 CHECK(result->IsString()); 7330 CHECK(result->IsString());
7312 v8::Handle<v8::String> function_name(result->ToString()); 7331 v8::Handle<v8::String> function_name(result->ToString());
7313 function_name->WriteUtf8(fn); 7332 function_name->WriteUtf8(fn);
7314 if (strcmp(fn, "bar") == 0) { 7333 if (strcmp(fn, "bar") == 0) {
7315 i::Deoptimizer::DeoptimizeAll(CcTest::i_isolate()); 7334 i::Deoptimizer::DeoptimizeAll(CcTest::i_isolate());
7316 debug_event_break_deoptimize_done = true; 7335 debug_event_break_deoptimize_done = true;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
7360 7379
7361 static void DebugEventBreakWithOptimizedStack( 7380 static void DebugEventBreakWithOptimizedStack(
7362 const v8::Debug::EventDetails& event_details) { 7381 const v8::Debug::EventDetails& event_details) {
7363 v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate(); 7382 v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate();
7364 v8::DebugEvent event = event_details.GetEvent(); 7383 v8::DebugEvent event = event_details.GetEvent();
7365 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 7384 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
7366 if (event == v8::Break) { 7385 if (event == v8::Break) {
7367 if (!frame_function_name.IsEmpty()) { 7386 if (!frame_function_name.IsEmpty()) {
7368 for (int i = 0; i < 2; i++) { 7387 for (int i = 0; i < 2; i++) {
7369 const int argc = 2; 7388 const int argc = 2;
7370 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(i) }; 7389 v8::Handle<v8::Value> argv[argc] = {
7390 exec_state, v8::Integer::New(isolate, i)
7391 };
7371 // Get the name of the function in frame i. 7392 // Get the name of the function in frame i.
7372 v8::Handle<v8::Value> result = 7393 v8::Handle<v8::Value> result =
7373 frame_function_name->Call(exec_state, argc, argv); 7394 frame_function_name->Call(exec_state, argc, argv);
7374 CHECK(result->IsString()); 7395 CHECK(result->IsString());
7375 v8::Handle<v8::String> function_name(result->ToString()); 7396 v8::Handle<v8::String> function_name(result->ToString());
7376 CHECK(function_name->Equals(v8::String::NewFromUtf8(isolate, "loop"))); 7397 CHECK(function_name->Equals(v8::String::NewFromUtf8(isolate, "loop")));
7377 // Get the name of the first argument in frame i. 7398 // Get the name of the first argument in frame i.
7378 result = frame_argument_name->Call(exec_state, argc, argv); 7399 result = frame_argument_name->Call(exec_state, argc, argv);
7379 CHECK(result->IsString()); 7400 CHECK(result->IsString());
7380 v8::Handle<v8::String> argument_name(result->ToString()); 7401 v8::Handle<v8::String> argument_name(result->ToString());
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
7670 TEST(LiveEditDisabled) { 7691 TEST(LiveEditDisabled) {
7671 v8::internal::FLAG_allow_natives_syntax = true; 7692 v8::internal::FLAG_allow_natives_syntax = true;
7672 LocalContext env; 7693 LocalContext env;
7673 v8::HandleScope scope(env->GetIsolate()); 7694 v8::HandleScope scope(env->GetIsolate());
7674 v8::Debug::SetLiveEditEnabled(false, env->GetIsolate()); 7695 v8::Debug::SetLiveEditEnabled(false, env->GetIsolate());
7675 CompileRun("%LiveEditCompareStrings('', '')"); 7696 CompileRun("%LiveEditCompareStrings('', '')");
7676 } 7697 }
7677 7698
7678 7699
7679 #endif // ENABLE_DEBUGGER_SUPPORT 7700 #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