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

Unified Diff: runtime/vm/debugger_arm.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: Fixed typo and removed debug printing 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/debugger_arm.cc
diff --git a/runtime/vm/debugger_arm.cc b/runtime/vm/debugger_arm.cc
index 753f781d7534db1536b127c8834c3457d9d68812..711cf3c92fe41e63cf336dbd96660b37c0f72d33 100644
--- a/runtime/vm/debugger_arm.cc
+++ b/runtime/vm/debugger_arm.cc
@@ -40,35 +40,35 @@ uword CodeBreakpoint::OrigStubAddress() const {
void CodeBreakpoint::PatchCode() {
ASSERT(!is_enabled_);
- switch (breakpoint_kind_) {
- case PcDescriptors::kIcCall: {
- const Code& code =
- Code::Handle(Function::Handle(function_).unoptimized_code());
- saved_value_ = CodePatcher::GetInstanceCallAt(pc_, code, NULL);
- CodePatcher::PatchInstanceCallAt(pc_, code,
- StubCode::BreakpointDynamicEntryPoint());
- break;
+ const Code& code =
+ Code::Handle(Function::Handle(function_).unoptimized_code());
+ const Instructions& instrs = Instructions::Handle(code.instructions());
+ {
+ WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
+ switch (breakpoint_kind_) {
+ case PcDescriptors::kIcCall: {
+ saved_value_ = CodePatcher::GetInstanceCallAt(pc_, code, NULL);
+ CodePatcher::PatchInstanceCallAt(
+ pc_, code, StubCode::BreakpointDynamicEntryPoint());
+ break;
+ }
+ case PcDescriptors::kUnoptStaticCall: {
+ saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
+ CodePatcher::PatchStaticCallAt(pc_, code,
+ StubCode::BreakpointStaticEntryPoint());
+ break;
+ }
+ case PcDescriptors::kRuntimeCall:
+ case PcDescriptors::kClosureCall:
+ case PcDescriptors::kReturn: {
+ saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
+ CodePatcher::PatchStaticCallAt(pc_, code,
+ StubCode::BreakpointRuntimeEntryPoint());
+ break;
+ }
+ default:
+ UNREACHABLE();
}
- case PcDescriptors::kUnoptStaticCall: {
- const Code& code =
- Code::Handle(Function::Handle(function_).unoptimized_code());
- saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
- CodePatcher::PatchStaticCallAt(pc_, code,
- StubCode::BreakpointStaticEntryPoint());
- break;
- }
- case PcDescriptors::kRuntimeCall:
- case PcDescriptors::kClosureCall:
- case PcDescriptors::kReturn: {
- const Code& code =
- Code::Handle(Function::Handle(function_).unoptimized_code());
- saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
- CodePatcher::PatchStaticCallAt(pc_, code,
- StubCode::BreakpointRuntimeEntryPoint());
- break;
- }
- default:
- UNREACHABLE();
}
is_enabled_ = true;
}
@@ -76,24 +76,26 @@ void CodeBreakpoint::PatchCode() {
void CodeBreakpoint::RestoreCode() {
ASSERT(is_enabled_);
- switch (breakpoint_kind_) {
- case PcDescriptors::kIcCall: {
- const Code& code =
- Code::Handle(Function::Handle(function_).unoptimized_code());
- CodePatcher::PatchInstanceCallAt(pc_, code, saved_value_);
- break;
- }
- case PcDescriptors::kUnoptStaticCall:
- case PcDescriptors::kClosureCall:
- case PcDescriptors::kRuntimeCall:
- case PcDescriptors::kReturn: {
- const Code& code =
- Code::Handle(Function::Handle(function_).unoptimized_code());
- CodePatcher::PatchStaticCallAt(pc_, code, saved_value_);
- break;
+ const Code& code =
+ Code::Handle(Function::Handle(function_).unoptimized_code());
+ const Instructions& instrs = Instructions::Handle(code.instructions());
+ {
+ WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
+ switch (breakpoint_kind_) {
+ case PcDescriptors::kIcCall: {
+ CodePatcher::PatchInstanceCallAt(pc_, code, saved_value_);
+ break;
+ }
+ case PcDescriptors::kUnoptStaticCall:
+ case PcDescriptors::kClosureCall:
+ case PcDescriptors::kRuntimeCall:
+ case PcDescriptors::kReturn: {
+ CodePatcher::PatchStaticCallAt(pc_, code, saved_value_);
+ break;
+ }
+ default:
+ UNREACHABLE();
}
- default:
- UNREACHABLE();
}
is_enabled_ = false;
}

Powered by Google App Engine
This is Rietveld 408576698