| OLD | NEW |
| 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 // If deep check of functions is requested check that no debug break code | 409 // If deep check of functions is requested check that no debug break code |
| 410 // is left in all functions. | 410 // is left in all functions. |
| 411 if (check_functions) { | 411 if (check_functions) { |
| 412 if (obj->IsJSFunction()) { | 412 if (obj->IsJSFunction()) { |
| 413 JSFunction* fun = JSFunction::cast(obj); | 413 JSFunction* fun = JSFunction::cast(obj); |
| 414 for (RelocIterator it(fun->shared()->code()); !it.done(); it.next()) { | 414 for (RelocIterator it(fun->shared()->code()); !it.done(); it.next()) { |
| 415 RelocInfo::Mode rmode = it.rinfo()->rmode(); | 415 RelocInfo::Mode rmode = it.rinfo()->rmode(); |
| 416 if (RelocInfo::IsCodeTarget(rmode)) { | 416 if (RelocInfo::IsCodeTarget(rmode)) { |
| 417 CHECK(!Debug::IsDebugBreak(it.rinfo()->target_address())); | 417 CHECK(!Debug::IsDebugBreak(it.rinfo()->target_address())); |
| 418 } else if (RelocInfo::IsJSReturn(rmode)) { | 418 } else if (RelocInfo::IsJSReturn(rmode)) { |
| 419 CHECK(!Debug::IsDebugBreakAtReturn(it.rinfo())); | 419 CHECK(!it.rinfo()->IsPatchedReturnSequence()); |
| 420 } | 420 } |
| 421 } | 421 } |
| 422 } | 422 } |
| 423 } | 423 } |
| 424 } | 424 } |
| 425 } | 425 } |
| 426 | 426 |
| 427 | 427 |
| 428 } } // namespace v8::internal | 428 } } // namespace v8::internal |
| 429 | 429 |
| 430 | 430 |
| 431 // Check that the debugger has been fully unloaded. | 431 // Check that the debugger has been fully unloaded. |
| 432 static void CheckDebuggerUnloaded(bool check_functions = false) { | 432 static void CheckDebuggerUnloaded(bool check_functions = false) { |
| 433 // Let debugger to unload itself synchronously | 433 // Let debugger to unload itself synchronously |
| 434 v8::Debug::ProcessDebugMessages(); | 434 v8::Debug::ProcessDebugMessages(); |
| 435 | 435 |
| 436 v8::internal::CheckDebuggerUnloaded(check_functions); | 436 v8::internal::CheckDebuggerUnloaded(check_functions); |
| 437 } | 437 } |
| 438 | 438 |
| 439 | 439 |
| 440 // Inherit from BreakLocationIterator to get access to protected parts for | |
| 441 // testing. | |
| 442 class TestBreakLocationIterator: public v8::internal::BreakLocationIterator { | |
| 443 public: | |
| 444 explicit TestBreakLocationIterator(Handle<v8::internal::DebugInfo> debug_info) | |
| 445 : BreakLocationIterator(debug_info, v8::internal::SOURCE_BREAK_LOCATIONS) {} | |
| 446 v8::internal::RelocIterator* it() { return reloc_iterator_; } | |
| 447 v8::internal::RelocIterator* it_original() { | |
| 448 return reloc_iterator_original_; | |
| 449 } | |
| 450 }; | |
| 451 | |
| 452 | |
| 453 // Compile a function, set a break point and check that the call at the break | 440 // Compile a function, set a break point and check that the call at the break |
| 454 // location in the code is the expected debug_break function. | 441 // location in the code is the expected debug_break function. |
| 455 void CheckDebugBreakFunction(DebugLocalContext* env, | 442 void CheckDebugBreakFunction(DebugLocalContext* env, |
| 456 const char* source, const char* name, | 443 const char* source, const char* name, |
| 457 int position, v8::internal::RelocInfo::Mode mode, | 444 int position, v8::internal::RelocInfo::Mode mode, |
| 458 Code* debug_break) { | 445 Code* debug_break) { |
| 459 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); | 446 i::Debug* debug = CcTest::i_isolate()->debug(); |
| 460 | 447 |
| 461 // Create function and set the break point. | 448 // Create function and set the break point. |
| 462 Handle<v8::internal::JSFunction> fun = v8::Utils::OpenHandle( | 449 Handle<i::JSFunction> fun = |
| 463 *CompileFunction(env, source, name)); | 450 v8::Utils::OpenHandle(*CompileFunction(env, source, name)); |
| 464 int bp = SetBreakPoint(fun, position); | 451 int bp = SetBreakPoint(fun, position); |
| 465 | 452 |
| 466 // Check that the debug break function is as expected. | 453 // Check that the debug break function is as expected. |
| 467 Handle<v8::internal::SharedFunctionInfo> shared(fun->shared()); | 454 Handle<i::SharedFunctionInfo> shared(fun->shared()); |
| 468 CHECK(Debug::HasDebugInfo(shared)); | 455 CHECK(Debug::HasDebugInfo(shared)); |
| 469 TestBreakLocationIterator it1(Debug::GetDebugInfo(shared)); | 456 i::BreakLocation location = i::BreakLocation::FromPosition( |
| 470 it1.FindBreakLocationFromPosition(position, v8::internal::STATEMENT_ALIGNED); | 457 Debug::GetDebugInfo(shared), i::SOURCE_BREAK_LOCATIONS, position, |
| 471 v8::internal::RelocInfo::Mode actual_mode = it1.it()->rinfo()->rmode(); | 458 i::STATEMENT_ALIGNED); |
| 472 if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) { | 459 i::RelocInfo::Mode actual_mode = location.rmode(); |
| 473 actual_mode = v8::internal::RelocInfo::CODE_TARGET; | 460 if (actual_mode == i::RelocInfo::CODE_TARGET_WITH_ID) { |
| 461 actual_mode = i::RelocInfo::CODE_TARGET; |
| 474 } | 462 } |
| 475 CHECK_EQ(mode, actual_mode); | 463 CHECK_EQ(mode, actual_mode); |
| 476 if (mode != v8::internal::RelocInfo::JS_RETURN) { | 464 if (mode != i::RelocInfo::JS_RETURN) { |
| 477 CHECK_EQ(debug_break, | 465 CHECK_EQ(debug_break, *location.CodeTarget()); |
| 478 Code::GetCodeFromTargetAddress(it1.it()->rinfo()->target_address())); | |
| 479 } else { | 466 } else { |
| 480 CHECK(Debug::IsDebugBreakAtReturn(it1.it()->rinfo())); | 467 i::RelocInfo rinfo = location.rinfo(); |
| 468 CHECK(i::RelocInfo::IsJSReturn(rinfo.rmode())); |
| 469 CHECK(rinfo.IsPatchedReturnSequence()); |
| 481 } | 470 } |
| 482 | 471 |
| 483 // Clear the break point and check that the debug break function is no longer | 472 // Clear the break point and check that the debug break function is no longer |
| 484 // there | 473 // there |
| 485 ClearBreakPoint(bp); | 474 ClearBreakPoint(bp); |
| 486 CHECK(!debug->HasDebugInfo(shared)); | 475 CHECK(!debug->HasDebugInfo(shared)); |
| 487 CHECK(debug->EnsureDebugInfo(shared, fun)); | 476 CHECK(debug->EnsureDebugInfo(shared, fun)); |
| 488 TestBreakLocationIterator it2(Debug::GetDebugInfo(shared)); | 477 location = i::BreakLocation::FromPosition(Debug::GetDebugInfo(shared), |
| 489 it2.FindBreakLocationFromPosition(position, v8::internal::STATEMENT_ALIGNED); | 478 i::SOURCE_BREAK_LOCATIONS, position, |
| 490 actual_mode = it2.it()->rinfo()->rmode(); | 479 i::STATEMENT_ALIGNED); |
| 491 if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) { | 480 actual_mode = location.rmode(); |
| 492 actual_mode = v8::internal::RelocInfo::CODE_TARGET; | 481 if (actual_mode == i::RelocInfo::CODE_TARGET_WITH_ID) { |
| 482 actual_mode = i::RelocInfo::CODE_TARGET; |
| 493 } | 483 } |
| 494 CHECK_EQ(mode, actual_mode); | 484 CHECK_EQ(mode, actual_mode); |
| 495 if (mode == v8::internal::RelocInfo::JS_RETURN) { | 485 if (mode == i::RelocInfo::JS_RETURN) { |
| 496 CHECK(!Debug::IsDebugBreakAtReturn(it2.it()->rinfo())); | 486 i::RelocInfo rinfo = location.rinfo(); |
| 487 CHECK(!rinfo.IsPatchedReturnSequence()); |
| 497 } | 488 } |
| 498 } | 489 } |
| 499 | 490 |
| 500 | 491 |
| 501 // --- D e b u g E v e n t H a n d l e r s | 492 // --- D e b u g E v e n t H a n d l e r s |
| 502 // --- | 493 // --- |
| 503 // --- The different tests uses a number of debug event handlers. | 494 // --- The different tests uses a number of debug event handlers. |
| 504 // --- | 495 // --- |
| 505 | 496 |
| 506 | 497 |
| (...skipping 7164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7671 "let y = 2; \n" | 7662 "let y = 2; \n" |
| 7672 "debugger; \n" | 7663 "debugger; \n" |
| 7673 "x * y", | 7664 "x * y", |
| 7674 30); | 7665 30); |
| 7675 ExpectInt32( | 7666 ExpectInt32( |
| 7676 "x = 1; y = 2; \n" | 7667 "x = 1; y = 2; \n" |
| 7677 "debugger;" | 7668 "debugger;" |
| 7678 "x * y", | 7669 "x * y", |
| 7679 30); | 7670 30); |
| 7680 } | 7671 } |
| OLD | NEW |