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(TARGET_ARCH_ARM) | 15 #if defined(HOST_ARCH_ARM) |
16 pc = static_cast<uintptr_t>(mcontext.arm_pc); | 16 pc = static_cast<uintptr_t>(mcontext.arm_pc); |
17 #elif defined(TARGET_ARCH_ARM64) | 17 #elif defined(HOST_ARCH_ARM64) |
18 pc = static_cast<uintptr_t>(mcontext.pc); | 18 pc = static_cast<uintptr_t>(mcontext.pc); |
19 #else | 19 #else |
20 UNIMPLEMENTED(); | 20 #error Unsupported architecture. |
21 #endif // TARGET_ARCH_... | 21 #endif // HOST_ARCH_... |
22 return pc; | 22 return pc; |
23 } | 23 } |
24 | 24 |
25 | 25 |
26 uintptr_t SignalHandler::GetFramePointer(const mcontext_t& mcontext) { | 26 uintptr_t SignalHandler::GetFramePointer(const mcontext_t& mcontext) { |
27 uintptr_t fp = 0; | 27 uintptr_t fp = 0; |
28 | 28 |
29 #if defined(TARGET_ARCH_ARM) | 29 #if defined(HOST_ARCH_ARM) |
30 fp = static_cast<uintptr_t>(mcontext.arm_fp); | 30 fp = static_cast<uintptr_t>(mcontext.arm_fp); |
31 #elif defined(TARGET_ARCH_ARM64) | 31 #elif defined(HOST_ARCH_ARM64) |
32 fp = static_cast<uintptr_t>(mcontext.regs[29]); | 32 fp = static_cast<uintptr_t>(mcontext.regs[29]); |
33 #else | 33 #else |
34 UNIMPLEMENTED(); | 34 #error Unsupported architecture. |
35 #endif // TARGET_ARCH_... | 35 #endif // HOST_ARCH_... |
36 | 36 |
37 return fp; | 37 return fp; |
38 } | 38 } |
39 | 39 |
40 | 40 |
41 uintptr_t SignalHandler::GetCStackPointer(const mcontext_t& mcontext) { | 41 uintptr_t SignalHandler::GetCStackPointer(const mcontext_t& mcontext) { |
42 uintptr_t sp = 0; | 42 uintptr_t sp = 0; |
43 | 43 |
44 #if defined(TARGET_ARCH_ARM) | 44 #if defined(HOST_ARCH_ARM) |
45 sp = static_cast<uintptr_t>(mcontext.arm_sp); | 45 sp = static_cast<uintptr_t>(mcontext.arm_sp); |
46 #elif defined(TARGET_ARCH_ARM64) | 46 #elif defined(HOST_ARCH_ARM64) |
47 sp = static_cast<uintptr_t>(mcontext.sp); | 47 sp = static_cast<uintptr_t>(mcontext.sp); |
48 #else | 48 #else |
49 UNIMPLEMENTED(); | 49 #error Unsupported architecture. |
50 #endif // TARGET_ARCH_... | 50 #endif // HOST_ARCH_... |
51 return sp; | 51 return sp; |
52 } | 52 } |
53 | 53 |
54 | 54 |
55 uintptr_t SignalHandler::GetDartStackPointer(const mcontext_t& mcontext) { | 55 uintptr_t SignalHandler::GetDartStackPointer(const mcontext_t& mcontext) { |
56 uintptr_t sp = 0; | 56 uintptr_t sp = 0; |
57 | 57 |
58 #if defined(TARGET_ARCH_ARM) | 58 #if defined(HOST_ARCH_ARM) |
59 sp = static_cast<uintptr_t>(mcontext.arm_sp); | 59 sp = static_cast<uintptr_t>(mcontext.arm_sp); |
60 #elif defined(TARGET_ARCH_ARM64) | 60 #elif defined(HOST_ARCH_ARM64) |
61 sp = static_cast<uintptr_t>(mcontext.regs[18]); | 61 sp = static_cast<uintptr_t>(mcontext.regs[18]); |
62 #else | 62 #else |
63 UNIMPLEMENTED(); | 63 #error Unsupported architecture. |
64 #endif // TARGET_ARCH_... | 64 #endif // HOST_ARCH_... |
65 return sp; | 65 return sp; |
66 } | 66 } |
67 | 67 |
68 | 68 |
69 uintptr_t SignalHandler::GetLinkRegister(const mcontext_t& mcontext) { | 69 uintptr_t SignalHandler::GetLinkRegister(const mcontext_t& mcontext) { |
70 uintptr_t lr = 0; | 70 uintptr_t lr = 0; |
71 #if defined(TARGET_ARCH_ARM) | 71 #if defined(HOST_ARCH_ARM) |
72 lr = static_cast<uintptr_t>(mcontext.arm_lr); | 72 lr = static_cast<uintptr_t>(mcontext.arm_lr); |
73 #elif defined(TARGET_ARCH_ARM64) | 73 #elif defined(HOST_ARCH_ARM64) |
74 lr = static_cast<uintptr_t>(mcontext.regs[30]); | 74 lr = static_cast<uintptr_t>(mcontext.regs[30]); |
75 #else | 75 #else |
76 UNIMPLEMENTED(); | 76 #error Unsupported architecture. |
77 #endif // TARGET_ARCH_... | 77 #endif // HOST_ARCH_... |
78 return lr; | 78 return lr; |
79 } | 79 } |
80 | 80 |
81 | 81 |
82 void SignalHandler::Install(SignalAction action) { | 82 void SignalHandler::Install(SignalAction action) { |
83 struct sigaction act; | 83 struct sigaction act; |
84 memset(&act, 0, sizeof(act)); | 84 memset(&act, 0, sizeof(act)); |
85 act.sa_sigaction = action; | 85 act.sa_sigaction = action; |
86 sigemptyset(&act.sa_mask); | 86 sigemptyset(&act.sa_mask); |
87 act.sa_flags = SA_RESTART | SA_SIGINFO; | 87 act.sa_flags = SA_RESTART | SA_SIGINFO; |
(...skipping 10 matching lines...) Expand all Loading... |
98 act.sa_handler = SIG_IGN; | 98 act.sa_handler = SIG_IGN; |
99 sigemptyset(&act.sa_mask); | 99 sigemptyset(&act.sa_mask); |
100 int r = sigaction(SIGPROF, &act, NULL); | 100 int r = sigaction(SIGPROF, &act, NULL); |
101 ASSERT(r == 0); | 101 ASSERT(r == 0); |
102 } | 102 } |
103 | 103 |
104 | 104 |
105 } // namespace dart | 105 } // namespace dart |
106 | 106 |
107 #endif // defined(TARGET_OS_ANDROID) | 107 #endif // defined(TARGET_OS_ANDROID) |
OLD | NEW |