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

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

Issue 119013004: Revert "More API cleanup." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years 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] = { 647 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(0) };
648 exec_state, v8::Integer::New(CcTest::isolate(), 0)
649 };
650 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state, 648 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state,
651 argc, argv); 649 argc, argv);
652 if (result->IsUndefined()) { 650 if (result->IsUndefined()) {
653 last_function_hit[0] = '\0'; 651 last_function_hit[0] = '\0';
654 } else { 652 } else {
655 CHECK(result->IsString()); 653 CHECK(result->IsString());
656 v8::Handle<v8::String> function_name(result->ToString()); 654 v8::Handle<v8::String> function_name(result->ToString());
657 function_name->WriteUtf8(last_function_hit); 655 function_name->WriteUtf8(last_function_hit);
658 } 656 }
659 } 657 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 884 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
887 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); 885 v8::internal::Debug* debug = CcTest::i_isolate()->debug();
888 // When hitting a debug event listener there must be a break set. 886 // When hitting a debug event listener there must be a break set.
889 CHECK_NE(debug->break_id(), 0); 887 CHECK_NE(debug->break_id(), 0);
890 888
891 if (event == v8::Break || event == v8::Exception) { 889 if (event == v8::Break || event == v8::Exception) {
892 // Check that the current function is the expected. 890 // Check that the current function is the expected.
893 CHECK(break_point_hit_count < 891 CHECK(break_point_hit_count <
894 StrLength(expected_step_sequence)); 892 StrLength(expected_step_sequence));
895 const int argc = 2; 893 const int argc = 2;
896 v8::Handle<v8::Value> argv[argc] = { 894 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(0) };
897 exec_state, v8::Integer::New(CcTest::isolate(), 0)
898 };
899 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state, 895 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state,
900 argc, argv); 896 argc, argv);
901 CHECK(result->IsString()); 897 CHECK(result->IsString());
902 v8::String::Utf8Value function_name(result->ToString()); 898 v8::String::Utf8Value function_name(result->ToString());
903 CHECK_EQ(1, StrLength(*function_name)); 899 CHECK_EQ(1, StrLength(*function_name));
904 CHECK_EQ((*function_name)[0], 900 CHECK_EQ((*function_name)[0],
905 expected_step_sequence[break_point_hit_count]); 901 expected_step_sequence[break_point_hit_count]);
906 902
907 // Perform step. 903 // Perform step.
908 break_point_hit_count++; 904 break_point_hit_count++;
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 v8::Local<v8::String> script = v8::String::NewFromUtf8( 2089 v8::Local<v8::String> script = v8::String::NewFromUtf8(
2094 env->GetIsolate(), 2090 env->GetIsolate(),
2095 "function f() {\n" 2091 "function f() {\n"
2096 " a = 0; // line 8 as this script has line offset 7\n" 2092 " a = 0; // line 8 as this script has line offset 7\n"
2097 " b = 0; // line 9 as this script has line offset 7\n" 2093 " b = 0; // line 9 as this script has line offset 7\n"
2098 "}"); 2094 "}");
2099 2095
2100 // Create script origin both name and line offset. 2096 // Create script origin both name and line offset.
2101 v8::ScriptOrigin origin( 2097 v8::ScriptOrigin origin(
2102 v8::String::NewFromUtf8(env->GetIsolate(), "test.html"), 2098 v8::String::NewFromUtf8(env->GetIsolate(), "test.html"),
2103 v8::Integer::New(env->GetIsolate(), 7)); 2099 v8::Integer::New(7));
2104 2100
2105 // Set two script break points before the script is loaded. 2101 // Set two script break points before the script is loaded.
2106 int sbp1 = 2102 int sbp1 =
2107 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 8, 0); 2103 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 8, 0);
2108 int sbp2 = 2104 int sbp2 =
2109 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 9, 0); 2105 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 9, 0);
2110 2106
2111 // Compile the script and get the function. 2107 // Compile the script and get the function.
2112 v8::Script::Compile(script, &origin)->Run(); 2108 v8::Script::Compile(script, &origin)->Run();
2113 f = v8::Local<v8::Function>::Cast( 2109 f = v8::Local<v8::Function>::Cast(
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2176 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 0, -1); 2172 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 0, -1);
2177 int sbp2 = 2173 int sbp2 =
2178 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 1, -1); 2174 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 1, -1);
2179 int sbp3 = 2175 int sbp3 =
2180 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 5, -1); 2176 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 5, -1);
2181 2177
2182 // Compile the script and get the function. 2178 // Compile the script and get the function.
2183 break_point_hit_count = 0; 2179 break_point_hit_count = 0;
2184 v8::ScriptOrigin origin( 2180 v8::ScriptOrigin origin(
2185 v8::String::NewFromUtf8(env->GetIsolate(), "test.html"), 2181 v8::String::NewFromUtf8(env->GetIsolate(), "test.html"),
2186 v8::Integer::New(env->GetIsolate(), 0)); 2182 v8::Integer::New(0));
2187 v8::Script::Compile(script, &origin)->Run(); 2183 v8::Script::Compile(script, &origin)->Run();
2188 f = v8::Local<v8::Function>::Cast( 2184 f = v8::Local<v8::Function>::Cast(
2189 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 2185 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
2190 g = v8::Local<v8::Function>::Cast( 2186 g = v8::Local<v8::Function>::Cast(
2191 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); 2187 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g")));
2192 2188
2193 // Check that a break point was hit when the script was run. 2189 // Check that a break point was hit when the script was run.
2194 CHECK_EQ(1, break_point_hit_count); 2190 CHECK_EQ(1, break_point_hit_count);
2195 CHECK_EQ(0, StrLength(last_function_hit)); 2191 CHECK_EQ(0, StrLength(last_function_hit));
2196 2192
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
2511 " y=0;a=x;" 2507 " y=0;a=x;"
2512 "}", 2508 "}",
2513 "bar"); 2509 "bar");
2514 const int barbar_break_position = 8; 2510 const int barbar_break_position = 8;
2515 2511
2516 // Call bar setting breakpoint before a=x in barbar and undefined as 2512 // Call bar setting breakpoint before a=x in barbar and undefined as
2517 // parameter. 2513 // parameter.
2518 checks = checks_uu; 2514 checks = checks_uu;
2519 v8::Handle<v8::Value> argv_bar_1[2] = { 2515 v8::Handle<v8::Value> argv_bar_1[2] = {
2520 v8::Undefined(isolate), 2516 v8::Undefined(isolate),
2521 v8::Number::New(isolate, barbar_break_position) 2517 v8::Number::New(barbar_break_position)
2522 }; 2518 };
2523 bar->Call(env->Global(), 2, argv_bar_1); 2519 bar->Call(env->Global(), 2, argv_bar_1);
2524 2520
2525 // Call bar setting breakpoint before a=x in barbar and parameter 2521 // Call bar setting breakpoint before a=x in barbar and parameter
2526 // "Hello, world!". 2522 // "Hello, world!".
2527 checks = checks_hu; 2523 checks = checks_hu;
2528 v8::Handle<v8::Value> argv_bar_2[2] = { 2524 v8::Handle<v8::Value> argv_bar_2[2] = {
2529 v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!"), 2525 v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!"),
2530 v8::Number::New(env->GetIsolate(), barbar_break_position) 2526 v8::Number::New(barbar_break_position)
2531 }; 2527 };
2532 bar->Call(env->Global(), 2, argv_bar_2); 2528 bar->Call(env->Global(), 2, argv_bar_2);
2533 2529
2534 // Call bar setting breakpoint after a=x in barbar and parameter 2530 // Call bar setting breakpoint after a=x in barbar and parameter
2535 // "Hello, world!". 2531 // "Hello, world!".
2536 checks = checks_hh; 2532 checks = checks_hh;
2537 v8::Handle<v8::Value> argv_bar_3[2] = { 2533 v8::Handle<v8::Value> argv_bar_3[2] = {
2538 v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!"), 2534 v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!"),
2539 v8::Number::New(env->GetIsolate(), barbar_break_position + 1) 2535 v8::Number::New(barbar_break_position + 1)
2540 }; 2536 };
2541 bar->Call(env->Global(), 2, argv_bar_3); 2537 bar->Call(env->Global(), 2, argv_bar_3);
2542 2538
2543 v8::Debug::SetDebugEventListener2(NULL); 2539 v8::Debug::SetDebugEventListener2(NULL);
2544 CheckDebuggerUnloaded(); 2540 CheckDebuggerUnloaded();
2545 } 2541 }
2546 2542
2547 2543
2548 int debugEventCount = 0; 2544 int debugEventCount = 0;
2549 static void CheckDebugEvent(const v8::Debug::EventDetails& eventDetails) { 2545 static void CheckDebugEvent(const v8::Debug::EventDetails& eventDetails) {
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
2862 " y = 1;\n" 2858 " y = 1;\n"
2863 " x = a[i];\n" 2859 " x = a[i];\n"
2864 " }\n" 2860 " }\n"
2865 "}\n" 2861 "}\n"
2866 "y=0\n", 2862 "y=0\n",
2867 "foo"); 2863 "foo");
2868 2864
2869 // Create array [0,1,2,3,4,5,6,7,8,9] 2865 // Create array [0,1,2,3,4,5,6,7,8,9]
2870 v8::Local<v8::Array> a = v8::Array::New(env->GetIsolate(), 10); 2866 v8::Local<v8::Array> a = v8::Array::New(env->GetIsolate(), 10);
2871 for (int i = 0; i < 10; i++) { 2867 for (int i = 0; i < 10; i++) {
2872 a->Set(v8::Number::New(env->GetIsolate(), i), 2868 a->Set(v8::Number::New(i), v8::Number::New(i));
2873 v8::Number::New(env->GetIsolate(), i));
2874 } 2869 }
2875 2870
2876 // Call function without any break points to ensure inlining is in place. 2871 // Call function without any break points to ensure inlining is in place.
2877 const int kArgc = 1; 2872 const int kArgc = 1;
2878 v8::Handle<v8::Value> args[kArgc] = { a }; 2873 v8::Handle<v8::Value> args[kArgc] = { a };
2879 foo->Call(env->Global(), kArgc, args); 2874 foo->Call(env->Global(), kArgc, args);
2880 2875
2881 // Set up break point and step through the function. 2876 // Set up break point and step through the function.
2882 SetBreakPoint(foo, 3); 2877 SetBreakPoint(foo, 3);
2883 step_action = StepNext; 2878 step_action = StepNext;
(...skipping 26 matching lines...) Expand all
2910 " y = 1;\n" 2905 " y = 1;\n"
2911 " a[i] = 42;\n" 2906 " a[i] = 42;\n"
2912 " }\n" 2907 " }\n"
2913 "}\n" 2908 "}\n"
2914 "y=0\n", 2909 "y=0\n",
2915 "foo"); 2910 "foo");
2916 2911
2917 // Create array [0,1,2,3,4,5,6,7,8,9] 2912 // Create array [0,1,2,3,4,5,6,7,8,9]
2918 v8::Local<v8::Array> a = v8::Array::New(env->GetIsolate(), 10); 2913 v8::Local<v8::Array> a = v8::Array::New(env->GetIsolate(), 10);
2919 for (int i = 0; i < 10; i++) { 2914 for (int i = 0; i < 10; i++) {
2920 a->Set(v8::Number::New(env->GetIsolate(), i), 2915 a->Set(v8::Number::New(i), v8::Number::New(i));
2921 v8::Number::New(env->GetIsolate(), i));
2922 } 2916 }
2923 2917
2924 // Call function without any break points to ensure inlining is in place. 2918 // Call function without any break points to ensure inlining is in place.
2925 const int kArgc = 1; 2919 const int kArgc = 1;
2926 v8::Handle<v8::Value> args[kArgc] = { a }; 2920 v8::Handle<v8::Value> args[kArgc] = { a };
2927 foo->Call(env->Global(), kArgc, args); 2921 foo->Call(env->Global(), kArgc, args);
2928 2922
2929 // Set up break point and step through the function. 2923 // Set up break point and step through the function.
2930 SetBreakPoint(foo, 3); 2924 SetBreakPoint(foo, 3);
2931 step_action = StepNext; 2925 step_action = StepNext;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
3177 CHECK_EQ(5, break_point_hit_count); 3171 CHECK_EQ(5, break_point_hit_count);
3178 3172
3179 // Get rid of the debug event listener. 3173 // Get rid of the debug event listener.
3180 v8::Debug::SetDebugEventListener2(NULL); 3174 v8::Debug::SetDebugEventListener2(NULL);
3181 CheckDebuggerUnloaded(); 3175 CheckDebuggerUnloaded();
3182 } 3176 }
3183 3177
3184 3178
3185 TEST(DebugStepSwitch) { 3179 TEST(DebugStepSwitch) {
3186 DebugLocalContext env; 3180 DebugLocalContext env;
3187 v8::Isolate* isolate = env->GetIsolate(); 3181 v8::HandleScope scope(env->GetIsolate());
3188 v8::HandleScope scope(isolate);
3189 3182
3190 // Register a debug event listener which steps and counts. 3183 // Register a debug event listener which steps and counts.
3191 v8::Debug::SetDebugEventListener2(DebugEventStep); 3184 v8::Debug::SetDebugEventListener2(DebugEventStep);
3192 3185
3193 // Create a function for testing stepping. Run it to allow it to get 3186 // Create a function for testing stepping. Run it to allow it to get
3194 // optimized. 3187 // optimized.
3195 const int argc = 1; 3188 const int argc = 1;
3196 const char* src = "function foo(x) { " 3189 const char* src = "function foo(x) { "
3197 " a = 1;" 3190 " a = 1;"
3198 " switch (x) {" 3191 " switch (x) {"
3199 " case 1:" 3192 " case 1:"
3200 " b = 1;" 3193 " b = 1;"
3201 " case 2:" 3194 " case 2:"
3202 " c = 1;" 3195 " c = 1;"
3203 " break;" 3196 " break;"
3204 " case 3:" 3197 " case 3:"
3205 " d = 1;" 3198 " d = 1;"
3206 " e = 1;" 3199 " e = 1;"
3207 " f = 1;" 3200 " f = 1;"
3208 " break;" 3201 " break;"
3209 " }" 3202 " }"
3210 "}" 3203 "}"
3211 "a=0; b=0; c=0; d=0; e=0; f=0; foo()"; 3204 "a=0; b=0; c=0; d=0; e=0; f=0; foo()";
3212 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3205 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3213 SetBreakPoint(foo, 0); 3206 SetBreakPoint(foo, 0);
3214 3207
3215 // One case with fall-through. 3208 // One case with fall-through.
3216 step_action = StepIn; 3209 step_action = StepIn;
3217 break_point_hit_count = 0; 3210 break_point_hit_count = 0;
3218 v8::Handle<v8::Value> argv_1[argc] = { v8::Number::New(isolate, 1) }; 3211 v8::Handle<v8::Value> argv_1[argc] = { v8::Number::New(1) };
3219 foo->Call(env->Global(), argc, argv_1); 3212 foo->Call(env->Global(), argc, argv_1);
3220 CHECK_EQ(6, break_point_hit_count); 3213 CHECK_EQ(6, break_point_hit_count);
3221 3214
3222 // Another case. 3215 // Another case.
3223 step_action = StepIn; 3216 step_action = StepIn;
3224 break_point_hit_count = 0; 3217 break_point_hit_count = 0;
3225 v8::Handle<v8::Value> argv_2[argc] = { v8::Number::New(isolate, 2) }; 3218 v8::Handle<v8::Value> argv_2[argc] = { v8::Number::New(2) };
3226 foo->Call(env->Global(), argc, argv_2); 3219 foo->Call(env->Global(), argc, argv_2);
3227 CHECK_EQ(5, break_point_hit_count); 3220 CHECK_EQ(5, break_point_hit_count);
3228 3221
3229 // Last case. 3222 // Last case.
3230 step_action = StepIn; 3223 step_action = StepIn;
3231 break_point_hit_count = 0; 3224 break_point_hit_count = 0;
3232 v8::Handle<v8::Value> argv_3[argc] = { v8::Number::New(isolate, 3) }; 3225 v8::Handle<v8::Value> argv_3[argc] = { v8::Number::New(3) };
3233 foo->Call(env->Global(), argc, argv_3); 3226 foo->Call(env->Global(), argc, argv_3);
3234 CHECK_EQ(7, break_point_hit_count); 3227 CHECK_EQ(7, break_point_hit_count);
3235 3228
3236 // Get rid of the debug event listener. 3229 // Get rid of the debug event listener.
3237 v8::Debug::SetDebugEventListener2(NULL); 3230 v8::Debug::SetDebugEventListener2(NULL);
3238 CheckDebuggerUnloaded(); 3231 CheckDebuggerUnloaded();
3239 } 3232 }
3240 3233
3241 3234
3242 TEST(DebugStepWhile) { 3235 TEST(DebugStepWhile) {
3243 DebugLocalContext env; 3236 DebugLocalContext env;
3244 v8::Isolate* isolate = env->GetIsolate(); 3237 v8::HandleScope scope(env->GetIsolate());
3245 v8::HandleScope scope(isolate);
3246 3238
3247 // Register a debug event listener which steps and counts. 3239 // Register a debug event listener which steps and counts.
3248 v8::Debug::SetDebugEventListener2(DebugEventStep); 3240 v8::Debug::SetDebugEventListener2(DebugEventStep);
3249 3241
3250 // Create a function for testing stepping. Run it to allow it to get 3242 // Create a function for testing stepping. Run it to allow it to get
3251 // optimized. 3243 // optimized.
3252 const int argc = 1; 3244 const int argc = 1;
3253 const char* src = "function foo(x) { " 3245 const char* src = "function foo(x) { "
3254 " var a = 0;" 3246 " var a = 0;"
3255 " while (a < x) {" 3247 " while (a < x) {"
3256 " a++;" 3248 " a++;"
3257 " }" 3249 " }"
3258 "}" 3250 "}"
3259 "foo()"; 3251 "foo()";
3260 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3252 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3261 SetBreakPoint(foo, 8); // "var a = 0;" 3253 SetBreakPoint(foo, 8); // "var a = 0;"
3262 3254
3263 // Looping 10 times. 3255 // Looping 10 times.
3264 step_action = StepIn; 3256 step_action = StepIn;
3265 break_point_hit_count = 0; 3257 break_point_hit_count = 0;
3266 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) }; 3258 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
3267 foo->Call(env->Global(), argc, argv_10); 3259 foo->Call(env->Global(), argc, argv_10);
3268 CHECK_EQ(22, break_point_hit_count); 3260 CHECK_EQ(22, break_point_hit_count);
3269 3261
3270 // Looping 100 times. 3262 // Looping 100 times.
3271 step_action = StepIn; 3263 step_action = StepIn;
3272 break_point_hit_count = 0; 3264 break_point_hit_count = 0;
3273 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) }; 3265 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
3274 foo->Call(env->Global(), argc, argv_100); 3266 foo->Call(env->Global(), argc, argv_100);
3275 CHECK_EQ(202, break_point_hit_count); 3267 CHECK_EQ(202, break_point_hit_count);
3276 3268
3277 // Get rid of the debug event listener. 3269 // Get rid of the debug event listener.
3278 v8::Debug::SetDebugEventListener2(NULL); 3270 v8::Debug::SetDebugEventListener2(NULL);
3279 CheckDebuggerUnloaded(); 3271 CheckDebuggerUnloaded();
3280 } 3272 }
3281 3273
3282 3274
3283 TEST(DebugStepDoWhile) { 3275 TEST(DebugStepDoWhile) {
3284 DebugLocalContext env; 3276 DebugLocalContext env;
3285 v8::Isolate* isolate = env->GetIsolate(); 3277 v8::HandleScope scope(env->GetIsolate());
3286 v8::HandleScope scope(isolate);
3287 3278
3288 // Register a debug event listener which steps and counts. 3279 // Register a debug event listener which steps and counts.
3289 v8::Debug::SetDebugEventListener2(DebugEventStep); 3280 v8::Debug::SetDebugEventListener2(DebugEventStep);
3290 3281
3291 // Create a function for testing stepping. Run it to allow it to get 3282 // Create a function for testing stepping. Run it to allow it to get
3292 // optimized. 3283 // optimized.
3293 const int argc = 1; 3284 const int argc = 1;
3294 const char* src = "function foo(x) { " 3285 const char* src = "function foo(x) { "
3295 " var a = 0;" 3286 " var a = 0;"
3296 " do {" 3287 " do {"
3297 " a++;" 3288 " a++;"
3298 " } while (a < x)" 3289 " } while (a < x)"
3299 "}" 3290 "}"
3300 "foo()"; 3291 "foo()";
3301 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3292 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3302 SetBreakPoint(foo, 8); // "var a = 0;" 3293 SetBreakPoint(foo, 8); // "var a = 0;"
3303 3294
3304 // Looping 10 times. 3295 // Looping 10 times.
3305 step_action = StepIn; 3296 step_action = StepIn;
3306 break_point_hit_count = 0; 3297 break_point_hit_count = 0;
3307 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) }; 3298 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
3308 foo->Call(env->Global(), argc, argv_10); 3299 foo->Call(env->Global(), argc, argv_10);
3309 CHECK_EQ(22, break_point_hit_count); 3300 CHECK_EQ(22, break_point_hit_count);
3310 3301
3311 // Looping 100 times. 3302 // Looping 100 times.
3312 step_action = StepIn; 3303 step_action = StepIn;
3313 break_point_hit_count = 0; 3304 break_point_hit_count = 0;
3314 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) }; 3305 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
3315 foo->Call(env->Global(), argc, argv_100); 3306 foo->Call(env->Global(), argc, argv_100);
3316 CHECK_EQ(202, break_point_hit_count); 3307 CHECK_EQ(202, break_point_hit_count);
3317 3308
3318 // Get rid of the debug event listener. 3309 // Get rid of the debug event listener.
3319 v8::Debug::SetDebugEventListener2(NULL); 3310 v8::Debug::SetDebugEventListener2(NULL);
3320 CheckDebuggerUnloaded(); 3311 CheckDebuggerUnloaded();
3321 } 3312 }
3322 3313
3323 3314
3324 TEST(DebugStepFor) { 3315 TEST(DebugStepFor) {
3325 DebugLocalContext env; 3316 DebugLocalContext env;
3326 v8::Isolate* isolate = env->GetIsolate(); 3317 v8::HandleScope scope(env->GetIsolate());
3327 v8::HandleScope scope(isolate);
3328 3318
3329 // Register a debug event listener which steps and counts. 3319 // Register a debug event listener which steps and counts.
3330 v8::Debug::SetDebugEventListener2(DebugEventStep); 3320 v8::Debug::SetDebugEventListener2(DebugEventStep);
3331 3321
3332 // Create a function for testing stepping. Run it to allow it to get 3322 // Create a function for testing stepping. Run it to allow it to get
3333 // optimized. 3323 // optimized.
3334 const int argc = 1; 3324 const int argc = 1;
3335 const char* src = "function foo(x) { " 3325 const char* src = "function foo(x) { "
3336 " a = 1;" 3326 " a = 1;"
3337 " for (i = 0; i < x; i++) {" 3327 " for (i = 0; i < x; i++) {"
3338 " b = 1;" 3328 " b = 1;"
3339 " }" 3329 " }"
3340 "}" 3330 "}"
3341 "a=0; b=0; i=0; foo()"; 3331 "a=0; b=0; i=0; foo()";
3342 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3332 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3343 3333
3344 SetBreakPoint(foo, 8); // "a = 1;" 3334 SetBreakPoint(foo, 8); // "a = 1;"
3345 3335
3346 // Looping 10 times. 3336 // Looping 10 times.
3347 step_action = StepIn; 3337 step_action = StepIn;
3348 break_point_hit_count = 0; 3338 break_point_hit_count = 0;
3349 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) }; 3339 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
3350 foo->Call(env->Global(), argc, argv_10); 3340 foo->Call(env->Global(), argc, argv_10);
3351 CHECK_EQ(23, break_point_hit_count); 3341 CHECK_EQ(23, break_point_hit_count);
3352 3342
3353 // Looping 100 times. 3343 // Looping 100 times.
3354 step_action = StepIn; 3344 step_action = StepIn;
3355 break_point_hit_count = 0; 3345 break_point_hit_count = 0;
3356 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) }; 3346 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
3357 foo->Call(env->Global(), argc, argv_100); 3347 foo->Call(env->Global(), argc, argv_100);
3358 CHECK_EQ(203, break_point_hit_count); 3348 CHECK_EQ(203, break_point_hit_count);
3359 3349
3360 // Get rid of the debug event listener. 3350 // Get rid of the debug event listener.
3361 v8::Debug::SetDebugEventListener2(NULL); 3351 v8::Debug::SetDebugEventListener2(NULL);
3362 CheckDebuggerUnloaded(); 3352 CheckDebuggerUnloaded();
3363 } 3353 }
3364 3354
3365 3355
3366 TEST(DebugStepForContinue) { 3356 TEST(DebugStepForContinue) {
3367 DebugLocalContext env; 3357 DebugLocalContext env;
3368 v8::Isolate* isolate = env->GetIsolate(); 3358 v8::HandleScope scope(env->GetIsolate());
3369 v8::HandleScope scope(isolate);
3370 3359
3371 // Register a debug event listener which steps and counts. 3360 // Register a debug event listener which steps and counts.
3372 v8::Debug::SetDebugEventListener2(DebugEventStep); 3361 v8::Debug::SetDebugEventListener2(DebugEventStep);
3373 3362
3374 // Create a function for testing stepping. Run it to allow it to get 3363 // Create a function for testing stepping. Run it to allow it to get
3375 // optimized. 3364 // optimized.
3376 const int argc = 1; 3365 const int argc = 1;
3377 const char* src = "function foo(x) { " 3366 const char* src = "function foo(x) { "
3378 " var a = 0;" 3367 " var a = 0;"
3379 " var b = 0;" 3368 " var b = 0;"
3380 " var c = 0;" 3369 " var c = 0;"
3381 " for (var i = 0; i < x; i++) {" 3370 " for (var i = 0; i < x; i++) {"
3382 " a++;" 3371 " a++;"
3383 " if (a % 2 == 0) continue;" 3372 " if (a % 2 == 0) continue;"
3384 " b++;" 3373 " b++;"
3385 " c++;" 3374 " c++;"
3386 " }" 3375 " }"
3387 " return b;" 3376 " return b;"
3388 "}" 3377 "}"
3389 "foo()"; 3378 "foo()";
3390 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3379 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3391 v8::Handle<v8::Value> result; 3380 v8::Handle<v8::Value> result;
3392 SetBreakPoint(foo, 8); // "var a = 0;" 3381 SetBreakPoint(foo, 8); // "var a = 0;"
3393 3382
3394 // Each loop generates 4 or 5 steps depending on whether a is equal. 3383 // Each loop generates 4 or 5 steps depending on whether a is equal.
3395 3384
3396 // Looping 10 times. 3385 // Looping 10 times.
3397 step_action = StepIn; 3386 step_action = StepIn;
3398 break_point_hit_count = 0; 3387 break_point_hit_count = 0;
3399 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) }; 3388 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
3400 result = foo->Call(env->Global(), argc, argv_10); 3389 result = foo->Call(env->Global(), argc, argv_10);
3401 CHECK_EQ(5, result->Int32Value()); 3390 CHECK_EQ(5, result->Int32Value());
3402 CHECK_EQ(52, break_point_hit_count); 3391 CHECK_EQ(52, break_point_hit_count);
3403 3392
3404 // Looping 100 times. 3393 // Looping 100 times.
3405 step_action = StepIn; 3394 step_action = StepIn;
3406 break_point_hit_count = 0; 3395 break_point_hit_count = 0;
3407 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) }; 3396 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
3408 result = foo->Call(env->Global(), argc, argv_100); 3397 result = foo->Call(env->Global(), argc, argv_100);
3409 CHECK_EQ(50, result->Int32Value()); 3398 CHECK_EQ(50, result->Int32Value());
3410 CHECK_EQ(457, break_point_hit_count); 3399 CHECK_EQ(457, break_point_hit_count);
3411 3400
3412 // Get rid of the debug event listener. 3401 // Get rid of the debug event listener.
3413 v8::Debug::SetDebugEventListener2(NULL); 3402 v8::Debug::SetDebugEventListener2(NULL);
3414 CheckDebuggerUnloaded(); 3403 CheckDebuggerUnloaded();
3415 } 3404 }
3416 3405
3417 3406
3418 TEST(DebugStepForBreak) { 3407 TEST(DebugStepForBreak) {
3419 DebugLocalContext env; 3408 DebugLocalContext env;
3420 v8::Isolate* isolate = env->GetIsolate(); 3409 v8::HandleScope scope(env->GetIsolate());
3421 v8::HandleScope scope(isolate);
3422 3410
3423 // Register a debug event listener which steps and counts. 3411 // Register a debug event listener which steps and counts.
3424 v8::Debug::SetDebugEventListener2(DebugEventStep); 3412 v8::Debug::SetDebugEventListener2(DebugEventStep);
3425 3413
3426 // Create a function for testing stepping. Run it to allow it to get 3414 // Create a function for testing stepping. Run it to allow it to get
3427 // optimized. 3415 // optimized.
3428 const int argc = 1; 3416 const int argc = 1;
3429 const char* src = "function foo(x) { " 3417 const char* src = "function foo(x) { "
3430 " var a = 0;" 3418 " var a = 0;"
3431 " var b = 0;" 3419 " var b = 0;"
(...skipping 10 matching lines...) Expand all
3442 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3430 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3443 v8::Handle<v8::Value> result; 3431 v8::Handle<v8::Value> result;
3444 SetBreakPoint(foo, 8); // "var a = 0;" 3432 SetBreakPoint(foo, 8); // "var a = 0;"
3445 3433
3446 // Each loop generates 5 steps except for the last (when break is executed) 3434 // Each loop generates 5 steps except for the last (when break is executed)
3447 // which only generates 4. 3435 // which only generates 4.
3448 3436
3449 // Looping 10 times. 3437 // Looping 10 times.
3450 step_action = StepIn; 3438 step_action = StepIn;
3451 break_point_hit_count = 0; 3439 break_point_hit_count = 0;
3452 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) }; 3440 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
3453 result = foo->Call(env->Global(), argc, argv_10); 3441 result = foo->Call(env->Global(), argc, argv_10);
3454 CHECK_EQ(9, result->Int32Value()); 3442 CHECK_EQ(9, result->Int32Value());
3455 CHECK_EQ(55, break_point_hit_count); 3443 CHECK_EQ(55, break_point_hit_count);
3456 3444
3457 // Looping 100 times. 3445 // Looping 100 times.
3458 step_action = StepIn; 3446 step_action = StepIn;
3459 break_point_hit_count = 0; 3447 break_point_hit_count = 0;
3460 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) }; 3448 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
3461 result = foo->Call(env->Global(), argc, argv_100); 3449 result = foo->Call(env->Global(), argc, argv_100);
3462 CHECK_EQ(99, result->Int32Value()); 3450 CHECK_EQ(99, result->Int32Value());
3463 CHECK_EQ(505, break_point_hit_count); 3451 CHECK_EQ(505, break_point_hit_count);
3464 3452
3465 // Get rid of the debug event listener. 3453 // Get rid of the debug event listener.
3466 v8::Debug::SetDebugEventListener2(NULL); 3454 v8::Debug::SetDebugEventListener2(NULL);
3467 CheckDebuggerUnloaded(); 3455 CheckDebuggerUnloaded();
3468 } 3456 }
3469 3457
3470 3458
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3525 3513
3526 // Create a function for testing stepping. Run it to allow it to get 3514 // Create a function for testing stepping. Run it to allow it to get
3527 // optimized. 3515 // optimized.
3528 const char* src = "function foo(x) { " 3516 const char* src = "function foo(x) { "
3529 " var a = {};" 3517 " var a = {};"
3530 " with (a) {}" 3518 " with (a) {}"
3531 " with (b) {}" 3519 " with (b) {}"
3532 "}" 3520 "}"
3533 "foo()"; 3521 "foo()";
3534 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "b"), 3522 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "b"),
3535 v8::Object::New(env->GetIsolate())); 3523 v8::Object::New());
3536 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3524 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3537 v8::Handle<v8::Value> result; 3525 v8::Handle<v8::Value> result;
3538 SetBreakPoint(foo, 8); // "var a = {};" 3526 SetBreakPoint(foo, 8); // "var a = {};"
3539 3527
3540 step_action = StepIn; 3528 step_action = StepIn;
3541 break_point_hit_count = 0; 3529 break_point_hit_count = 0;
3542 foo->Call(env->Global(), 0, NULL); 3530 foo->Call(env->Global(), 0, NULL);
3543 CHECK_EQ(4, break_point_hit_count); 3531 CHECK_EQ(4, break_point_hit_count);
3544 3532
3545 // Get rid of the debug event listener. 3533 // Get rid of the debug event listener.
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
3864 // Create a script that returns a function. 3852 // Create a script that returns a function.
3865 const char* src = "(function (evt) {})"; 3853 const char* src = "(function (evt) {})";
3866 const char* script_name = "StepInHandlerTest"; 3854 const char* script_name = "StepInHandlerTest";
3867 3855
3868 // Set breakpoint in the script. 3856 // Set breakpoint in the script.
3869 SetScriptBreakPointByNameFromJS(env->GetIsolate(), script_name, 0, -1); 3857 SetScriptBreakPointByNameFromJS(env->GetIsolate(), script_name, 0, -1);
3870 break_point_hit_count = 0; 3858 break_point_hit_count = 0;
3871 3859
3872 v8::ScriptOrigin origin( 3860 v8::ScriptOrigin origin(
3873 v8::String::NewFromUtf8(env->GetIsolate(), script_name), 3861 v8::String::NewFromUtf8(env->GetIsolate(), script_name),
3874 v8::Integer::New(env->GetIsolate(), 0)); 3862 v8::Integer::New(0));
3875 v8::Handle<v8::Script> script = v8::Script::Compile( 3863 v8::Handle<v8::Script> script = v8::Script::Compile(
3876 v8::String::NewFromUtf8(env->GetIsolate(), src), &origin); 3864 v8::String::NewFromUtf8(env->GetIsolate(), src), &origin);
3877 v8::Local<v8::Value> r = script->Run(); 3865 v8::Local<v8::Value> r = script->Run();
3878 3866
3879 CHECK(r->IsFunction()); 3867 CHECK(r->IsFunction());
3880 CHECK_EQ(1, break_point_hit_count); 3868 CHECK_EQ(1, break_point_hit_count);
3881 3869
3882 // Get rid of the debug event listener. 3870 // Get rid of the debug event listener.
3883 v8::Debug::SetDebugEventListener2(NULL); 3871 v8::Debug::SetDebugEventListener2(NULL);
3884 CheckDebuggerUnloaded(); 3872 CheckDebuggerUnloaded();
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
4176 CheckDebuggerUnloaded(); 4164 CheckDebuggerUnloaded();
4177 } 4165 }
4178 4166
4179 4167
4180 TEST(DebugBreak) { 4168 TEST(DebugBreak) {
4181 i::FLAG_stress_compaction = false; 4169 i::FLAG_stress_compaction = false;
4182 #ifdef VERIFY_HEAP 4170 #ifdef VERIFY_HEAP
4183 i::FLAG_verify_heap = true; 4171 i::FLAG_verify_heap = true;
4184 #endif 4172 #endif
4185 DebugLocalContext env; 4173 DebugLocalContext env;
4186 v8::Isolate* isolate = env->GetIsolate(); 4174 v8::HandleScope scope(env->GetIsolate());
4187 v8::HandleScope scope(isolate);
4188 4175
4189 // Register a debug event listener which sets the break flag and counts. 4176 // Register a debug event listener which sets the break flag and counts.
4190 v8::Debug::SetDebugEventListener2(DebugEventBreak); 4177 v8::Debug::SetDebugEventListener2(DebugEventBreak);
4191 4178
4192 // Create a function for testing stepping. 4179 // Create a function for testing stepping.
4193 const char* src = "function f0() {}" 4180 const char* src = "function f0() {}"
4194 "function f1(x1) {}" 4181 "function f1(x1) {}"
4195 "function f2(x1,x2) {}" 4182 "function f2(x1,x2) {}"
4196 "function f3(x1,x2,x3) {}"; 4183 "function f3(x1,x2,x3) {}";
4197 v8::Local<v8::Function> f0 = CompileFunction(&env, src, "f0"); 4184 v8::Local<v8::Function> f0 = CompileFunction(&env, src, "f0");
4198 v8::Local<v8::Function> f1 = CompileFunction(&env, src, "f1"); 4185 v8::Local<v8::Function> f1 = CompileFunction(&env, src, "f1");
4199 v8::Local<v8::Function> f2 = CompileFunction(&env, src, "f2"); 4186 v8::Local<v8::Function> f2 = CompileFunction(&env, src, "f2");
4200 v8::Local<v8::Function> f3 = CompileFunction(&env, src, "f3"); 4187 v8::Local<v8::Function> f3 = CompileFunction(&env, src, "f3");
4201 4188
4202 // Call the function to make sure it is compiled. 4189 // Call the function to make sure it is compiled.
4203 v8::Handle<v8::Value> argv[] = { v8::Number::New(isolate, 1), 4190 v8::Handle<v8::Value> argv[] = { v8::Number::New(1),
4204 v8::Number::New(isolate, 1), 4191 v8::Number::New(1),
4205 v8::Number::New(isolate, 1), 4192 v8::Number::New(1),
4206 v8::Number::New(isolate, 1) }; 4193 v8::Number::New(1) };
4207 4194
4208 // Call all functions to make sure that they are compiled. 4195 // Call all functions to make sure that they are compiled.
4209 f0->Call(env->Global(), 0, NULL); 4196 f0->Call(env->Global(), 0, NULL);
4210 f1->Call(env->Global(), 0, NULL); 4197 f1->Call(env->Global(), 0, NULL);
4211 f2->Call(env->Global(), 0, NULL); 4198 f2->Call(env->Global(), 0, NULL);
4212 f3->Call(env->Global(), 0, NULL); 4199 f3->Call(env->Global(), 0, NULL);
4213 4200
4214 // Set the debug break flag. 4201 // Set the debug break flag.
4215 v8::Debug::DebugBreak(env->GetIsolate()); 4202 v8::Debug::DebugBreak(env->GetIsolate());
4216 4203
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
4300 CHECK_EQ(0, break_point_hit_count); 4287 CHECK_EQ(0, break_point_hit_count);
4301 4288
4302 // Get rid of the debug event listener. 4289 // Get rid of the debug event listener.
4303 v8::Debug::SetDebugEventListener2(NULL); 4290 v8::Debug::SetDebugEventListener2(NULL);
4304 CheckDebuggerUnloaded(); 4291 CheckDebuggerUnloaded();
4305 } 4292 }
4306 4293
4307 4294
4308 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { 4295 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
4309 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 3); 4296 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 3);
4310 result->Set(v8::Integer::New(info.GetIsolate(), 0), 4297 result->Set(v8::Integer::New(0),
4311 v8::String::NewFromUtf8(info.GetIsolate(), "a")); 4298 v8::String::NewFromUtf8(info.GetIsolate(), "a"));
4312 result->Set(v8::Integer::New(info.GetIsolate(), 1), 4299 result->Set(v8::Integer::New(1),
4313 v8::String::NewFromUtf8(info.GetIsolate(), "b")); 4300 v8::String::NewFromUtf8(info.GetIsolate(), "b"));
4314 result->Set(v8::Integer::New(info.GetIsolate(), 2), 4301 result->Set(v8::Integer::New(2),
4315 v8::String::NewFromUtf8(info.GetIsolate(), "c")); 4302 v8::String::NewFromUtf8(info.GetIsolate(), "c"));
4316 info.GetReturnValue().Set(result); 4303 info.GetReturnValue().Set(result);
4317 } 4304 }
4318 4305
4319 4306
4320 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { 4307 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
4321 v8::Isolate* isolate = info.GetIsolate(); 4308 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2);
4322 v8::Handle<v8::Array> result = v8::Array::New(isolate, 2); 4309 result->Set(v8::Integer::New(0), v8::Number::New(1));
4323 result->Set(v8::Integer::New(isolate, 0), v8::Number::New(isolate, 1)); 4310 result->Set(v8::Integer::New(1), v8::Number::New(10));
4324 result->Set(v8::Integer::New(isolate, 1), v8::Number::New(isolate, 10));
4325 info.GetReturnValue().Set(result); 4311 info.GetReturnValue().Set(result);
4326 } 4312 }
4327 4313
4328 4314
4329 static void NamedGetter(v8::Local<v8::String> name, 4315 static void NamedGetter(v8::Local<v8::String> name,
4330 const v8::PropertyCallbackInfo<v8::Value>& info) { 4316 const v8::PropertyCallbackInfo<v8::Value>& info) {
4331 v8::String::Utf8Value n(name); 4317 v8::String::Utf8Value n(name);
4332 if (strcmp(*n, "a") == 0) { 4318 if (strcmp(*n, "a") == 0) {
4333 info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "AA")); 4319 info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "AA"));
4334 return; 4320 return;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
4489 4475
4490 TEST(HiddenPrototypePropertyMirror) { 4476 TEST(HiddenPrototypePropertyMirror) {
4491 // Create a V8 environment with debug access. 4477 // Create a V8 environment with debug access.
4492 DebugLocalContext env; 4478 DebugLocalContext env;
4493 v8::Isolate* isolate = env->GetIsolate(); 4479 v8::Isolate* isolate = env->GetIsolate();
4494 v8::HandleScope scope(isolate); 4480 v8::HandleScope scope(isolate);
4495 env.ExposeDebug(); 4481 env.ExposeDebug();
4496 4482
4497 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate); 4483 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
4498 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "x"), 4484 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "x"),
4499 v8::Number::New(isolate, 0)); 4485 v8::Number::New(0));
4500 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); 4486 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
4501 t1->SetHiddenPrototype(true); 4487 t1->SetHiddenPrototype(true);
4502 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "y"), 4488 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "y"),
4503 v8::Number::New(isolate, 1)); 4489 v8::Number::New(1));
4504 v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate); 4490 v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate);
4505 t2->SetHiddenPrototype(true); 4491 t2->SetHiddenPrototype(true);
4506 t2->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "z"), 4492 t2->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "z"),
4507 v8::Number::New(isolate, 2)); 4493 v8::Number::New(2));
4508 v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate); 4494 v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate);
4509 t3->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "u"), 4495 t3->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "u"),
4510 v8::Number::New(isolate, 3)); 4496 v8::Number::New(3));
4511 4497
4512 // Create object and set them on the global object. 4498 // Create object and set them on the global object.
4513 v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance(); 4499 v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance();
4514 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o0"), o0); 4500 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o0"), o0);
4515 v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance(); 4501 v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance();
4516 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o1"), o1); 4502 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o1"), o1);
4517 v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance(); 4503 v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance();
4518 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o2"), o2); 4504 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o2"), o2);
4519 v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance(); 4505 v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance();
4520 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o3"), o3); 4506 env->Global()->Set(v8::String::NewFromUtf8(isolate, "o3"), o3);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
4678 4664
4679 // Create an object in the global scope. 4665 // Create an object in the global scope.
4680 const char* source = "var obj = {a: 1};"; 4666 const char* source = "var obj = {a: 1};";
4681 v8::Script::Compile(v8::String::NewFromUtf8(isolate, source)) 4667 v8::Script::Compile(v8::String::NewFromUtf8(isolate, source))
4682 ->Run(); 4668 ->Run();
4683 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast( 4669 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(
4684 env->Global()->Get(v8::String::NewFromUtf8(isolate, "obj"))); 4670 env->Global()->Get(v8::String::NewFromUtf8(isolate, "obj")));
4685 // Set a hidden property on the object. 4671 // Set a hidden property on the object.
4686 obj->SetHiddenValue( 4672 obj->SetHiddenValue(
4687 v8::String::NewFromUtf8(isolate, "v8::test-debug::a"), 4673 v8::String::NewFromUtf8(isolate, "v8::test-debug::a"),
4688 v8::Int32::New(isolate, 11)); 4674 v8::Int32::New(11));
4689 4675
4690 // Get mirror for the object with property getter. 4676 // Get mirror for the object with property getter.
4691 CompileRun("var obj_mirror = debug.MakeMirror(obj);"); 4677 CompileRun("var obj_mirror = debug.MakeMirror(obj);");
4692 CHECK(CompileRun( 4678 CHECK(CompileRun(
4693 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue()); 4679 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue());
4694 CompileRun("var named_names = obj_mirror.propertyNames();"); 4680 CompileRun("var named_names = obj_mirror.propertyNames();");
4695 // There should be exactly one property. But there is also an unnamed 4681 // There should be exactly one property. But there is also an unnamed
4696 // property whose value is hidden properties dictionary. The latter 4682 // property whose value is hidden properties dictionary. The latter
4697 // property should not be in the list of reguar properties. 4683 // property should not be in the list of reguar properties.
4698 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); 4684 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value());
4699 CHECK(CompileRun("named_names[0] == 'a'")->BooleanValue()); 4685 CHECK(CompileRun("named_names[0] == 'a'")->BooleanValue());
4700 CHECK(CompileRun( 4686 CHECK(CompileRun(
4701 "obj_mirror.property('a').value().value() == 1")->BooleanValue()); 4687 "obj_mirror.property('a').value().value() == 1")->BooleanValue());
4702 4688
4703 // Object created by t0 will become hidden prototype of object 'obj'. 4689 // Object created by t0 will become hidden prototype of object 'obj'.
4704 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate); 4690 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
4705 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "b"), 4691 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "b"),
4706 v8::Number::New(isolate, 2)); 4692 v8::Number::New(2));
4707 t0->SetHiddenPrototype(true); 4693 t0->SetHiddenPrototype(true);
4708 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); 4694 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
4709 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "c"), 4695 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "c"),
4710 v8::Number::New(isolate, 3)); 4696 v8::Number::New(3));
4711 4697
4712 // Create proto objects, add hidden properties to them and set them on 4698 // Create proto objects, add hidden properties to them and set them on
4713 // the global object. 4699 // the global object.
4714 v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance(); 4700 v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance();
4715 protoObj->SetHiddenValue( 4701 protoObj->SetHiddenValue(
4716 v8::String::NewFromUtf8(isolate, "v8::test-debug::b"), 4702 v8::String::NewFromUtf8(isolate, "v8::test-debug::b"),
4717 v8::Int32::New(isolate, 12)); 4703 v8::Int32::New(12));
4718 env->Global()->Set(v8::String::NewFromUtf8(isolate, "protoObj"), 4704 env->Global()->Set(v8::String::NewFromUtf8(isolate, "protoObj"),
4719 protoObj); 4705 protoObj);
4720 v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance(); 4706 v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance();
4721 grandProtoObj->SetHiddenValue( 4707 grandProtoObj->SetHiddenValue(
4722 v8::String::NewFromUtf8(isolate, "v8::test-debug::c"), 4708 v8::String::NewFromUtf8(isolate, "v8::test-debug::c"),
4723 v8::Int32::New(isolate, 13)); 4709 v8::Int32::New(13));
4724 env->Global()->Set( 4710 env->Global()->Set(
4725 v8::String::NewFromUtf8(isolate, "grandProtoObj"), 4711 v8::String::NewFromUtf8(isolate, "grandProtoObj"),
4726 grandProtoObj); 4712 grandProtoObj);
4727 4713
4728 // Setting prototypes: obj->protoObj->grandProtoObj 4714 // Setting prototypes: obj->protoObj->grandProtoObj
4729 protoObj->Set(v8::String::NewFromUtf8(isolate, "__proto__"), 4715 protoObj->Set(v8::String::NewFromUtf8(isolate, "__proto__"),
4730 grandProtoObj); 4716 grandProtoObj);
4731 obj->Set(v8::String::NewFromUtf8(isolate, "__proto__"), protoObj); 4717 obj->Set(v8::String::NewFromUtf8(isolate, "__proto__"), protoObj);
4732 4718
4733 // Get mirror for the object with property getter. 4719 // Get mirror for the object with property getter.
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
5620 CcTest::isolate(), "debugger_call_with_data"))); 5606 CcTest::isolate(), "debugger_call_with_data")));
5621 5607
5622 // Compile a function capturing closure. 5608 // Compile a function capturing closure.
5623 debugger_call_with_closure = 5609 debugger_call_with_closure =
5624 v8::Local<v8::Function>::Cast(v8::Script::Compile( 5610 v8::Local<v8::Function>::Cast(v8::Script::Compile(
5625 v8::String::NewFromUtf8(CcTest::isolate(), 5611 v8::String::NewFromUtf8(CcTest::isolate(),
5626 debugger_call_with_closure_source))->Run()); 5612 debugger_call_with_closure_source))->Run());
5627 5613
5628 // Calling a function through the debugger returns 0 frames if there are 5614 // Calling a function through the debugger returns 0 frames if there are
5629 // no JavaScript frames. 5615 // no JavaScript frames.
5630 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 0), 5616 CHECK_EQ(v8::Integer::New(0), v8::Debug::Call(frame_count));
5631 v8::Debug::Call(frame_count));
5632 5617
5633 // Test that the number of frames can be retrieved. 5618 // Test that the number of frames can be retrieved.
5634 v8::Script::Compile( 5619 v8::Script::Compile(
5635 v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount(1)"))->Run(); 5620 v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount(1)"))->Run();
5636 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5621 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(),
5637 "function f() {" 5622 "function f() {"
5638 " CheckFrameCount(2);" 5623 " CheckFrameCount(2);"
5639 "}; f()"))->Run(); 5624 "}; f()"))->Run();
5640 5625
5641 // Test that the source line can be retrieved. 5626 // Test that the source line can be retrieved.
5642 v8::Script::Compile( 5627 v8::Script::Compile(
5643 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine(0)"))->Run(); 5628 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine(0)"))->Run();
5644 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5629 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(),
5645 "function f() {\n" 5630 "function f() {\n"
5646 " CheckSourceLine(1)\n" 5631 " CheckSourceLine(1)\n"
5647 " CheckSourceLine(2)\n" 5632 " CheckSourceLine(2)\n"
5648 " CheckSourceLine(3)\n" 5633 " CheckSourceLine(3)\n"
5649 "}; f()"))->Run(); 5634 "}; f()"))->Run();
5650 5635
5651 // Test that a parameter can be passed to a function called in the debugger. 5636 // Test that a parameter can be passed to a function called in the debugger.
5652 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5637 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(),
5653 "CheckDataParameter()"))->Run(); 5638 "CheckDataParameter()"))->Run();
5654 5639
5655 // Test that a function with closure can be run in the debugger. 5640 // Test that a function with closure can be run in the debugger.
5656 v8::Script::Compile( 5641 v8::Script::Compile(
5657 v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure()"))->Run(); 5642 v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure()"))->Run();
5658 5643
5659 // Test that the source line is correct when there is a line offset. 5644 // Test that the source line is correct when there is a line offset.
5660 v8::ScriptOrigin origin(v8::String::NewFromUtf8(CcTest::isolate(), "test"), 5645 v8::ScriptOrigin origin(v8::String::NewFromUtf8(CcTest::isolate(), "test"),
5661 v8::Integer::New(CcTest::isolate(), 7)); 5646 v8::Integer::New(7));
5662 v8::Script::Compile( 5647 v8::Script::Compile(
5663 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine(7)"), &origin) 5648 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine(7)"), &origin)
5664 ->Run(); 5649 ->Run();
5665 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), 5650 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(),
5666 "function f() {\n" 5651 "function f() {\n"
5667 " CheckSourceLine(8)\n" 5652 " CheckSourceLine(8)\n"
5668 " CheckSourceLine(9)\n" 5653 " CheckSourceLine(9)\n"
5669 " CheckSourceLine(10)\n" 5654 " CheckSourceLine(10)\n"
5670 "}; f()"), 5655 "}; f()"),
5671 &origin)->Run(); 5656 &origin)->Run();
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
6452 v8::DebugEvent event = event_details.GetEvent(); 6437 v8::DebugEvent event = event_details.GetEvent();
6453 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 6438 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
6454 6439
6455 if (event == v8::Break) { 6440 if (event == v8::Break) {
6456 break_point_hit_count++; 6441 break_point_hit_count++;
6457 6442
6458 // Get the name of the top frame function. 6443 // Get the name of the top frame function.
6459 if (!frame_function_name.IsEmpty()) { 6444 if (!frame_function_name.IsEmpty()) {
6460 // Get the name of the function. 6445 // Get the name of the function.
6461 const int argc = 2; 6446 const int argc = 2;
6462 v8::Handle<v8::Value> argv[argc] = { 6447 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(0) };
6463 exec_state, v8::Integer::New(CcTest::isolate(), 0)
6464 };
6465 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state, 6448 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state,
6466 argc, argv); 6449 argc, argv);
6467 if (result->IsUndefined()) { 6450 if (result->IsUndefined()) {
6468 last_function_hit[0] = '\0'; 6451 last_function_hit[0] = '\0';
6469 } else { 6452 } else {
6470 CHECK(result->IsString()); 6453 CHECK(result->IsString());
6471 v8::Handle<v8::String> function_name(result->ToString()); 6454 v8::Handle<v8::String> function_name(result->ToString());
6472 function_name->WriteUtf8(last_function_hit); 6455 function_name->WriteUtf8(last_function_hit);
6473 } 6456 }
6474 } 6457 }
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
6870 int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name, 6853 int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name,
6871 3, -1 /* no column */); 6854 3, -1 /* no column */);
6872 int sbp2 = 6855 int sbp2 =
6873 SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name, 5, 5); 6856 SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name, 5, 5);
6874 6857
6875 after_compile_message_count = 0; 6858 after_compile_message_count = 0;
6876 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); 6859 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
6877 6860
6878 v8::ScriptOrigin origin( 6861 v8::ScriptOrigin origin(
6879 v8::String::NewFromUtf8(env->GetIsolate(), resource_name), 6862 v8::String::NewFromUtf8(env->GetIsolate(), resource_name),
6880 v8::Integer::New(env->GetIsolate(), 10), 6863 v8::Integer::New(10),
6881 v8::Integer::New(env->GetIsolate(), 1)); 6864 v8::Integer::New(1));
6882 // Compile a script whose first line number is greater than the breakpoints' 6865 // Compile a script whose first line number is greater than the breakpoints'
6883 // lines. 6866 // lines.
6884 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script), 6867 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script),
6885 &origin)->Run(); 6868 &origin)->Run();
6886 6869
6887 // If the script is compiled successfully there is exactly one after compile 6870 // If the script is compiled successfully there is exactly one after compile
6888 // event. In case of an exception in debugger code after compile event is not 6871 // event. In case of an exception in debugger code after compile event is not
6889 // sent. 6872 // sent.
6890 CHECK_EQ(1, after_compile_message_count); 6873 CHECK_EQ(1, after_compile_message_count);
6891 6874
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
7215 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) { 7198 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) {
7216 CHECK(details.GetEventContext() == expected_context); 7199 CHECK(details.GetEventContext() == expected_context);
7217 CHECK_EQ(expected_callback_data, details.GetCallbackData()); 7200 CHECK_EQ(expected_callback_data, details.GetCallbackData());
7218 } 7201 }
7219 7202
7220 7203
7221 // Check that event details contain context where debug event occured. 7204 // Check that event details contain context where debug event occured.
7222 TEST(DebugEventContext) { 7205 TEST(DebugEventContext) {
7223 v8::Isolate* isolate = CcTest::isolate(); 7206 v8::Isolate* isolate = CcTest::isolate();
7224 v8::HandleScope scope(isolate); 7207 v8::HandleScope scope(isolate);
7208 expected_callback_data = v8::Int32::New(2010);
7225 expected_context = v8::Context::New(isolate); 7209 expected_context = v8::Context::New(isolate);
7226 expected_callback_data = v8::Int32::New(isolate, 2010);
7227 v8::Debug::SetDebugEventListener2(DebugEventContextChecker, 7210 v8::Debug::SetDebugEventListener2(DebugEventContextChecker,
7228 expected_callback_data); 7211 expected_callback_data);
7229 v8::Context::Scope context_scope(expected_context); 7212 v8::Context::Scope context_scope(expected_context);
7230 v8::Script::Compile( 7213 v8::Script::Compile(
7231 v8::String::NewFromUtf8(isolate, "(function(){debugger;})();"))->Run(); 7214 v8::String::NewFromUtf8(isolate, "(function(){debugger;})();"))->Run();
7232 expected_context.Clear(); 7215 expected_context.Clear();
7233 v8::Debug::SetDebugEventListener2(NULL); 7216 v8::Debug::SetDebugEventListener2(NULL);
7234 expected_context_data = v8::Handle<v8::Value>(); 7217 expected_context_data = v8::Handle<v8::Value>();
7235 CheckDebuggerUnloaded(); 7218 CheckDebuggerUnloaded();
7236 } 7219 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
7313 static bool debug_event_break_deoptimize_done = false; 7296 static bool debug_event_break_deoptimize_done = false;
7314 7297
7315 static void DebugEventBreakDeoptimize( 7298 static void DebugEventBreakDeoptimize(
7316 const v8::Debug::EventDetails& event_details) { 7299 const v8::Debug::EventDetails& event_details) {
7317 v8::DebugEvent event = event_details.GetEvent(); 7300 v8::DebugEvent event = event_details.GetEvent();
7318 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 7301 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
7319 if (event == v8::Break) { 7302 if (event == v8::Break) {
7320 if (!frame_function_name.IsEmpty()) { 7303 if (!frame_function_name.IsEmpty()) {
7321 // Get the name of the function. 7304 // Get the name of the function.
7322 const int argc = 2; 7305 const int argc = 2;
7323 v8::Handle<v8::Value> argv[argc] = { 7306 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(0) };
7324 exec_state, v8::Integer::New(CcTest::isolate(), 0)
7325 };
7326 v8::Handle<v8::Value> result = 7307 v8::Handle<v8::Value> result =
7327 frame_function_name->Call(exec_state, argc, argv); 7308 frame_function_name->Call(exec_state, argc, argv);
7328 if (!result->IsUndefined()) { 7309 if (!result->IsUndefined()) {
7329 char fn[80]; 7310 char fn[80];
7330 CHECK(result->IsString()); 7311 CHECK(result->IsString());
7331 v8::Handle<v8::String> function_name(result->ToString()); 7312 v8::Handle<v8::String> function_name(result->ToString());
7332 function_name->WriteUtf8(fn); 7313 function_name->WriteUtf8(fn);
7333 if (strcmp(fn, "bar") == 0) { 7314 if (strcmp(fn, "bar") == 0) {
7334 i::Deoptimizer::DeoptimizeAll(CcTest::i_isolate()); 7315 i::Deoptimizer::DeoptimizeAll(CcTest::i_isolate());
7335 debug_event_break_deoptimize_done = true; 7316 debug_event_break_deoptimize_done = true;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
7379 7360
7380 static void DebugEventBreakWithOptimizedStack( 7361 static void DebugEventBreakWithOptimizedStack(
7381 const v8::Debug::EventDetails& event_details) { 7362 const v8::Debug::EventDetails& event_details) {
7382 v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate(); 7363 v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate();
7383 v8::DebugEvent event = event_details.GetEvent(); 7364 v8::DebugEvent event = event_details.GetEvent();
7384 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 7365 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
7385 if (event == v8::Break) { 7366 if (event == v8::Break) {
7386 if (!frame_function_name.IsEmpty()) { 7367 if (!frame_function_name.IsEmpty()) {
7387 for (int i = 0; i < 2; i++) { 7368 for (int i = 0; i < 2; i++) {
7388 const int argc = 2; 7369 const int argc = 2;
7389 v8::Handle<v8::Value> argv[argc] = { 7370 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(i) };
7390 exec_state, v8::Integer::New(isolate, i)
7391 };
7392 // Get the name of the function in frame i. 7371 // Get the name of the function in frame i.
7393 v8::Handle<v8::Value> result = 7372 v8::Handle<v8::Value> result =
7394 frame_function_name->Call(exec_state, argc, argv); 7373 frame_function_name->Call(exec_state, argc, argv);
7395 CHECK(result->IsString()); 7374 CHECK(result->IsString());
7396 v8::Handle<v8::String> function_name(result->ToString()); 7375 v8::Handle<v8::String> function_name(result->ToString());
7397 CHECK(function_name->Equals(v8::String::NewFromUtf8(isolate, "loop"))); 7376 CHECK(function_name->Equals(v8::String::NewFromUtf8(isolate, "loop")));
7398 // Get the name of the first argument in frame i. 7377 // Get the name of the first argument in frame i.
7399 result = frame_argument_name->Call(exec_state, argc, argv); 7378 result = frame_argument_name->Call(exec_state, argc, argv);
7400 CHECK(result->IsString()); 7379 CHECK(result->IsString());
7401 v8::Handle<v8::String> argument_name(result->ToString()); 7380 v8::Handle<v8::String> argument_name(result->ToString());
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
7691 TEST(LiveEditDisabled) { 7670 TEST(LiveEditDisabled) {
7692 v8::internal::FLAG_allow_natives_syntax = true; 7671 v8::internal::FLAG_allow_natives_syntax = true;
7693 LocalContext env; 7672 LocalContext env;
7694 v8::HandleScope scope(env->GetIsolate()); 7673 v8::HandleScope scope(env->GetIsolate());
7695 v8::Debug::SetLiveEditEnabled(false, env->GetIsolate()); 7674 v8::Debug::SetLiveEditEnabled(false, env->GetIsolate());
7696 CompileRun("%LiveEditCompareStrings('', '')"); 7675 CompileRun("%LiveEditCompareStrings('', '')");
7697 } 7676 }
7698 7677
7699 7678
7700 #endif // ENABLE_DEBUGGER_SUPPORT 7679 #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