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

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

Issue 274043003: Adds debugger patching to arm64. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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_api_impl_test.cc ('k') | runtime/vm/debugger_test.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 RawInstance* ActivationFrame::GetInstanceCallReceiver( 16 RawInstance* ActivationFrame::GetInstanceCallReceiver(
17 intptr_t num_actual_args) { 17 intptr_t num_actual_args) {
18 UNIMPLEMENTED(); 18 ASSERT(num_actual_args > 0); // At minimum we have a receiver on the stack.
19 return NULL; 19 // Stack pointer points to last argument that was pushed on the stack.
20 const uword receiver_addr = sp() + ((num_actual_args - 1) * kWordSize);
21 const uword receiver = *reinterpret_cast<uword*>(receiver_addr);
22 return reinterpret_cast<RawInstance*>(receiver);
20 } 23 }
21 24
22 25
23 RawObject* ActivationFrame::GetClosureObject(intptr_t num_actual_args) { 26 RawObject* ActivationFrame::GetClosureObject(intptr_t num_actual_args) {
24 UNIMPLEMENTED(); 27 // At a minimum we have the closure object on the stack.
25 return NULL; 28 ASSERT(num_actual_args > 0);
29 // Stack pointer points to last argument that was pushed on the stack.
30 const uword closure_addr = sp() + ((num_actual_args - 1) * kWordSize);
31 const uword closure = *reinterpret_cast<uword*>(closure_addr);
32 return reinterpret_cast<RawObject*>(closure);
26 } 33 }
27 34
28 35
29 uword CodeBreakpoint::OrigStubAddress() const { 36 uword CodeBreakpoint::OrigStubAddress() const {
30 UNIMPLEMENTED(); 37 const Code& code = Code::Handle(code_);
31 return 0; 38 const Array& object_pool = Array::Handle(code.ObjectPool());
39 const uword offset = saved_value_;
40 ASSERT((offset % kWordSize) == 0);
41 const intptr_t index = (offset - Array::data_offset()) / kWordSize;
42 const uword stub_address = reinterpret_cast<uword>(object_pool.At(index));
43 ASSERT(stub_address % kWordSize == 0);
44 return stub_address;
32 } 45 }
33 46
34 47
35 void CodeBreakpoint::PatchCode() { 48 void CodeBreakpoint::PatchCode() {
36 UNIMPLEMENTED(); 49 ASSERT(!is_enabled_);
50 const Code& code = Code::Handle(code_);
51 const Instructions& instrs = Instructions::Handle(code.instructions());
52 {
53 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
54 switch (breakpoint_kind_) {
55 case PcDescriptors::kIcCall:
56 case PcDescriptors::kUnoptStaticCall:
57 case PcDescriptors::kRuntimeCall:
58 case PcDescriptors::kClosureCall:
59 case PcDescriptors::kReturn: {
60 int32_t offset = CodePatcher::GetPoolOffsetAt(pc_);
61 ASSERT((offset > 0) && ((offset & 0x7) == 0));
62 saved_value_ = static_cast<uword>(offset);
63 const uint32_t stub_offset =
64 InstructionPattern::OffsetFromPPIndex(
65 Assembler::kBreakpointRuntimeCPIndex);
66 CodePatcher::SetPoolOffsetAt(pc_, stub_offset);
67 break;
68 }
69 default:
70 UNREACHABLE();
71 }
72 }
73 is_enabled_ = true;
37 } 74 }
38 75
39 76
40 void CodeBreakpoint::RestoreCode() { 77 void CodeBreakpoint::RestoreCode() {
41 UNIMPLEMENTED(); 78 ASSERT(is_enabled_);
79 const Code& code = Code::Handle(code_);
80 const Instructions& instrs = Instructions::Handle(code.instructions());
81 {
82 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
83 switch (breakpoint_kind_) {
84 case PcDescriptors::kIcCall:
85 case PcDescriptors::kUnoptStaticCall:
86 case PcDescriptors::kClosureCall:
87 case PcDescriptors::kRuntimeCall:
88 case PcDescriptors::kReturn: {
89 CodePatcher::SetPoolOffsetAt(pc_, static_cast<int32_t>(saved_value_));
90 break;
91 }
92 default:
93 UNREACHABLE();
94 }
95 }
96 is_enabled_ = false;
42 } 97 }
43 98
44 } // namespace dart 99 } // namespace dart
45 100
46 #endif // defined TARGET_ARCH_ARM64 101 #endif // defined TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « runtime/vm/debugger_api_impl_test.cc ('k') | runtime/vm/debugger_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698