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

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

Issue 1218493005: Debugger: use debug break slots instead of ICs (except for calls). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comments Created 5 years, 5 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
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | test/mjsunit/debug-backtrace.js » ('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 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 } 962 }
963 963
964 static void MessageCallbackCount(v8::Handle<v8::Message> message, 964 static void MessageCallbackCount(v8::Handle<v8::Message> message,
965 v8::Handle<v8::Value> data) { 965 v8::Handle<v8::Value> data) {
966 message_callback_count++; 966 message_callback_count++;
967 } 967 }
968 968
969 969
970 // --- T h e A c t u a l T e s t s 970 // --- T h e A c t u a l T e s t s
971 971
972
973 // Test that the debug break function is the expected one for different kinds
974 // of break locations.
975 TEST(DebugStub) {
976 using ::v8::internal::Builtins;
977 using ::v8::internal::Isolate;
978 DebugLocalContext env;
979 v8::HandleScope scope(env->GetIsolate());
980
981 CheckDebugBreakFunction(&env,
982 "function f1(){}", "f1",
983 0,
984 v8::internal::RelocInfo::JS_RETURN,
985 NULL);
986 CheckDebugBreakFunction(&env,
987 "function f2(){x=1;}", "f2",
988 0,
989 v8::internal::RelocInfo::CODE_TARGET,
990 CcTest::i_isolate()->builtins()->builtin(
991 Builtins::kStoreIC_DebugBreak));
992 CheckDebugBreakFunction(
993 &env, "function f3(){x();}", "f3", 0,
994 v8::internal::RelocInfo::CODE_TARGET,
995 CcTest::i_isolate()->builtins()->builtin(Builtins::kLoadIC_DebugBreak));
996
997 // TODO(1240753): Make the test architecture independent or split
998 // parts of the debugger into architecture dependent files. This
999 // part currently disabled as it is not portable between IA32/ARM.
1000 // Currently on ICs for keyed store/load on ARM.
1001 #if !defined (__arm__) && !defined(__thumb__)
1002 CheckDebugBreakFunction(
1003 &env,
1004 "function f4(){var index='propertyName'; var a={}; a[index] = 'x';}",
1005 "f4", 39, v8::internal::RelocInfo::CODE_TARGET,
1006 CcTest::i_isolate()->builtins()->builtin(
1007 Builtins::kKeyedStoreIC_DebugBreak));
1008 CheckDebugBreakFunction(
1009 &env,
1010 "function f5(){var index='propertyName'; var a={}; return a[index];}",
1011 "f5", 39, v8::internal::RelocInfo::CODE_TARGET,
1012 CcTest::i_isolate()->builtins()->builtin(
1013 Builtins::kKeyedLoadIC_DebugBreak));
1014 #endif
1015
1016 CheckDebugBreakFunction(&env, "function f6(){(0==null)()}", "f6", 0,
1017 v8::internal::RelocInfo::CODE_TARGET,
1018 CcTest::i_isolate()->builtins()->builtin(
1019 Builtins::kCompareNilIC_DebugBreak));
1020
1021 // Check the debug break code stubs for call ICs with different number of
1022 // parameters.
1023 // TODO(verwaest): XXX update test.
1024 // Handle<Code> debug_break_0 = v8::internal::ComputeCallDebugBreak(0);
1025 // Handle<Code> debug_break_1 = v8::internal::ComputeCallDebugBreak(1);
1026 // Handle<Code> debug_break_4 = v8::internal::ComputeCallDebugBreak(4);
1027
1028 // CheckDebugBreakFunction(&env,
1029 // "function f4_0(){x();}", "f4_0",
1030 // 0,
1031 // v8::internal::RelocInfo::CODE_TARGET,
1032 // *debug_break_0);
1033
1034 // CheckDebugBreakFunction(&env,
1035 // "function f4_1(){x(1);}", "f4_1",
1036 // 0,
1037 // v8::internal::RelocInfo::CODE_TARGET,
1038 // *debug_break_1);
1039
1040 // CheckDebugBreakFunction(&env,
1041 // "function f4_4(){x(1,2,3,4);}", "f4_4",
1042 // 0,
1043 // v8::internal::RelocInfo::CODE_TARGET,
1044 // *debug_break_4);
1045 }
1046
1047
1048 // Test that the debug info in the VM is in sync with the functions being 972 // Test that the debug info in the VM is in sync with the functions being
1049 // debugged. 973 // debugged.
1050 TEST(DebugInfo) { 974 TEST(DebugInfo) {
1051 DebugLocalContext env; 975 DebugLocalContext env;
1052 v8::HandleScope scope(env->GetIsolate()); 976 v8::HandleScope scope(env->GetIsolate());
1053 // Create a couple of functions for the test. 977 // Create a couple of functions for the test.
1054 v8::Local<v8::Function> foo = 978 v8::Local<v8::Function> foo =
1055 CompileFunction(&env, "function foo(){}", "foo"); 979 CompileFunction(&env, "function foo(){}", "foo");
1056 v8::Local<v8::Function> bar = 980 v8::Local<v8::Function> bar =
1057 CompileFunction(&env, "function bar(){}", "bar"); 981 CompileFunction(&env, "function bar(){}", "bar");
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2339 break_point_hit_count = 0; 2263 break_point_hit_count = 0;
2340 DebugLocalContext env; 2264 DebugLocalContext env;
2341 v8::HandleScope scope(env->GetIsolate()); 2265 v8::HandleScope scope(env->GetIsolate());
2342 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); 2266 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount);
2343 v8::Script::Compile( 2267 v8::Script::Compile(
2344 v8::String::NewFromUtf8(env->GetIsolate(), "function foo(){debugger;}")) 2268 v8::String::NewFromUtf8(env->GetIsolate(), "function foo(){debugger;}"))
2345 ->Run(); 2269 ->Run();
2346 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( 2270 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
2347 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); 2271 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")));
2348 2272
2349 // The debugger statement triggers breakpint hit 2273 // The debugger statement triggers breakpoint hit
2350 foo->Call(env->Global(), 0, NULL); 2274 foo->Call(env->Global(), 0, NULL);
2351 CHECK_EQ(1, break_point_hit_count); 2275 CHECK_EQ(1, break_point_hit_count);
2352 2276
2353 int bp = SetBreakPoint(foo, 0); 2277 int bp = SetBreakPoint(foo, 0);
2354 2278
2355 // Set breakpoint does not duplicate hits 2279 // Set breakpoint does not duplicate hits
2356 foo->Call(env->Global(), 0, NULL); 2280 foo->Call(env->Global(), 0, NULL);
2357 CHECK_EQ(2, break_point_hit_count); 2281 CHECK_EQ(2, break_point_hit_count);
2358 2282
2359 ClearBreakPoint(bp); 2283 ClearBreakPoint(bp);
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
3263 const char* src = "function foo(x) { " 3187 const char* src = "function foo(x) { "
3264 " var a = 0;" 3188 " var a = 0;"
3265 " do {" 3189 " do {"
3266 " a++;" 3190 " a++;"
3267 " } while (a < x)" 3191 " } while (a < x)"
3268 "}" 3192 "}"
3269 "foo()"; 3193 "foo()";
3270 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3194 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3271 SetBreakPoint(foo, 8); // "var a = 0;" 3195 SetBreakPoint(foo, 8); // "var a = 0;"
3272 3196
3197 // Looping 0 times.
3198 step_action = StepIn;
3199 break_point_hit_count = 0;
3200 v8::Handle<v8::Value> argv_0[argc] = {v8::Number::New(isolate, 0)};
3201 foo->Call(env->Global(), argc, argv_0);
3202 CHECK_EQ(4, break_point_hit_count);
3203
3273 // Looping 10 times. 3204 // Looping 10 times.
3274 step_action = StepIn; 3205 step_action = StepIn;
3275 break_point_hit_count = 0; 3206 break_point_hit_count = 0;
3276 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) }; 3207 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
3277 foo->Call(env->Global(), argc, argv_10); 3208 foo->Call(env->Global(), argc, argv_10);
3278 CHECK_EQ(22, break_point_hit_count); 3209 CHECK_EQ(22, break_point_hit_count);
3279 3210
3280 // Looping 100 times. 3211 // Looping 100 times.
3281 step_action = StepIn; 3212 step_action = StepIn;
3282 break_point_hit_count = 0; 3213 break_point_hit_count = 0;
(...skipping 22 matching lines...) Expand all
3305 " a = 1;" 3236 " a = 1;"
3306 " for (i = 0; i < x; i++) {" 3237 " for (i = 0; i < x; i++) {"
3307 " b = 1;" 3238 " b = 1;"
3308 " }" 3239 " }"
3309 "}" 3240 "}"
3310 "a=0; b=0; i=0; foo()"; 3241 "a=0; b=0; i=0; foo()";
3311 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3242 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3312 3243
3313 SetBreakPoint(foo, 8); // "a = 1;" 3244 SetBreakPoint(foo, 8); // "a = 1;"
3314 3245
3246 // Looping 0 times.
3247 step_action = StepIn;
3248 break_point_hit_count = 0;
3249 v8::Handle<v8::Value> argv_0[argc] = {v8::Number::New(isolate, 0)};
3250 foo->Call(env->Global(), argc, argv_0);
3251 CHECK_EQ(4, break_point_hit_count);
3252
3315 // Looping 10 times. 3253 // Looping 10 times.
3316 step_action = StepIn; 3254 step_action = StepIn;
3317 break_point_hit_count = 0; 3255 break_point_hit_count = 0;
3318 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) }; 3256 v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
3319 foo->Call(env->Global(), argc, argv_10); 3257 foo->Call(env->Global(), argc, argv_10);
3320 CHECK_EQ(45, break_point_hit_count); 3258 CHECK_EQ(34, break_point_hit_count);
3321 3259
3322 // Looping 100 times. 3260 // Looping 100 times.
3323 step_action = StepIn; 3261 step_action = StepIn;
3324 break_point_hit_count = 0; 3262 break_point_hit_count = 0;
3325 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) }; 3263 v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
3326 foo->Call(env->Global(), argc, argv_100); 3264 foo->Call(env->Global(), argc, argv_100);
3327 CHECK_EQ(405, break_point_hit_count); 3265 CHECK_EQ(304, break_point_hit_count);
3328 3266
3329 // Get rid of the debug event listener. 3267 // Get rid of the debug event listener.
3330 v8::Debug::SetDebugEventListener(NULL); 3268 v8::Debug::SetDebugEventListener(NULL);
3331 CheckDebuggerUnloaded(); 3269 CheckDebuggerUnloaded();
3332 } 3270 }
3333 3271
3334 3272
3335 TEST(DebugStepForContinue) { 3273 TEST(DebugStepForContinue) {
3336 DebugLocalContext env; 3274 DebugLocalContext env;
3337 v8::Isolate* isolate = env->GetIsolate(); 3275 v8::Isolate* isolate = env->GetIsolate();
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
3532 " a = x ? 1 : 2;" 3470 " a = x ? 1 : 2;"
3533 " return a;" 3471 " return a;"
3534 "}" 3472 "}"
3535 "foo()"; 3473 "foo()";
3536 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3474 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3537 SetBreakPoint(foo, 0); // "var a;" 3475 SetBreakPoint(foo, 0); // "var a;"
3538 3476
3539 step_action = StepIn; 3477 step_action = StepIn;
3540 break_point_hit_count = 0; 3478 break_point_hit_count = 0;
3541 foo->Call(env->Global(), 0, NULL); 3479 foo->Call(env->Global(), 0, NULL);
3542 CHECK_EQ(5, break_point_hit_count); 3480 CHECK_EQ(4, break_point_hit_count);
3543 3481
3544 step_action = StepIn; 3482 step_action = StepIn;
3545 break_point_hit_count = 0; 3483 break_point_hit_count = 0;
3546 const int argc = 1; 3484 const int argc = 1;
3547 v8::Handle<v8::Value> argv_true[argc] = { v8::True(isolate) }; 3485 v8::Handle<v8::Value> argv_true[argc] = { v8::True(isolate) };
3548 foo->Call(env->Global(), argc, argv_true); 3486 foo->Call(env->Global(), argc, argv_true);
3549 CHECK_EQ(5, break_point_hit_count); 3487 CHECK_EQ(4, break_point_hit_count);
3550 3488
3551 // Get rid of the debug event listener. 3489 // Get rid of the debug event listener.
3552 v8::Debug::SetDebugEventListener(NULL); 3490 v8::Debug::SetDebugEventListener(NULL);
3553 CheckDebuggerUnloaded(); 3491 CheckDebuggerUnloaded();
3554 } 3492 }
3555 3493
3556 3494
3557 TEST(StepInOutSimple) { 3495 TEST(StepInOutSimple) {
3558 DebugLocalContext env; 3496 DebugLocalContext env;
3559 v8::HandleScope scope(env->GetIsolate()); 3497 v8::HandleScope scope(env->GetIsolate());
(...skipping 4132 matching lines...) Expand 10 before | Expand all | Expand 10 after
7692 "let y = 2; \n" 7630 "let y = 2; \n"
7693 "debugger; \n" 7631 "debugger; \n"
7694 "x * y", 7632 "x * y",
7695 30); 7633 30);
7696 ExpectInt32( 7634 ExpectInt32(
7697 "x = 1; y = 2; \n" 7635 "x = 1; y = 2; \n"
7698 "debugger;" 7636 "debugger;"
7699 "x * y", 7637 "x * y",
7700 30); 7638 30);
7701 } 7639 }
OLDNEW
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | test/mjsunit/debug-backtrace.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698