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