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

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

Issue 1137313002: VM: Set breakpoints on x64 and arm64 without patching code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: re-upload from git workspace Created 5 years, 7 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
« no previous file with comments | « runtime/vm/code_patcher_x64.cc ('k') | runtime/vm/debugger_x64.cc » ('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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
7 7
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/debugger.h" 10 #include "vm/debugger.h"
11 #include "vm/instructions.h" 11 #include "vm/instructions.h"
12 #include "vm/stub_code.h" 12 #include "vm/stub_code.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 uword CodeBreakpoint::OrigStubAddress() const { 16 uword CodeBreakpoint::OrigStubAddress() const {
17 const Code& code = Code::Handle(code_); 17 return saved_value_;
18 const Array& object_pool = Array::Handle(code.ObjectPool());
19 const uword offset = saved_value_;
20 ASSERT((offset % kWordSize) == 0);
21 const intptr_t index = (offset - Array::data_offset()) / kWordSize;
22 const uword stub_address = reinterpret_cast<uword>(object_pool.At(index));
23 ASSERT(stub_address % kWordSize == 0);
24 return stub_address;
25 } 18 }
26 19
27 20
28 void CodeBreakpoint::PatchCode() { 21 void CodeBreakpoint::PatchCode() {
29 ASSERT(!is_enabled_); 22 ASSERT(!is_enabled_);
23 StubCode* stub_code = Isolate::Current()->stub_code();
24 uword stub_target = 0;
25 switch (breakpoint_kind_) {
26 case RawPcDescriptors::kIcCall:
27 case RawPcDescriptors::kUnoptStaticCall:
28 stub_target = stub_code->ICCallBreakpointEntryPoint();
29 break;
30 case RawPcDescriptors::kClosureCall:
31 stub_target = stub_code->ClosureCallBreakpointEntryPoint();
32 break;
33 case RawPcDescriptors::kRuntimeCall: {
34 stub_target = stub_code->RuntimeCallBreakpointEntryPoint();
35 break;
36 }
37 default:
38 UNREACHABLE();
39 }
30 const Code& code = Code::Handle(code_); 40 const Code& code = Code::Handle(code_);
31 const Instructions& instrs = Instructions::Handle(code.instructions()); 41 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
32 { 42 CodePatcher::PatchPoolPointerCallAt(pc_, code, stub_target);
33 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
34 switch (breakpoint_kind_) {
35 case RawPcDescriptors::kIcCall:
36 case RawPcDescriptors::kUnoptStaticCall: {
37 int32_t offset = CodePatcher::GetPoolOffsetAt(pc_);
38 ASSERT((offset > 0) && ((offset & 0x7) == 0));
39 saved_value_ = static_cast<uword>(offset);
40 const uint32_t stub_offset =
41 InstructionPattern::OffsetFromPPIndex(
42 Assembler::kICCallBreakpointCPIndex);
43 CodePatcher::SetPoolOffsetAt(pc_, stub_offset);
44 break;
45 }
46 case RawPcDescriptors::kClosureCall: {
47 int32_t offset = CodePatcher::GetPoolOffsetAt(pc_);
48 ASSERT((offset > 0) && ((offset & 0x7) == 0));
49 saved_value_ = static_cast<uword>(offset);
50 const uint32_t stub_offset =
51 InstructionPattern::OffsetFromPPIndex(
52 Assembler::kClosureCallBreakpointCPIndex);
53 CodePatcher::SetPoolOffsetAt(pc_, stub_offset);
54 break;
55 }
56 case RawPcDescriptors::kRuntimeCall: {
57 int32_t offset = CodePatcher::GetPoolOffsetAt(pc_);
58 ASSERT((offset > 0) && ((offset & 0x7) == 0));
59 saved_value_ = static_cast<uword>(offset);
60 const uint32_t stub_offset =
61 InstructionPattern::OffsetFromPPIndex(
62 Assembler::kRuntimeCallBreakpointCPIndex);
63 CodePatcher::SetPoolOffsetAt(pc_, stub_offset);
64 break;
65 }
66 default:
67 UNREACHABLE();
68 }
69 }
70 is_enabled_ = true; 43 is_enabled_ = true;
71 } 44 }
72 45
73 46
74 void CodeBreakpoint::RestoreCode() { 47 void CodeBreakpoint::RestoreCode() {
75 ASSERT(is_enabled_); 48 ASSERT(is_enabled_);
76 const Code& code = Code::Handle(code_); 49 const Code& code = Code::Handle(code_);
77 const Instructions& instrs = Instructions::Handle(code.instructions()); 50 switch (breakpoint_kind_) {
78 { 51 case RawPcDescriptors::kIcCall:
79 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); 52 case RawPcDescriptors::kUnoptStaticCall:
80 switch (breakpoint_kind_) { 53 case RawPcDescriptors::kClosureCall:
81 case RawPcDescriptors::kIcCall: 54 case RawPcDescriptors::kRuntimeCall: {
82 case RawPcDescriptors::kUnoptStaticCall: 55 CodePatcher::PatchPoolPointerCallAt(pc_, code, saved_value_);
83 case RawPcDescriptors::kClosureCall: 56 break;
84 case RawPcDescriptors::kRuntimeCall: {
85 CodePatcher::SetPoolOffsetAt(pc_, static_cast<int32_t>(saved_value_));
86 break;
87 }
88 default:
89 UNREACHABLE();
90 } 57 }
58 default:
59 UNREACHABLE();
91 } 60 }
92 is_enabled_ = false; 61 is_enabled_ = false;
93 } 62 }
94 63
95 } // namespace dart 64 } // namespace dart
96 65
97 #endif // defined TARGET_ARCH_ARM64 66 #endif // defined TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « runtime/vm/code_patcher_x64.cc ('k') | runtime/vm/debugger_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698