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

Side by Side Diff: runtime/vm/debugger_x64.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/debugger_arm64.cc ('k') | runtime/vm/intermediate_language_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) 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_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/debugger.h" 8 #include "vm/debugger.h"
9 9
10 #include "vm/assembler.h" 10 #include "vm/assembler.h"
11 #include "vm/code_patcher.h" 11 #include "vm/code_patcher.h"
12 #include "vm/cpu.h" 12 #include "vm/cpu.h"
13 #include "vm/instructions.h" 13 #include "vm/instructions.h"
14 #include "vm/stub_code.h" 14 #include "vm/stub_code.h"
15 15
16 namespace dart { 16 namespace dart {
17 17
18 uword CodeBreakpoint::OrigStubAddress() const { 18 uword CodeBreakpoint::OrigStubAddress() const {
19 const Code& code = Code::Handle(code_); 19 return saved_value_;
20 const Array& object_pool = Array::Handle(code.ObjectPool());
21 uword offset = saved_value_ + kHeapObjectTag;
22 ASSERT((offset % kWordSize) == 0);
23 const intptr_t index = (offset - Array::data_offset()) / kWordSize;
24 const uword stub_address = reinterpret_cast<uword>(object_pool.At(index));
25 ASSERT(stub_address % kWordSize == 0);
26 return stub_address;
27 } 20 }
28 21
29 22
30 void CodeBreakpoint::PatchCode() { 23 void CodeBreakpoint::PatchCode() {
31 ASSERT(!is_enabled_); 24 ASSERT(!is_enabled_);
25 StubCode* stub_code = Isolate::Current()->stub_code();
26 uword stub_target = 0;
27 switch (breakpoint_kind_) {
28 case RawPcDescriptors::kIcCall:
29 case RawPcDescriptors::kUnoptStaticCall:
30 stub_target = stub_code->ICCallBreakpointEntryPoint();
31 break;
32 case RawPcDescriptors::kClosureCall:
33 stub_target = stub_code->ClosureCallBreakpointEntryPoint();
34 break;
35 case RawPcDescriptors::kRuntimeCall:
36 stub_target = stub_code->RuntimeCallBreakpointEntryPoint();
37 break;
38 default:
39 UNREACHABLE();
40 }
32 const Code& code = Code::Handle(code_); 41 const Code& code = Code::Handle(code_);
33 const Instructions& instrs = Instructions::Handle(code.instructions()); 42 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
34 { 43 CodePatcher::PatchPoolPointerCallAt(pc_, code, stub_target);
35 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
36 switch (breakpoint_kind_) {
37 case RawPcDescriptors::kIcCall:
38 case RawPcDescriptors::kUnoptStaticCall: {
39 int32_t offset = CodePatcher::GetPoolOffsetAt(pc_);
40 ASSERT((offset > 0) && ((offset % 8) == 7));
41 saved_value_ = static_cast<uword>(offset);
42 const uint32_t stub_offset =
43 InstructionPattern::OffsetFromPPIndex(
44 Assembler::kICCallBreakpointCPIndex);
45 CodePatcher::SetPoolOffsetAt(pc_, stub_offset);
46 break;
47 }
48 case RawPcDescriptors::kClosureCall: {
49 int32_t offset = CodePatcher::GetPoolOffsetAt(pc_);
50 ASSERT((offset > 0) && ((offset % 8) == 7));
51 saved_value_ = static_cast<uword>(offset);
52 const uint32_t stub_offset =
53 InstructionPattern::OffsetFromPPIndex(
54 Assembler::kClosureCallBreakpointCPIndex);
55 CodePatcher::SetPoolOffsetAt(pc_, stub_offset);
56 break;
57 }
58 case RawPcDescriptors::kRuntimeCall: {
59 int32_t offset = CodePatcher::GetPoolOffsetAt(pc_);
60 ASSERT((offset > 0) && ((offset % 8) == 7));
61 saved_value_ = static_cast<uword>(offset);
62 const uint32_t stub_offset =
63 InstructionPattern::OffsetFromPPIndex(
64 Assembler::kRuntimeCallBreakpointCPIndex);
65 CodePatcher::SetPoolOffsetAt(pc_, stub_offset);
66 break;
67 }
68 default:
69 UNREACHABLE();
70 }
71 }
72 is_enabled_ = true; 44 is_enabled_ = true;
73 } 45 }
74 46
75 47
76 void CodeBreakpoint::RestoreCode() { 48 void CodeBreakpoint::RestoreCode() {
77 ASSERT(is_enabled_); 49 ASSERT(is_enabled_);
78 const Code& code = Code::Handle(code_); 50 const Code& code = Code::Handle(code_);
79 const Instructions& instrs = Instructions::Handle(code.instructions()); 51 switch (breakpoint_kind_) {
80 { 52 case RawPcDescriptors::kIcCall:
81 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); 53 case RawPcDescriptors::kUnoptStaticCall:
82 switch (breakpoint_kind_) { 54 case RawPcDescriptors::kClosureCall:
83 case RawPcDescriptors::kIcCall: 55 case RawPcDescriptors::kRuntimeCall: {
84 case RawPcDescriptors::kUnoptStaticCall: 56 CodePatcher::PatchPoolPointerCallAt(pc_, code, saved_value_);
85 case RawPcDescriptors::kClosureCall: 57 break;
86 case RawPcDescriptors::kRuntimeCall: {
87 CodePatcher::SetPoolOffsetAt(pc_, static_cast<int32_t>(saved_value_));
88 break;
89 }
90 default:
91 UNREACHABLE();
92 } 58 }
59 default:
60 UNREACHABLE();
93 } 61 }
94 is_enabled_ = false; 62 is_enabled_ = false;
95 } 63 }
96 64
97 65
98 } // namespace dart 66 } // namespace dart
99 67
100 #endif // defined TARGET_ARCH_X64 68 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/debugger_arm64.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698