| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 v8::internal::RelocIterator* it_original() { | 369 v8::internal::RelocIterator* it_original() { |
| 370 return reloc_iterator_original_; | 370 return reloc_iterator_original_; |
| 371 } | 371 } |
| 372 }; | 372 }; |
| 373 | 373 |
| 374 | 374 |
| 375 // Compile a function, set a break point and check that the call at the break | 375 // Compile a function, set a break point and check that the call at the break |
| 376 // location in the code is the expected debug_break function. | 376 // location in the code is the expected debug_break function. |
| 377 void CheckDebugBreakFunction(DebugLocalContext* env, | 377 void CheckDebugBreakFunction(DebugLocalContext* env, |
| 378 const char* source, const char* name, | 378 const char* source, const char* name, |
| 379 int position, v8::internal::RelocMode mode, | 379 int position, v8::internal::RelocInfo::Mode mode, |
| 380 Code* debug_break) { | 380 Code* debug_break) { |
| 381 // Create function and set the break point. | 381 // Create function and set the break point. |
| 382 Handle<v8::internal::JSFunction> fun = v8::Utils::OpenHandle( | 382 Handle<v8::internal::JSFunction> fun = v8::Utils::OpenHandle( |
| 383 *CompileFunction(env, source, name)); | 383 *CompileFunction(env, source, name)); |
| 384 int bp = SetBreakPoint(fun, position); | 384 int bp = SetBreakPoint(fun, position); |
| 385 | 385 |
| 386 // Check that the debug break function is as expected. | 386 // Check that the debug break function is as expected. |
| 387 Handle<v8::internal::SharedFunctionInfo> shared(fun->shared()); | 387 Handle<v8::internal::SharedFunctionInfo> shared(fun->shared()); |
| 388 CHECK(Debug::HasDebugInfo(shared)); | 388 CHECK(Debug::HasDebugInfo(shared)); |
| 389 TestBreakLocationIterator it1(Debug::GetDebugInfo(shared)); | 389 TestBreakLocationIterator it1(Debug::GetDebugInfo(shared)); |
| 390 it1.FindBreakLocationFromPosition(position); | 390 it1.FindBreakLocationFromPosition(position); |
| 391 CHECK_EQ(mode, it1.it()->rinfo()->rmode()); | 391 CHECK_EQ(mode, it1.it()->rinfo()->rmode()); |
| 392 if (mode != v8::internal::js_return) { | 392 if (mode != v8::internal::RelocInfo::JS_RETURN) { |
| 393 CHECK_EQ(debug_break, | 393 CHECK_EQ(debug_break, |
| 394 Debug::GetCodeTarget(it1.it()->rinfo()->target_address())); | 394 Debug::GetCodeTarget(it1.it()->rinfo()->target_address())); |
| 395 } else { | 395 } else { |
| 396 // TODO(1240753): Make the test architecture independent or split | 396 // TODO(1240753): Make the test architecture independent or split |
| 397 // parts of the debugger into architecture dependent files. | 397 // parts of the debugger into architecture dependent files. |
| 398 CHECK_EQ(0xE8, *(it1.rinfo()->pc())); | 398 CHECK_EQ(0xE8, *(it1.rinfo()->pc())); |
| 399 } | 399 } |
| 400 | 400 |
| 401 // Clear the break point and check that the debug break function is no longer | 401 // Clear the break point and check that the debug break function is no longer |
| 402 // there | 402 // there |
| 403 ClearBreakPoint(bp); | 403 ClearBreakPoint(bp); |
| 404 CHECK(!Debug::HasDebugInfo(shared)); | 404 CHECK(!Debug::HasDebugInfo(shared)); |
| 405 CHECK(Debug::EnsureDebugInfo(shared)); | 405 CHECK(Debug::EnsureDebugInfo(shared)); |
| 406 TestBreakLocationIterator it2(Debug::GetDebugInfo(shared)); | 406 TestBreakLocationIterator it2(Debug::GetDebugInfo(shared)); |
| 407 it2.FindBreakLocationFromPosition(position); | 407 it2.FindBreakLocationFromPosition(position); |
| 408 CHECK_EQ(mode, it2.it()->rinfo()->rmode()); | 408 CHECK_EQ(mode, it2.it()->rinfo()->rmode()); |
| 409 if (mode == v8::internal::js_return) { | 409 if (mode == v8::internal::RelocInfo::JS_RETURN) { |
| 410 // TODO(1240753): Make the test architecture independent or split | 410 // TODO(1240753): Make the test architecture independent or split |
| 411 // parts of the debugger into architecture dependent files. | 411 // parts of the debugger into architecture dependent files. |
| 412 CHECK_NE(0xE8, *(it2.rinfo()->pc())); | 412 CHECK_NE(0xE8, *(it2.rinfo()->pc())); |
| 413 } | 413 } |
| 414 } | 414 } |
| 415 | 415 |
| 416 | 416 |
| 417 // --- D e b u g E v e n t H a n d l e r s | 417 // --- D e b u g E v e n t H a n d l e r s |
| 418 // --- | 418 // --- |
| 419 // --- The different tests uses a number of debug event handlers. | 419 // --- The different tests uses a number of debug event handlers. |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 // --- T h e A c t u a l T e s t s | 660 // --- T h e A c t u a l T e s t s |
| 661 | 661 |
| 662 | 662 |
| 663 // Test that the debug break function is the expected one for different kinds | 663 // Test that the debug break function is the expected one for different kinds |
| 664 // of break locations. | 664 // of break locations. |
| 665 TEST(DebugStub) { | 665 TEST(DebugStub) { |
| 666 using ::v8::internal::Builtins; | 666 using ::v8::internal::Builtins; |
| 667 v8::HandleScope scope; | 667 v8::HandleScope scope; |
| 668 DebugLocalContext env; | 668 DebugLocalContext env; |
| 669 | 669 |
| 670 // TODO(1240753): Make the test architecture independent or split | |
| 671 // parts of the debugger into architecture dependent files. This | |
| 672 // part currently disabled as it is not portable between IA32/ARM. | |
| 673 // Ia32 uses js_return ARM uses exit_js_frame. | |
| 674 #if !defined (__arm__) && !defined(__thumb__) | |
| 675 CheckDebugBreakFunction(&env, | 670 CheckDebugBreakFunction(&env, |
| 676 "function f1(){}", "f1", | 671 "function f1(){}", "f1", |
| 677 0, | 672 0, |
| 678 v8::internal::js_return, | 673 v8::internal::RelocInfo::JS_RETURN, |
| 679 NULL); | 674 NULL); |
| 680 #endif | |
| 681 CheckDebugBreakFunction(&env, | 675 CheckDebugBreakFunction(&env, |
| 682 "function f2(){x=1;}", "f2", | 676 "function f2(){x=1;}", "f2", |
| 683 0, | 677 0, |
| 684 v8::internal::code_target, | 678 v8::internal::RelocInfo::CODE_TARGET, |
| 685 Builtins::builtin(Builtins::StoreIC_DebugBreak)); | 679 Builtins::builtin(Builtins::StoreIC_DebugBreak)); |
| 686 CheckDebugBreakFunction(&env, | 680 CheckDebugBreakFunction(&env, |
| 687 "function f3(){var a=x;}", "f3", | 681 "function f3(){var a=x;}", "f3", |
| 688 0, | 682 0, |
| 689 v8::internal::code_target_context, | 683 v8::internal::RelocInfo::CODE_TARGET_CONTEXT, |
| 690 Builtins::builtin(Builtins::LoadIC_DebugBreak)); | 684 Builtins::builtin(Builtins::LoadIC_DebugBreak)); |
| 691 | 685 |
| 686 // TODO(1240753): Make the test architecture independent or split |
| 687 // parts of the debugger into architecture dependent files. This |
| 688 // part currently disabled as it is not portable between IA32/ARM. |
| 692 // Currently on ICs for keyed store/load on ARM. | 689 // Currently on ICs for keyed store/load on ARM. |
| 693 #if !defined (__arm__) && !defined(__thumb__) | 690 #if !defined (__arm__) && !defined(__thumb__) |
| 694 CheckDebugBreakFunction( | 691 CheckDebugBreakFunction( |
| 695 &env, | 692 &env, |
| 696 "function f4(){var index='propertyName'; var a={}; a[index] = 'x';}", | 693 "function f4(){var index='propertyName'; var a={}; a[index] = 'x';}", |
| 697 "f4", | 694 "f4", |
| 698 0, | 695 0, |
| 699 v8::internal::code_target, | 696 v8::internal::RelocInfo::CODE_TARGET, |
| 700 Builtins::builtin(Builtins::KeyedStoreIC_DebugBreak)); | 697 Builtins::builtin(Builtins::KeyedStoreIC_DebugBreak)); |
| 701 CheckDebugBreakFunction( | 698 CheckDebugBreakFunction( |
| 702 &env, | 699 &env, |
| 703 "function f5(){var index='propertyName'; var a={}; return a[index];}", | 700 "function f5(){var index='propertyName'; var a={}; return a[index];}", |
| 704 "f5", | 701 "f5", |
| 705 0, | 702 0, |
| 706 v8::internal::code_target, | 703 v8::internal::RelocInfo::CODE_TARGET, |
| 707 Builtins::builtin(Builtins::KeyedLoadIC_DebugBreak)); | 704 Builtins::builtin(Builtins::KeyedLoadIC_DebugBreak)); |
| 708 #endif | 705 #endif |
| 709 | 706 |
| 710 // Check the debug break code stubs for call ICs with different number of | 707 // Check the debug break code stubs for call ICs with different number of |
| 711 // parameters. | 708 // parameters. |
| 712 Handle<Code> debug_break_0 = v8::internal::ComputeCallDebugBreak(0); | 709 Handle<Code> debug_break_0 = v8::internal::ComputeCallDebugBreak(0); |
| 713 Handle<Code> debug_break_1 = v8::internal::ComputeCallDebugBreak(1); | 710 Handle<Code> debug_break_1 = v8::internal::ComputeCallDebugBreak(1); |
| 714 Handle<Code> debug_break_4 = v8::internal::ComputeCallDebugBreak(4); | 711 Handle<Code> debug_break_4 = v8::internal::ComputeCallDebugBreak(4); |
| 715 | 712 |
| 716 CheckDebugBreakFunction(&env, | 713 CheckDebugBreakFunction(&env, |
| 717 "function f4_0(){x();}", "f4_0", | 714 "function f4_0(){x();}", "f4_0", |
| 718 0, | 715 0, |
| 719 v8::internal::code_target_context, | 716 v8::internal::RelocInfo::CODE_TARGET_CONTEXT, |
| 720 *debug_break_0); | 717 *debug_break_0); |
| 721 | 718 |
| 722 CheckDebugBreakFunction(&env, | 719 CheckDebugBreakFunction(&env, |
| 723 "function f4_1(){x(1);}", "f4_1", | 720 "function f4_1(){x(1);}", "f4_1", |
| 724 0, | 721 0, |
| 725 v8::internal::code_target_context, | 722 v8::internal::RelocInfo::CODE_TARGET_CONTEXT, |
| 726 *debug_break_1); | 723 *debug_break_1); |
| 727 | 724 |
| 728 CheckDebugBreakFunction(&env, | 725 CheckDebugBreakFunction(&env, |
| 729 "function f4_4(){x(1,2,3,4);}", "f4_4", | 726 "function f4_4(){x(1,2,3,4);}", "f4_4", |
| 730 0, | 727 0, |
| 731 v8::internal::code_target_context, | 728 v8::internal::RelocInfo::CODE_TARGET_CONTEXT, |
| 732 *debug_break_4); | 729 *debug_break_4); |
| 733 } | 730 } |
| 734 | 731 |
| 735 | 732 |
| 736 // Test that the debug info in the VM is in sync with the functions being | 733 // Test that the debug info in the VM is in sync with the functions being |
| 737 // debugged. | 734 // debugged. |
| 738 TEST(DebugInfo) { | 735 TEST(DebugInfo) { |
| 739 v8::HandleScope scope; | 736 v8::HandleScope scope; |
| 740 DebugLocalContext env; | 737 DebugLocalContext env; |
| 741 // Create a couple of functions for the test. | 738 // Create a couple of functions for the test. |
| (...skipping 2379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3121 Barriers stack_allocated_breakpoints_barriers; | 3118 Barriers stack_allocated_breakpoints_barriers; |
| 3122 stack_allocated_breakpoints_barriers.Initialize(); | 3119 stack_allocated_breakpoints_barriers.Initialize(); |
| 3123 breakpoints_barriers = &stack_allocated_breakpoints_barriers; | 3120 breakpoints_barriers = &stack_allocated_breakpoints_barriers; |
| 3124 | 3121 |
| 3125 breakpoints_v8_thread.Start(); | 3122 breakpoints_v8_thread.Start(); |
| 3126 breakpoints_debugger_thread.Start(); | 3123 breakpoints_debugger_thread.Start(); |
| 3127 | 3124 |
| 3128 breakpoints_v8_thread.Join(); | 3125 breakpoints_v8_thread.Join(); |
| 3129 breakpoints_debugger_thread.Join(); | 3126 breakpoints_debugger_thread.Join(); |
| 3130 } | 3127 } |
| OLD | NEW |