| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
| 9 #include "src/debug/debug-evaluate.h" | 9 #include "src/debug/debug-evaluate.h" |
| 10 #include "src/debug/debug-frames.h" | 10 #include "src/debug/debug-frames.h" |
| 11 #include "src/debug/debug-scopes.h" | 11 #include "src/debug/debug-scopes.h" |
| 12 #include "src/frames-inl.h" | 12 #include "src/frames-inl.h" |
| 13 #include "src/isolate-inl.h" | 13 #include "src/isolate-inl.h" |
| 14 #include "src/runtime/runtime.h" | 14 #include "src/runtime/runtime.h" |
| 15 | 15 |
| 16 namespace v8 { | 16 namespace v8 { |
| 17 namespace internal { | 17 namespace internal { |
| 18 | 18 |
| 19 RUNTIME_FUNCTION(Runtime_DebugBreak) { | 19 RUNTIME_FUNCTION(Runtime_DebugBreak) { |
| 20 SealHandleScope shs(isolate); | 20 SealHandleScope shs(isolate); |
| 21 DCHECK(args.length() == 0); | 21 DCHECK(args.length() == 1); |
| 22 // Get the top-most JavaScript frame. | 22 // Get the top-most JavaScript frame. |
| 23 JavaScriptFrameIterator it(isolate); | 23 JavaScriptFrameIterator it(isolate); |
| 24 isolate->debug()->Break(args, it.frame()); | 24 isolate->debug()->Break(args, it.frame()); |
| 25 return isolate->debug()->SetAfterBreakTarget(it.frame()); | 25 return isolate->debug()->SetAfterBreakTarget(it.frame()); |
| 26 } | 26 } |
| 27 | 27 |
| 28 | 28 |
| 29 RUNTIME_FUNCTION(Runtime_HandleDebuggerStatement) { | 29 RUNTIME_FUNCTION(Runtime_HandleDebuggerStatement) { |
| 30 SealHandleScope shs(isolate); | 30 SealHandleScope shs(isolate); |
| 31 DCHECK(args.length() == 0); | 31 DCHECK(args.length() == 0); |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 // frame or if the frame is optimized it cannot be at a return. | 584 // frame or if the frame is optimized it cannot be at a return. |
| 585 bool at_return = false; | 585 bool at_return = false; |
| 586 if (!is_optimized && index == 0) { | 586 if (!is_optimized && index == 0) { |
| 587 at_return = isolate->debug()->IsBreakAtReturn(it.frame()); | 587 at_return = isolate->debug()->IsBreakAtReturn(it.frame()); |
| 588 } | 588 } |
| 589 | 589 |
| 590 // If positioned just before return find the value to be returned and add it | 590 // If positioned just before return find the value to be returned and add it |
| 591 // to the frame information. | 591 // to the frame information. |
| 592 Handle<Object> return_value = isolate->factory()->undefined_value(); | 592 Handle<Object> return_value = isolate->factory()->undefined_value(); |
| 593 if (at_return) { | 593 if (at_return) { |
| 594 StackFrameIterator it2(isolate); | 594 return_value = isolate->debug()->get_return_value(); |
| 595 Address internal_frame_sp = NULL; | |
| 596 while (!it2.done()) { | |
| 597 if (it2.frame()->is_internal()) { | |
| 598 internal_frame_sp = it2.frame()->sp(); | |
| 599 } else { | |
| 600 if (it2.frame()->is_java_script()) { | |
| 601 if (it2.frame()->id() == it.frame()->id()) { | |
| 602 // The internal frame just before the JavaScript frame contains the | |
| 603 // value to return on top. A debug break at return will create an | |
| 604 // internal frame to store the return value (eax/rax/r0) before | |
| 605 // entering the debug break exit frame. | |
| 606 if (internal_frame_sp != NULL) { | |
| 607 return_value = | |
| 608 Handle<Object>(Memory::Object_at(internal_frame_sp), isolate); | |
| 609 break; | |
| 610 } | |
| 611 } | |
| 612 } | |
| 613 | |
| 614 // Indicate that the previous frame was not an internal frame. | |
| 615 internal_frame_sp = NULL; | |
| 616 } | |
| 617 it2.Advance(); | |
| 618 } | |
| 619 } | 595 } |
| 620 | 596 |
| 621 // Now advance to the arguments adapter frame (if any). It contains all | 597 // Now advance to the arguments adapter frame (if any). It contains all |
| 622 // the provided parameters whereas the function frame always have the number | 598 // the provided parameters whereas the function frame always have the number |
| 623 // of arguments matching the functions parameters. The rest of the | 599 // of arguments matching the functions parameters. The rest of the |
| 624 // information (except for what is collected above) is the same. | 600 // information (except for what is collected above) is the same. |
| 625 if ((inlined_jsframe_index == 0) && it.frame()->has_adapted_arguments()) { | 601 if ((inlined_jsframe_index == 0) && it.frame()->has_adapted_arguments()) { |
| 626 it.AdvanceToArgumentsFrame(); | 602 it.AdvanceToArgumentsFrame(); |
| 627 frame_inspector.SetArgumentsFrame(it.frame()); | 603 frame_inspector.SetArgumentsFrame(it.frame()); |
| 628 } | 604 } |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 return Smi::FromInt(isolate->debug()->is_active()); | 1628 return Smi::FromInt(isolate->debug()->is_active()); |
| 1653 } | 1629 } |
| 1654 | 1630 |
| 1655 | 1631 |
| 1656 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 1632 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
| 1657 UNIMPLEMENTED(); | 1633 UNIMPLEMENTED(); |
| 1658 return NULL; | 1634 return NULL; |
| 1659 } | 1635 } |
| 1660 } // namespace internal | 1636 } // namespace internal |
| 1661 } // namespace v8 | 1637 } // namespace v8 |
| OLD | NEW |