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

Side by Side Diff: dart/runtime/vm/debugger_x64.cc

Issue 119673004: Version 1.1.0-dev.5.2 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
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 | « dart/runtime/vm/debugger_test.cc ('k') | dart/runtime/vm/flow_graph_builder.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"
(...skipping 14 matching lines...) Expand all
25 25
26 RawObject* ActivationFrame::GetClosureObject(intptr_t num_actual_args) { 26 RawObject* ActivationFrame::GetClosureObject(intptr_t num_actual_args) {
27 // At a minimum we have the closure object on the stack. 27 // At a minimum we have the closure object on the stack.
28 ASSERT(num_actual_args > 0); 28 ASSERT(num_actual_args > 0);
29 // 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.
30 uword closure_addr = sp() + ((num_actual_args - 1) * kWordSize); 30 uword closure_addr = sp() + ((num_actual_args - 1) * kWordSize);
31 return reinterpret_cast<RawObject*>( 31 return reinterpret_cast<RawObject*>(
32 *reinterpret_cast<uword*>(closure_addr)); 32 *reinterpret_cast<uword*>(closure_addr));
33 } 33 }
34 34
35
36 void CodeBreakpoint::PatchFunctionReturn() {
37 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 13);
38 ASSERT((code[0] == 0x4c) && (code[1] == 0x8b) && (code[2] == 0x7d) &&
39 (code[3] == 0xf0)); // movq r15,[rbp-0x10]
40 ASSERT((code[4] == 0x48) && (code[5] == 0x89) &&
41 (code[6] == 0xec)); // mov rsp, rbp
42 ASSERT(code[7] == 0x5d); // pop rbp
43 ASSERT(code[8] == 0xc3); // ret
44 ASSERT((code[9] == 0x0F) && (code[10] == 0x1F) && (code[11] == 0x40) &&
45 (code[12] == 0x00)); // nops
46 // Smash code with call instruction and relative target address.
47 uword stub_addr = StubCode::BreakpointReturnEntryPoint();
48 code[0] = 0x49;
49 code[1] = 0xbb;
50 *reinterpret_cast<uword*>(&code[2]) = stub_addr;
51 code[10] = 0x41;
52 code[11] = 0xff;
53 code[12] = 0xd3;
54 CPU::FlushICache(pc_ - 13, 13);
55 }
56
57
58 void CodeBreakpoint::RestoreFunctionReturn() {
59 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 13);
60 ASSERT((code[0] == 0x49) && (code[1] == 0xbb));
61
62 MemoryRegion code_region(reinterpret_cast<void*>(pc_ - 13), 13);
63 Assembler assembler;
64
65 assembler.ReturnPatchable();
66 assembler.FinalizeInstructions(code_region);
67
68 CPU::FlushICache(pc_ - 13, 13);
69 }
70
71 } // namespace dart 35 } // namespace dart
72 36
73 #endif // defined TARGET_ARCH_X64 37 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « dart/runtime/vm/debugger_test.cc ('k') | dart/runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698