| 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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 // Restore the code in the break slot. | 382 // Restore the code in the break slot. |
| 383 ClearDebugBreakAtSlot(); | 383 ClearDebugBreakAtSlot(); |
| 384 } else { | 384 } else { |
| 385 // Patch the IC call. | 385 // Patch the IC call. |
| 386 ClearDebugBreakAtIC(); | 386 ClearDebugBreakAtIC(); |
| 387 } | 387 } |
| 388 ASSERT(!IsDebugBreak()); | 388 ASSERT(!IsDebugBreak()); |
| 389 } | 389 } |
| 390 | 390 |
| 391 | 391 |
| 392 void BreakLocationIterator::PrepareStepIn() { | 392 void BreakLocationIterator::PrepareStepIn(Isolate* isolate) { |
| 393 HandleScope scope; | 393 HandleScope scope(isolate); |
| 394 | 394 |
| 395 // Step in can only be prepared if currently positioned on an IC call, | 395 // Step in can only be prepared if currently positioned on an IC call, |
| 396 // construct call or CallFunction stub call. | 396 // construct call or CallFunction stub call. |
| 397 Address target = rinfo()->target_address(); | 397 Address target = rinfo()->target_address(); |
| 398 Handle<Code> target_code(Code::GetCodeFromTargetAddress(target)); | 398 Handle<Code> target_code(Code::GetCodeFromTargetAddress(target)); |
| 399 if (target_code->is_call_stub() || target_code->is_keyed_call_stub()) { | 399 if (target_code->is_call_stub() || target_code->is_keyed_call_stub()) { |
| 400 // Step in through IC call is handled by the runtime system. Therefore make | 400 // Step in through IC call is handled by the runtime system. Therefore make |
| 401 // sure that the any current IC is cleared and the runtime system is | 401 // sure that the any current IC is cleared and the runtime system is |
| 402 // called. If the executing code has a debug break at the location change | 402 // called. If the executing code has a debug break at the location change |
| 403 // the call in the original code as it is the code there that will be | 403 // the call in the original code as it is the code there that will be |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 | 820 |
| 821 // Disable breakpoints and interrupts while compiling and running the | 821 // Disable breakpoints and interrupts while compiling and running the |
| 822 // debugger scripts including the context creation code. | 822 // debugger scripts including the context creation code. |
| 823 DisableBreak disable(true); | 823 DisableBreak disable(true); |
| 824 PostponeInterruptsScope postpone(isolate_); | 824 PostponeInterruptsScope postpone(isolate_); |
| 825 | 825 |
| 826 // Create the debugger context. | 826 // Create the debugger context. |
| 827 HandleScope scope(isolate_); | 827 HandleScope scope(isolate_); |
| 828 Handle<Context> context = | 828 Handle<Context> context = |
| 829 isolate_->bootstrapper()->CreateEnvironment( | 829 isolate_->bootstrapper()->CreateEnvironment( |
| 830 isolate_, | |
| 831 Handle<Object>::null(), | 830 Handle<Object>::null(), |
| 832 v8::Handle<ObjectTemplate>(), | 831 v8::Handle<ObjectTemplate>(), |
| 833 NULL); | 832 NULL); |
| 834 | 833 |
| 835 // Fail if no context could be created. | 834 // Fail if no context could be created. |
| 836 if (context.is_null()) return false; | 835 if (context.is_null()) return false; |
| 837 | 836 |
| 838 // Use the debugger context. | 837 // Use the debugger context. |
| 839 SaveContext save(isolate_); | 838 SaveContext save(isolate_); |
| 840 isolate_->set_context(*context); | 839 isolate_->set_context(*context); |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 // Remember source position and frame to handle step in getter/setter. If | 1539 // Remember source position and frame to handle step in getter/setter. If |
| 1541 // there is a custom getter/setter it will be handled in | 1540 // there is a custom getter/setter it will be handled in |
| 1542 // Object::Get/SetPropertyWithCallback, otherwise the step action will be | 1541 // Object::Get/SetPropertyWithCallback, otherwise the step action will be |
| 1543 // propagated on the next Debug::Break. | 1542 // propagated on the next Debug::Break. |
| 1544 thread_local_.last_statement_position_ = | 1543 thread_local_.last_statement_position_ = |
| 1545 debug_info->code()->SourceStatementPosition(frame->pc()); | 1544 debug_info->code()->SourceStatementPosition(frame->pc()); |
| 1546 thread_local_.last_fp_ = frame->UnpaddedFP(); | 1545 thread_local_.last_fp_ = frame->UnpaddedFP(); |
| 1547 } | 1546 } |
| 1548 | 1547 |
| 1549 // Step in or Step in min | 1548 // Step in or Step in min |
| 1550 it.PrepareStepIn(); | 1549 it.PrepareStepIn(isolate_); |
| 1551 ActivateStepIn(frame); | 1550 ActivateStepIn(frame); |
| 1552 } | 1551 } |
| 1553 } | 1552 } |
| 1554 | 1553 |
| 1555 | 1554 |
| 1556 // Check whether the current debug break should be reported to the debugger. It | 1555 // Check whether the current debug break should be reported to the debugger. It |
| 1557 // is used to have step next and step in only report break back to the debugger | 1556 // is used to have step next and step in only report break back to the debugger |
| 1558 // if on a different frame or in a different statement. In some situations | 1557 // if on a different frame or in a different statement. In some situations |
| 1559 // there will be several break points in the same statement when the code is | 1558 // there will be several break points in the same statement when the code is |
| 1560 // flooded with one-shot break points. This function helps to perform several | 1559 // flooded with one-shot break points. This function helps to perform several |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 thread_local_.break_frame_id_ = break_frame_id; | 1696 thread_local_.break_frame_id_ = break_frame_id; |
| 1698 thread_local_.break_id_ = break_id; | 1697 thread_local_.break_id_ = break_id; |
| 1699 } | 1698 } |
| 1700 | 1699 |
| 1701 | 1700 |
| 1702 // Handle stepping into a function. | 1701 // Handle stepping into a function. |
| 1703 void Debug::HandleStepIn(Handle<JSFunction> function, | 1702 void Debug::HandleStepIn(Handle<JSFunction> function, |
| 1704 Handle<Object> holder, | 1703 Handle<Object> holder, |
| 1705 Address fp, | 1704 Address fp, |
| 1706 bool is_constructor) { | 1705 bool is_constructor) { |
| 1706 Isolate* isolate = function->GetIsolate(); |
| 1707 // If the frame pointer is not supplied by the caller find it. | 1707 // If the frame pointer is not supplied by the caller find it. |
| 1708 if (fp == 0) { | 1708 if (fp == 0) { |
| 1709 StackFrameIterator it; | 1709 StackFrameIterator it(isolate); |
| 1710 it.Advance(); | 1710 it.Advance(); |
| 1711 // For constructor functions skip another frame. | 1711 // For constructor functions skip another frame. |
| 1712 if (is_constructor) { | 1712 if (is_constructor) { |
| 1713 ASSERT(it.frame()->is_construct()); | 1713 ASSERT(it.frame()->is_construct()); |
| 1714 it.Advance(); | 1714 it.Advance(); |
| 1715 } | 1715 } |
| 1716 fp = it.frame()->fp(); | 1716 fp = it.frame()->fp(); |
| 1717 } | 1717 } |
| 1718 | 1718 |
| 1719 // Flood the function with one-shot break points if it is called from where | 1719 // Flood the function with one-shot break points if it is called from where |
| 1720 // step into was requested. | 1720 // step into was requested. |
| 1721 if (fp == step_in_fp()) { | 1721 if (fp == step_in_fp()) { |
| 1722 if (function->shared()->bound()) { | 1722 if (function->shared()->bound()) { |
| 1723 // Handle Function.prototype.bind | 1723 // Handle Function.prototype.bind |
| 1724 Debug::FloodBoundFunctionWithOneShot(function); | 1724 Debug::FloodBoundFunctionWithOneShot(function); |
| 1725 } else if (!function->IsBuiltin()) { | 1725 } else if (!function->IsBuiltin()) { |
| 1726 // Don't allow step into functions in the native context. | 1726 // Don't allow step into functions in the native context. |
| 1727 if (function->shared()->code() == | 1727 if (function->shared()->code() == |
| 1728 Isolate::Current()->builtins()->builtin(Builtins::kFunctionApply) || | 1728 isolate->builtins()->builtin(Builtins::kFunctionApply) || |
| 1729 function->shared()->code() == | 1729 function->shared()->code() == |
| 1730 Isolate::Current()->builtins()->builtin(Builtins::kFunctionCall)) { | 1730 isolate->builtins()->builtin(Builtins::kFunctionCall)) { |
| 1731 // Handle function.apply and function.call separately to flood the | 1731 // Handle function.apply and function.call separately to flood the |
| 1732 // function to be called and not the code for Builtins::FunctionApply or | 1732 // function to be called and not the code for Builtins::FunctionApply or |
| 1733 // Builtins::FunctionCall. The receiver of call/apply is the target | 1733 // Builtins::FunctionCall. The receiver of call/apply is the target |
| 1734 // function. | 1734 // function. |
| 1735 if (!holder.is_null() && holder->IsJSFunction() && | 1735 if (!holder.is_null() && holder->IsJSFunction() && |
| 1736 !JSFunction::cast(*holder)->IsBuiltin()) { | 1736 !JSFunction::cast(*holder)->IsBuiltin()) { |
| 1737 Handle<JSFunction> js_function = Handle<JSFunction>::cast(holder); | 1737 Handle<JSFunction> js_function = Handle<JSFunction>::cast(holder); |
| 1738 Debug::FloodWithOneShot(js_function); | 1738 Debug::FloodWithOneShot(js_function); |
| 1739 } | 1739 } |
| 1740 } else { | 1740 } else { |
| (...skipping 2040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3781 { | 3781 { |
| 3782 Locker locker(reinterpret_cast<v8::Isolate*>(isolate)); | 3782 Locker locker(reinterpret_cast<v8::Isolate*>(isolate)); |
| 3783 isolate->debugger()->CallMessageDispatchHandler(); | 3783 isolate->debugger()->CallMessageDispatchHandler(); |
| 3784 } | 3784 } |
| 3785 } | 3785 } |
| 3786 } | 3786 } |
| 3787 | 3787 |
| 3788 #endif // ENABLE_DEBUGGER_SUPPORT | 3788 #endif // ENABLE_DEBUGGER_SUPPORT |
| 3789 | 3789 |
| 3790 } } // namespace v8::internal | 3790 } } // namespace v8::internal |
| OLD | NEW |