OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "vm/simulator.h" | 6 #include "vm/simulator.h" |
7 #include "vm/signal_handler.h" | 7 #include "vm/signal_handler.h" |
8 #if defined(TARGET_OS_ANDROID) | 8 #if defined(TARGET_OS_ANDROID) |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
11 | 11 |
12 uintptr_t SignalHandler::GetProgramCounter(const mcontext_t& mcontext) { | 12 uintptr_t SignalHandler::GetProgramCounter(const mcontext_t& mcontext) { |
13 uintptr_t pc = 0; | 13 uintptr_t pc = 0; |
14 | 14 |
15 #if defined(HOST_ARCH_IA32) | 15 #if defined(HOST_ARCH_IA32) |
16 pc = static_cast<uintptr_t>(mcontext.gregs[REG_EIP]); | 16 pc = static_cast<uintptr_t>(mcontext.gregs[REG_EIP]); |
| 17 #elif defined(HOST_ARCH_X64) |
| 18 pc = static_cast<uintptr_t>(mcontext.gregs[REG_RIP]); |
17 #elif defined(HOST_ARCH_ARM) | 19 #elif defined(HOST_ARCH_ARM) |
18 pc = static_cast<uintptr_t>(mcontext.arm_pc); | 20 pc = static_cast<uintptr_t>(mcontext.arm_pc); |
19 #elif defined(HOST_ARCH_ARM64) | 21 #elif defined(HOST_ARCH_ARM64) |
20 pc = static_cast<uintptr_t>(mcontext.pc); | 22 pc = static_cast<uintptr_t>(mcontext.pc); |
21 #else | 23 #else |
22 #error Unsupported architecture. | 24 #error Unsupported architecture. |
23 #endif // HOST_ARCH_... | 25 #endif // HOST_ARCH_... |
24 return pc; | 26 return pc; |
25 } | 27 } |
26 | 28 |
27 | 29 |
28 uintptr_t SignalHandler::GetFramePointer(const mcontext_t& mcontext) { | 30 uintptr_t SignalHandler::GetFramePointer(const mcontext_t& mcontext) { |
29 uintptr_t fp = 0; | 31 uintptr_t fp = 0; |
30 | 32 |
31 #if defined(HOST_ARCH_IA32) | 33 #if defined(HOST_ARCH_IA32) |
32 fp = static_cast<uintptr_t>(mcontext.gregs[REG_EBP]); | 34 fp = static_cast<uintptr_t>(mcontext.gregs[REG_EBP]); |
| 35 #elif defined(HOST_ARCH_X64) |
| 36 fp = static_cast<uintptr_t>(mcontext.gregs[REG_RBP]); |
33 #elif defined(HOST_ARCH_ARM) | 37 #elif defined(HOST_ARCH_ARM) |
34 fp = static_cast<uintptr_t>(mcontext.arm_fp); | 38 fp = static_cast<uintptr_t>(mcontext.arm_fp); |
35 #elif defined(HOST_ARCH_ARM64) | 39 #elif defined(HOST_ARCH_ARM64) |
36 fp = static_cast<uintptr_t>(mcontext.regs[29]); | 40 fp = static_cast<uintptr_t>(mcontext.regs[29]); |
37 #else | 41 #else |
38 #error Unsupported architecture. | 42 #error Unsupported architecture. |
39 #endif // HOST_ARCH_... | 43 #endif // HOST_ARCH_... |
40 | 44 |
41 return fp; | 45 return fp; |
42 } | 46 } |
43 | 47 |
44 | 48 |
45 uintptr_t SignalHandler::GetCStackPointer(const mcontext_t& mcontext) { | 49 uintptr_t SignalHandler::GetCStackPointer(const mcontext_t& mcontext) { |
46 uintptr_t sp = 0; | 50 uintptr_t sp = 0; |
47 | 51 |
48 #if defined(HOST_ARCH_IA32) | 52 #if defined(HOST_ARCH_IA32) |
49 sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]); | 53 sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]); |
| 54 #elif defined(HOST_ARCH_X64) |
| 55 sp = static_cast<uintptr_t>(mcontext.gregs[REG_RSP]); |
50 #elif defined(HOST_ARCH_ARM) | 56 #elif defined(HOST_ARCH_ARM) |
51 sp = static_cast<uintptr_t>(mcontext.arm_sp); | 57 sp = static_cast<uintptr_t>(mcontext.arm_sp); |
52 #elif defined(HOST_ARCH_ARM64) | 58 #elif defined(HOST_ARCH_ARM64) |
53 sp = static_cast<uintptr_t>(mcontext.sp); | 59 sp = static_cast<uintptr_t>(mcontext.sp); |
54 #else | 60 #else |
55 #error Unsupported architecture. | 61 #error Unsupported architecture. |
56 #endif // HOST_ARCH_... | 62 #endif // HOST_ARCH_... |
57 return sp; | 63 return sp; |
58 } | 64 } |
59 | 65 |
60 | 66 |
61 uintptr_t SignalHandler::GetDartStackPointer(const mcontext_t& mcontext) { | 67 uintptr_t SignalHandler::GetDartStackPointer(const mcontext_t& mcontext) { |
62 uintptr_t sp = 0; | 68 uintptr_t sp = 0; |
63 | 69 |
64 #if defined(HOST_ARCH_IA32) | 70 #if defined(HOST_ARCH_IA32) |
65 sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]); | 71 sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]); |
| 72 #elif defined(HOST_ARCH_X64) |
| 73 sp = static_cast<uintptr_t>(mcontext.gregs[REG_RSP]); |
66 #elif defined(HOST_ARCH_ARM) | 74 #elif defined(HOST_ARCH_ARM) |
67 sp = static_cast<uintptr_t>(mcontext.arm_sp); | 75 sp = static_cast<uintptr_t>(mcontext.arm_sp); |
68 #elif defined(HOST_ARCH_ARM64) | 76 #elif defined(HOST_ARCH_ARM64) |
69 sp = static_cast<uintptr_t>(mcontext.regs[19]); | 77 sp = static_cast<uintptr_t>(mcontext.regs[19]); |
70 #else | 78 #else |
71 #error Unsupported architecture. | 79 #error Unsupported architecture. |
72 #endif // HOST_ARCH_... | 80 #endif // HOST_ARCH_... |
73 return sp; | 81 return sp; |
74 } | 82 } |
75 | 83 |
76 | 84 |
77 uintptr_t SignalHandler::GetLinkRegister(const mcontext_t& mcontext) { | 85 uintptr_t SignalHandler::GetLinkRegister(const mcontext_t& mcontext) { |
78 uintptr_t lr = 0; | 86 uintptr_t lr = 0; |
79 | 87 |
80 #if defined(HOST_ARCH_IA32) | 88 #if defined(HOST_ARCH_IA32) |
81 lr = 0; | 89 lr = 0; |
| 90 #elif defined(HOST_ARCH_X64) |
| 91 lr = 0; |
82 #elif defined(HOST_ARCH_ARM) | 92 #elif defined(HOST_ARCH_ARM) |
83 lr = static_cast<uintptr_t>(mcontext.arm_lr); | 93 lr = static_cast<uintptr_t>(mcontext.arm_lr); |
84 #elif defined(HOST_ARCH_ARM64) | 94 #elif defined(HOST_ARCH_ARM64) |
85 lr = static_cast<uintptr_t>(mcontext.regs[30]); | 95 lr = static_cast<uintptr_t>(mcontext.regs[30]); |
86 #else | 96 #else |
87 #error Unsupported architecture. | 97 #error Unsupported architecture. |
88 #endif // HOST_ARCH_... | 98 #endif // HOST_ARCH_... |
89 return lr; | 99 return lr; |
90 } | 100 } |
91 | 101 |
(...skipping 17 matching lines...) Expand all Loading... |
109 act.sa_handler = SIG_IGN; | 119 act.sa_handler = SIG_IGN; |
110 sigemptyset(&act.sa_mask); | 120 sigemptyset(&act.sa_mask); |
111 int r = sigaction(SIGPROF, &act, NULL); | 121 int r = sigaction(SIGPROF, &act, NULL); |
112 ASSERT(r == 0); | 122 ASSERT(r == 0); |
113 } | 123 } |
114 | 124 |
115 | 125 |
116 } // namespace dart | 126 } // namespace dart |
117 | 127 |
118 #endif // defined(TARGET_OS_ANDROID) | 128 #endif // defined(TARGET_OS_ANDROID) |
OLD | NEW |