OLD | NEW |
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/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 (code[9] == 0x90) && (code[10] == 0x90) && | 42 (code[9] == 0x90) && (code[10] == 0x90) && |
43 (code[11] == 0x90) && (code[12] == 0x90)); | 43 (code[11] == 0x90) && (code[12] == 0x90)); |
44 // Smash code with call instruction and relative target address. | 44 // Smash code with call instruction and relative target address. |
45 uword stub_addr = StubCode::BreakpointReturnEntryPoint(); | 45 uword stub_addr = StubCode::BreakpointReturnEntryPoint(); |
46 code[0] = 0x49; | 46 code[0] = 0x49; |
47 code[1] = 0xbb; | 47 code[1] = 0xbb; |
48 *reinterpret_cast<uword*>(&code[2]) = stub_addr; | 48 *reinterpret_cast<uword*>(&code[2]) = stub_addr; |
49 code[10] = 0x41; | 49 code[10] = 0x41; |
50 code[11] = 0xff; | 50 code[11] = 0xff; |
51 code[12] = 0xd3; | 51 code[12] = 0xd3; |
52 CPU::FlushICache(pc_, 5); | 52 CPU::FlushICache(pc_ - 13, 13); |
53 } | 53 } |
54 | 54 |
55 | 55 |
56 void CodeBreakpoint::RestoreFunctionReturn() { | 56 void CodeBreakpoint::RestoreFunctionReturn() { |
57 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 13); | 57 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 13); |
58 ASSERT((code[0] == 0x49) && (code[1] == 0xbb)); | 58 ASSERT((code[0] == 0x49) && (code[1] == 0xbb)); |
59 code[0] = 0x48; // movq %rbp,%rsp | 59 code[0] = 0x48; // movq %rbp,%rsp |
60 code[1] = 0x89; | 60 code[1] = 0x89; |
61 code[2] = 0xec; | 61 code[2] = 0xec; |
62 code[3] = 0x5d; // popq %rbp | 62 code[3] = 0x5d; // popq %rbp |
63 code[4] = 0xc3; // ret | 63 code[4] = 0xc3; // ret |
64 code[5] = 0x90; // nop | 64 code[5] = 0x90; // nop |
65 code[6] = 0x90; // nop | 65 code[6] = 0x90; // nop |
66 code[7] = 0x90; // nop | 66 code[7] = 0x90; // nop |
67 code[8] = 0x90; // nop | 67 code[8] = 0x90; // nop |
68 code[9] = 0x90; // nop | 68 code[9] = 0x90; // nop |
69 code[10] = 0x90; // nop | 69 code[10] = 0x90; // nop |
70 code[11] = 0x90; // nop | 70 code[11] = 0x90; // nop |
71 code[12] = 0x90; // nop | 71 code[12] = 0x90; // nop |
72 CPU::FlushICache(pc_, 5); | 72 CPU::FlushICache(pc_ - 13, 13); |
73 } | 73 } |
74 | 74 |
75 } // namespace dart | 75 } // namespace dart |
76 | 76 |
77 #endif // defined TARGET_ARCH_X64 | 77 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |