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

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

Issue 131853006: Fix debugger stub patching on x64 architecture (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/debugger_ia32.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_ARM) 6 #if defined(TARGET_ARCH_ARM)
7 7
8 #include "vm/code_patcher.h"
8 #include "vm/cpu.h" 9 #include "vm/cpu.h"
9 #include "vm/debugger.h" 10 #include "vm/debugger.h"
10 #include "vm/instructions.h" 11 #include "vm/instructions.h"
11 #include "vm/stub_code.h" 12 #include "vm/stub_code.h"
12 13
13 namespace dart { 14 namespace dart {
14 15
15 RawInstance* ActivationFrame::GetInstanceCallReceiver( 16 RawInstance* ActivationFrame::GetInstanceCallReceiver(
16 intptr_t num_actual_args) { 17 intptr_t num_actual_args) {
17 ASSERT(num_actual_args > 0); // At minimum we have a receiver on the stack. 18 ASSERT(num_actual_args > 0); // At minimum we have a receiver on the stack.
18 // Stack pointer points to last argument that was pushed on the stack. 19 // Stack pointer points to last argument that was pushed on the stack.
19 uword receiver_addr = sp() + ((num_actual_args - 1) * kWordSize); 20 uword receiver_addr = sp() + ((num_actual_args - 1) * kWordSize);
20 return reinterpret_cast<RawInstance*>( 21 return reinterpret_cast<RawInstance*>(
21 *reinterpret_cast<uword*>(receiver_addr)); 22 *reinterpret_cast<uword*>(receiver_addr));
22 } 23 }
23 24
24 25
25 RawObject* ActivationFrame::GetClosureObject(intptr_t num_actual_args) { 26 RawObject* ActivationFrame::GetClosureObject(intptr_t num_actual_args) {
26 // At a minimum we have the closure object on the stack. 27 // At a minimum we have the closure object on the stack.
27 ASSERT(num_actual_args > 0); 28 ASSERT(num_actual_args > 0);
28 // Stack pointer points to last argument that was pushed on the stack. 29 // Stack pointer points to last argument that was pushed on the stack.
29 uword closure_addr = sp() + ((num_actual_args - 1) * kWordSize); 30 uword closure_addr = sp() + ((num_actual_args - 1) * kWordSize);
30 return reinterpret_cast<RawObject*>( 31 return reinterpret_cast<RawObject*>(
31 *reinterpret_cast<uword*>(closure_addr)); 32 *reinterpret_cast<uword*>(closure_addr));
32 } 33 }
33 34
35
36 uword CodeBreakpoint::OrigStubAddress() const {
37 return saved_value_;
38 }
39
40
41 void CodeBreakpoint::PatchCode() {
42 ASSERT(!is_enabled_);
43 switch (breakpoint_kind_) {
44 case PcDescriptors::kIcCall: {
45 const Code& code =
46 Code::Handle(Function::Handle(function_).unoptimized_code());
47 saved_value_ = CodePatcher::GetInstanceCallAt(pc_, code, NULL);
48 CodePatcher::PatchInstanceCallAt(pc_, code,
49 StubCode::BreakpointDynamicEntryPoint());
50 break;
51 }
52 case PcDescriptors::kUnoptStaticCall: {
53 const Code& code =
54 Code::Handle(Function::Handle(function_).unoptimized_code());
55 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
56 CodePatcher::PatchStaticCallAt(pc_, code,
57 StubCode::BreakpointStaticEntryPoint());
58 break;
59 }
60 case PcDescriptors::kRuntimeCall:
61 case PcDescriptors::kClosureCall:
62 case PcDescriptors::kReturn: {
63 const Code& code =
64 Code::Handle(Function::Handle(function_).unoptimized_code());
65 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
66 CodePatcher::PatchStaticCallAt(pc_, code,
67 StubCode::BreakpointRuntimeEntryPoint());
68 break;
69 }
70 default:
71 UNREACHABLE();
72 }
73 is_enabled_ = true;
74 }
75
76
77 void CodeBreakpoint::RestoreCode() {
78 ASSERT(is_enabled_);
79 switch (breakpoint_kind_) {
80 case PcDescriptors::kIcCall: {
81 const Code& code =
82 Code::Handle(Function::Handle(function_).unoptimized_code());
83 CodePatcher::PatchInstanceCallAt(pc_, code, saved_value_);
84 break;
85 }
86 case PcDescriptors::kUnoptStaticCall:
87 case PcDescriptors::kClosureCall:
88 case PcDescriptors::kRuntimeCall:
89 case PcDescriptors::kReturn: {
90 const Code& code =
91 Code::Handle(Function::Handle(function_).unoptimized_code());
92 CodePatcher::PatchStaticCallAt(pc_, code, saved_value_);
93 break;
94 }
95 default:
96 UNREACHABLE();
97 }
98 is_enabled_ = false;
99 }
100
34 } // namespace dart 101 } // namespace dart
35 102
36 #endif // defined TARGET_ARCH_ARM 103 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/debugger_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698