Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: runtime/vm/debugger.cc

Issue 106593002: Write protect executable pages in the VM. Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/freelist.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/debugger.h" 5 #include "vm/debugger.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 if (line_number_ < 0) { 746 if (line_number_ < 0) {
747 const Script& script = Script::Handle(SourceCode()); 747 const Script& script = Script::Handle(SourceCode());
748 script.GetTokenLocation(token_pos_, &line_number_, NULL); 748 script.GetTokenLocation(token_pos_, &line_number_, NULL);
749 } 749 }
750 return line_number_; 750 return line_number_;
751 } 751 }
752 752
753 753
754 void CodeBreakpoint::PatchCode() { 754 void CodeBreakpoint::PatchCode() {
755 ASSERT(!is_enabled_); 755 ASSERT(!is_enabled_);
756 switch (breakpoint_kind_) { 756 const Code& code =
757 case PcDescriptors::kIcCall: { 757 Code::Handle(Function::Handle(function_).unoptimized_code());
758 const Code& code = 758 const Instructions& instrs = Instructions::Handle(code.instructions());
759 Code::Handle(Function::Handle(function_).unoptimized_code()); 759 {
760 saved_bytes_.target_address_ = 760 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
761 CodePatcher::GetInstanceCallAt(pc_, code, NULL); 761 switch (breakpoint_kind_) {
762 CodePatcher::PatchInstanceCallAt(pc_, code, 762 case PcDescriptors::kIcCall: {
763 StubCode::BreakpointDynamicEntryPoint()); 763 saved_bytes_.target_address_ =
764 break; 764 CodePatcher::GetInstanceCallAt(pc_, code, NULL);
765 CodePatcher::PatchInstanceCallAt(
766 pc_, code, StubCode::BreakpointDynamicEntryPoint());
767 break;
768 }
769 case PcDescriptors::kUnoptStaticCall: {
770 saved_bytes_.target_address_ =
771 CodePatcher::GetStaticCallTargetAt(pc_, code);
772 CodePatcher::PatchStaticCallAt(pc_, code,
773 StubCode::BreakpointStaticEntryPoint());
774 break;
775 }
776 case PcDescriptors::kRuntimeCall:
777 case PcDescriptors::kClosureCall: {
778 saved_bytes_.target_address_ =
779 CodePatcher::GetStaticCallTargetAt(pc_, code);
780 CodePatcher::PatchStaticCallAt(pc_, code,
781 StubCode::BreakpointRuntimeEntryPoint());
782 break;
783 }
784 case PcDescriptors::kReturn:
785 PatchFunctionReturn();
786 break;
787 default:
788 UNREACHABLE();
765 } 789 }
766 case PcDescriptors::kUnoptStaticCall: {
767 const Code& code =
768 Code::Handle(Function::Handle(function_).unoptimized_code());
769 saved_bytes_.target_address_ =
770 CodePatcher::GetStaticCallTargetAt(pc_, code);
771 CodePatcher::PatchStaticCallAt(pc_, code,
772 StubCode::BreakpointStaticEntryPoint());
773 break;
774 }
775 case PcDescriptors::kRuntimeCall:
776 case PcDescriptors::kClosureCall: {
777 const Code& code =
778 Code::Handle(Function::Handle(function_).unoptimized_code());
779 saved_bytes_.target_address_ =
780 CodePatcher::GetStaticCallTargetAt(pc_, code);
781 CodePatcher::PatchStaticCallAt(pc_, code,
782 StubCode::BreakpointRuntimeEntryPoint());
783 break;
784 }
785 case PcDescriptors::kReturn:
786 PatchFunctionReturn();
787 break;
788 default:
789 UNREACHABLE();
790 } 790 }
791 is_enabled_ = true; 791 is_enabled_ = true;
792 } 792 }
793 793
794 794
795 void CodeBreakpoint::RestoreCode() { 795 void CodeBreakpoint::RestoreCode() {
796 ASSERT(is_enabled_); 796 ASSERT(is_enabled_);
797 switch (breakpoint_kind_) { 797 const Code& code =
798 case PcDescriptors::kIcCall: { 798 Code::Handle(Function::Handle(function_).unoptimized_code());
799 const Code& code = 799 const Instructions& instrs = Instructions::Handle(code.instructions());
800 Code::Handle(Function::Handle(function_).unoptimized_code()); 800 {
801 CodePatcher::PatchInstanceCallAt(pc_, code, 801 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
802 switch (breakpoint_kind_) {
803 case PcDescriptors::kIcCall: {
804 CodePatcher::PatchInstanceCallAt(pc_, code,
805 saved_bytes_.target_address_);
806 break;
807 }
808 case PcDescriptors::kUnoptStaticCall:
809 case PcDescriptors::kClosureCall:
810 case PcDescriptors::kRuntimeCall: {
811 const Code& code =
812 Code::Handle(Function::Handle(function_).unoptimized_code());
813 CodePatcher::PatchStaticCallAt(pc_, code,
802 saved_bytes_.target_address_); 814 saved_bytes_.target_address_);
803 break; 815 break;
816 }
817 case PcDescriptors::kReturn:
818 RestoreFunctionReturn();
819 break;
820 default:
821 UNREACHABLE();
804 } 822 }
805 case PcDescriptors::kUnoptStaticCall:
806 case PcDescriptors::kClosureCall:
807 case PcDescriptors::kRuntimeCall: {
808 const Code& code =
809 Code::Handle(Function::Handle(function_).unoptimized_code());
810 CodePatcher::PatchStaticCallAt(pc_, code,
811 saved_bytes_.target_address_);
812 break;
813 }
814 case PcDescriptors::kReturn:
815 RestoreFunctionReturn();
816 break;
817 default:
818 UNREACHABLE();
819 } 823 }
820 is_enabled_ = false; 824 is_enabled_ = false;
821 } 825 }
822 826
823 827
824 void CodeBreakpoint::Enable() { 828 void CodeBreakpoint::Enable() {
825 if (!is_enabled_) { 829 if (!is_enabled_) {
826 PatchCode(); 830 PatchCode();
827 } 831 }
828 ASSERT(is_enabled_); 832 ASSERT(is_enabled_);
(...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after
2240 } 2244 }
2241 2245
2242 2246
2243 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 2247 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
2244 ASSERT(bpt->next() == NULL); 2248 ASSERT(bpt->next() == NULL);
2245 bpt->set_next(code_breakpoints_); 2249 bpt->set_next(code_breakpoints_);
2246 code_breakpoints_ = bpt; 2250 code_breakpoints_ = bpt;
2247 } 2251 }
2248 2252
2249 } // namespace dart 2253 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/freelist.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698