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

Side by Side Diff: runtime/vm/debugger_ia32.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/debugger.h" 8 #include "vm/debugger.h"
9 9
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 26 matching lines...) Expand all
37 } 37 }
38 38
39 39
40 uword CodeBreakpoint::OrigStubAddress() const { 40 uword CodeBreakpoint::OrigStubAddress() const {
41 return saved_value_; 41 return saved_value_;
42 } 42 }
43 43
44 44
45 void CodeBreakpoint::PatchCode() { 45 void CodeBreakpoint::PatchCode() {
46 ASSERT(!is_enabled_); 46 ASSERT(!is_enabled_);
47 switch (breakpoint_kind_) { 47 const Code& code =
48 case PcDescriptors::kIcCall: { 48 Code::Handle(Function::Handle(function_).unoptimized_code());
49 const Code& code = 49 const Instructions& instrs = Instructions::Handle(code.instructions());
50 Code::Handle(Function::Handle(function_).unoptimized_code()); 50 {
51 saved_value_ = CodePatcher::GetInstanceCallAt(pc_, code, NULL); 51 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
52 CodePatcher::PatchInstanceCallAt(pc_, code, 52 switch (breakpoint_kind_) {
53 StubCode::BreakpointDynamicEntryPoint()); 53 case PcDescriptors::kIcCall: {
54 break; 54 saved_value_ = CodePatcher::GetInstanceCallAt(pc_, code, NULL);
55 CodePatcher::PatchInstanceCallAt(
56 pc_, code, StubCode::BreakpointDynamicEntryPoint());
57 break;
58 }
59 case PcDescriptors::kUnoptStaticCall: {
60 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
61 CodePatcher::PatchStaticCallAt(pc_, code,
62 StubCode::BreakpointStaticEntryPoint());
63 break;
64 }
65 case PcDescriptors::kRuntimeCall:
66 case PcDescriptors::kClosureCall:
67 case PcDescriptors::kReturn: {
68 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
69 CodePatcher::PatchStaticCallAt(pc_, code,
70 StubCode::BreakpointRuntimeEntryPoint());
71 break;
72 }
73 default:
74 UNREACHABLE();
55 } 75 }
56 case PcDescriptors::kUnoptStaticCall: {
57 const Code& code =
58 Code::Handle(Function::Handle(function_).unoptimized_code());
59 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
60 CodePatcher::PatchStaticCallAt(pc_, code,
61 StubCode::BreakpointStaticEntryPoint());
62 break;
63 }
64 case PcDescriptors::kRuntimeCall:
65 case PcDescriptors::kClosureCall:
66 case PcDescriptors::kReturn: {
67 const Code& code =
68 Code::Handle(Function::Handle(function_).unoptimized_code());
69 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
70 CodePatcher::PatchStaticCallAt(pc_, code,
71 StubCode::BreakpointRuntimeEntryPoint());
72 break;
73 }
74 default:
75 UNREACHABLE();
76 } 76 }
77 is_enabled_ = true; 77 is_enabled_ = true;
78 } 78 }
79 79
80 80
81 void CodeBreakpoint::RestoreCode() { 81 void CodeBreakpoint::RestoreCode() {
82 ASSERT(is_enabled_); 82 ASSERT(is_enabled_);
83 switch (breakpoint_kind_) { 83 const Code& code =
84 case PcDescriptors::kIcCall: { 84 Code::Handle(Function::Handle(function_).unoptimized_code());
85 const Code& code = 85 const Instructions& instrs = Instructions::Handle(code.instructions());
86 Code::Handle(Function::Handle(function_).unoptimized_code()); 86 {
87 CodePatcher::PatchInstanceCallAt(pc_, code, saved_value_); 87 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
88 break; 88 switch (breakpoint_kind_) {
89 case PcDescriptors::kIcCall: {
90 CodePatcher::PatchInstanceCallAt(pc_, code, saved_value_);
91 break;
92 }
93 case PcDescriptors::kUnoptStaticCall:
94 case PcDescriptors::kClosureCall:
95 case PcDescriptors::kRuntimeCall:
96 case PcDescriptors::kReturn: {
97 CodePatcher::PatchStaticCallAt(pc_, code, saved_value_);
98 break;
99 }
100 default:
101 UNREACHABLE();
89 } 102 }
90 case PcDescriptors::kUnoptStaticCall:
91 case PcDescriptors::kClosureCall:
92 case PcDescriptors::kRuntimeCall:
93 case PcDescriptors::kReturn: {
94 const Code& code =
95 Code::Handle(Function::Handle(function_).unoptimized_code());
96 CodePatcher::PatchStaticCallAt(pc_, code, saved_value_);
97 break;
98 }
99 default:
100 UNREACHABLE();
101 } 103 }
102 is_enabled_ = false; 104 is_enabled_ = false;
103 } 105 }
104 106
105 } // namespace dart 107 } // namespace dart
106 108
107 #endif // defined TARGET_ARCH_IA32 109 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698