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

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

Issue 136563002: Landing: Write protect executable pages in the VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 months 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
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 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 if (line_number_ < 0) { 753 if (line_number_ < 0) {
754 const Script& script = Script::Handle(SourceCode()); 754 const Script& script = Script::Handle(SourceCode());
755 script.GetTokenLocation(token_pos_, &line_number_, NULL); 755 script.GetTokenLocation(token_pos_, &line_number_, NULL);
756 } 756 }
757 return line_number_; 757 return line_number_;
758 } 758 }
759 759
760 760
761 void CodeBreakpoint::PatchCode() { 761 void CodeBreakpoint::PatchCode() {
762 ASSERT(!is_enabled_); 762 ASSERT(!is_enabled_);
763 switch (breakpoint_kind_) { 763 const Code& code =
764 case PcDescriptors::kIcCall: { 764 Code::Handle(Function::Handle(function_).unoptimized_code());
765 const Code& code = 765 const Instructions& instrs = Instructions::Handle(code.instructions());
766 Code::Handle(Function::Handle(function_).unoptimized_code()); 766 {
767 saved_bytes_.target_address_ = 767 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
768 CodePatcher::GetInstanceCallAt(pc_, code, NULL); 768 switch (breakpoint_kind_) {
769 CodePatcher::PatchInstanceCallAt(pc_, code, 769 case PcDescriptors::kIcCall: {
770 StubCode::BreakpointDynamicEntryPoint()); 770 saved_bytes_.target_address_ =
771 break; 771 CodePatcher::GetInstanceCallAt(pc_, code, NULL);
772 CodePatcher::PatchInstanceCallAt(
773 pc_, code, StubCode::BreakpointDynamicEntryPoint());
774 break;
775 }
776 case PcDescriptors::kUnoptStaticCall: {
777 saved_bytes_.target_address_ =
778 CodePatcher::GetStaticCallTargetAt(pc_, code);
779 CodePatcher::PatchStaticCallAt(pc_, code,
780 StubCode::BreakpointStaticEntryPoint());
781 break;
782 }
783 case PcDescriptors::kRuntimeCall:
784 case PcDescriptors::kClosureCall:
785 case PcDescriptors::kReturn: {
786 saved_bytes_.target_address_ =
787 CodePatcher::GetStaticCallTargetAt(pc_, code);
788 CodePatcher::PatchStaticCallAt(pc_, code,
789 StubCode::BreakpointRuntimeEntryPoint());
790 break;
791 }
792 default:
793 UNREACHABLE();
772 } 794 }
773 case PcDescriptors::kUnoptStaticCall: {
774 const Code& code =
775 Code::Handle(Function::Handle(function_).unoptimized_code());
776 saved_bytes_.target_address_ =
777 CodePatcher::GetStaticCallTargetAt(pc_, code);
778 CodePatcher::PatchStaticCallAt(pc_, code,
779 StubCode::BreakpointStaticEntryPoint());
780 break;
781 }
782 case PcDescriptors::kRuntimeCall:
783 case PcDescriptors::kClosureCall:
784 case PcDescriptors::kReturn: {
785 const Code& code =
786 Code::Handle(Function::Handle(function_).unoptimized_code());
787 saved_bytes_.target_address_ =
788 CodePatcher::GetStaticCallTargetAt(pc_, code);
789 CodePatcher::PatchStaticCallAt(pc_, code,
790 StubCode::BreakpointRuntimeEntryPoint());
791 break;
792 }
793 default:
794 UNREACHABLE();
795 } 795 }
796 is_enabled_ = true; 796 is_enabled_ = true;
797 } 797 }
798 798
799 799
800 void CodeBreakpoint::RestoreCode() { 800 void CodeBreakpoint::RestoreCode() {
801 ASSERT(is_enabled_); 801 ASSERT(is_enabled_);
802 switch (breakpoint_kind_) { 802 const Code& code =
803 case PcDescriptors::kIcCall: { 803 Code::Handle(Function::Handle(function_).unoptimized_code());
804 const Code& code = 804 const Instructions& instrs = Instructions::Handle(code.instructions());
805 Code::Handle(Function::Handle(function_).unoptimized_code()); 805 {
806 CodePatcher::PatchInstanceCallAt(pc_, code, 806 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
807 switch (breakpoint_kind_) {
808 case PcDescriptors::kIcCall: {
809 CodePatcher::PatchInstanceCallAt(pc_, code,
810 saved_bytes_.target_address_);
811 break;
812 }
813 case PcDescriptors::kUnoptStaticCall:
814 case PcDescriptors::kClosureCall:
815 case PcDescriptors::kRuntimeCall:
816 case PcDescriptors::kReturn: {
817 CodePatcher::PatchStaticCallAt(pc_, code,
807 saved_bytes_.target_address_); 818 saved_bytes_.target_address_);
808 break; 819 break;
820 }
821 default:
822 UNREACHABLE();
809 } 823 }
810 case PcDescriptors::kUnoptStaticCall:
811 case PcDescriptors::kClosureCall:
812 case PcDescriptors::kRuntimeCall:
813 case PcDescriptors::kReturn: {
814 const Code& code =
815 Code::Handle(Function::Handle(function_).unoptimized_code());
816 CodePatcher::PatchStaticCallAt(pc_, code,
817 saved_bytes_.target_address_);
818 break;
819 }
820 default:
821 UNREACHABLE();
822 } 824 }
823 is_enabled_ = false; 825 is_enabled_ = false;
824 } 826 }
825 827
826 828
827 void CodeBreakpoint::Enable() { 829 void CodeBreakpoint::Enable() {
828 if (!is_enabled_) { 830 if (!is_enabled_) {
829 PatchCode(); 831 PatchCode();
830 } 832 }
831 ASSERT(is_enabled_); 833 ASSERT(is_enabled_);
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after
2281 } 2283 }
2282 2284
2283 2285
2284 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 2286 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
2285 ASSERT(bpt->next() == NULL); 2287 ASSERT(bpt->next() == NULL);
2286 bpt->set_next(code_breakpoints_); 2288 bpt->set_next(code_breakpoints_);
2287 code_breakpoints_ = bpt; 2289 code_breakpoints_ = bpt;
2288 } 2290 }
2289 2291
2290 } // namespace dart 2292 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/freelist.h » ('j') | runtime/vm/freelist.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698