| 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 432 |
| 433 // Check that the debugger has been fully unloaded. | 433 // Check that the debugger has been fully unloaded. |
| 434 static void CheckDebuggerUnloaded(bool check_functions = false) { | 434 static void CheckDebuggerUnloaded(bool check_functions = false) { |
| 435 // Let debugger to unload itself synchronously | 435 // Let debugger to unload itself synchronously |
| 436 v8::Debug::ProcessDebugMessages(); | 436 v8::Debug::ProcessDebugMessages(); |
| 437 | 437 |
| 438 v8::internal::CheckDebuggerUnloaded(check_functions); | 438 v8::internal::CheckDebuggerUnloaded(check_functions); |
| 439 } | 439 } |
| 440 | 440 |
| 441 | 441 |
| 442 // Compile a function, set a break point and check that the call at the break | |
| 443 // location in the code is the expected debug_break function. | |
| 444 void CheckDebugBreakFunction(DebugLocalContext* env, | |
| 445 const char* source, const char* name, | |
| 446 int position, v8::internal::RelocInfo::Mode mode, | |
| 447 Code* debug_break) { | |
| 448 EnableDebugger(); | |
| 449 i::Debug* debug = CcTest::i_isolate()->debug(); | |
| 450 | |
| 451 // Create function and set the break point. | |
| 452 Handle<i::JSFunction> fun = | |
| 453 v8::Utils::OpenHandle(*CompileFunction(env, source, name)); | |
| 454 int bp = SetBreakPoint(fun, position); | |
| 455 | |
| 456 // Check that the debug break function is as expected. | |
| 457 Handle<i::SharedFunctionInfo> shared(fun->shared()); | |
| 458 CHECK(Debug::HasDebugInfo(shared)); | |
| 459 i::BreakLocation location = i::BreakLocation::FromPosition( | |
| 460 Debug::GetDebugInfo(shared), i::SOURCE_BREAK_LOCATIONS, position, | |
| 461 i::STATEMENT_ALIGNED); | |
| 462 i::RelocInfo::Mode actual_mode = location.rmode(); | |
| 463 if (actual_mode == i::RelocInfo::CODE_TARGET_WITH_ID) { | |
| 464 actual_mode = i::RelocInfo::CODE_TARGET; | |
| 465 } | |
| 466 CHECK_EQ(mode, actual_mode); | |
| 467 if (mode != i::RelocInfo::JS_RETURN) { | |
| 468 CHECK_EQ(debug_break, *location.CodeTarget()); | |
| 469 } else { | |
| 470 i::RelocInfo rinfo = location.rinfo(); | |
| 471 CHECK(i::RelocInfo::IsJSReturn(rinfo.rmode())); | |
| 472 CHECK(rinfo.IsPatchedReturnSequence()); | |
| 473 } | |
| 474 | |
| 475 // Clear the break point and check that the debug break function is no longer | |
| 476 // there | |
| 477 ClearBreakPoint(bp); | |
| 478 CHECK(!debug->HasDebugInfo(shared)); | |
| 479 CHECK(debug->EnsureDebugInfo(shared, fun)); | |
| 480 location = i::BreakLocation::FromPosition(Debug::GetDebugInfo(shared), | |
| 481 i::SOURCE_BREAK_LOCATIONS, position, | |
| 482 i::STATEMENT_ALIGNED); | |
| 483 actual_mode = location.rmode(); | |
| 484 if (actual_mode == i::RelocInfo::CODE_TARGET_WITH_ID) { | |
| 485 actual_mode = i::RelocInfo::CODE_TARGET; | |
| 486 } | |
| 487 CHECK_EQ(mode, actual_mode); | |
| 488 if (mode == i::RelocInfo::JS_RETURN) { | |
| 489 i::RelocInfo rinfo = location.rinfo(); | |
| 490 CHECK(!rinfo.IsPatchedReturnSequence()); | |
| 491 } | |
| 492 | |
| 493 DisableDebugger(); | |
| 494 } | |
| 495 | |
| 496 | |
| 497 // --- D e b u g E v e n t H a n d l e r s | 442 // --- D e b u g E v e n t H a n d l e r s |
| 498 // --- | 443 // --- |
| 499 // --- The different tests uses a number of debug event handlers. | 444 // --- The different tests uses a number of debug event handlers. |
| 500 // --- | 445 // --- |
| 501 | 446 |
| 502 | 447 |
| 503 // Source for the JavaScript function which picks out the function | 448 // Source for the JavaScript function which picks out the function |
| 504 // name of a frame. | 449 // name of a frame. |
| 505 const char* frame_function_name_source = | 450 const char* frame_function_name_source = |
| 506 "function frame_function_name(exec_state, frame_number) {" | 451 "function frame_function_name(exec_state, frame_number) {" |
| (...skipping 7123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7630 "let y = 2; \n" | 7575 "let y = 2; \n" |
| 7631 "debugger; \n" | 7576 "debugger; \n" |
| 7632 "x * y", | 7577 "x * y", |
| 7633 30); | 7578 30); |
| 7634 ExpectInt32( | 7579 ExpectInt32( |
| 7635 "x = 1; y = 2; \n" | 7580 "x = 1; y = 2; \n" |
| 7636 "debugger;" | 7581 "debugger;" |
| 7637 "x * y", | 7582 "x * y", |
| 7638 30); | 7583 30); |
| 7639 } | 7584 } |
| OLD | NEW |