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 "platform/thread.h" | |
6 #include "vm/globals.h" | 5 #include "vm/globals.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; |
| 14 |
| 15 #if defined(TARGET_ARCH_ARM) |
| 16 pc = static_cast<uintptr_t>(mcontext.arm_pc); |
| 17 #else |
13 UNIMPLEMENTED(); | 18 UNIMPLEMENTED(); |
| 19 #endif // TARGET_ARCH_... |
| 20 return pc; |
14 } | 21 } |
15 | 22 |
16 | 23 |
17 uintptr_t SignalHandler::GetFramePointer(const mcontext_t& mcontext) { | 24 uintptr_t SignalHandler::GetFramePointer(const mcontext_t& mcontext) { |
| 25 uintptr_t fp = 0; |
| 26 |
| 27 #if defined(TARGET_ARCH_ARM) |
| 28 fp = static_cast<uintptr_t>(mcontext.arm_fp); |
| 29 #else |
18 UNIMPLEMENTED(); | 30 UNIMPLEMENTED(); |
| 31 #endif // TARGET_ARCH_... |
| 32 |
| 33 return fp; |
19 } | 34 } |
20 | 35 |
21 | 36 |
22 uintptr_t SignalHandler::GetStackPointer(const mcontext_t& mcontext) { | 37 uintptr_t SignalHandler::GetStackPointer(const mcontext_t& mcontext) { |
| 38 uintptr_t sp = 0; |
| 39 |
| 40 #if defined(TARGET_ARCH_ARM) |
| 41 sp = static_cast<uintptr_t>(mcontext.arm_sp); |
| 42 #else |
23 UNIMPLEMENTED(); | 43 UNIMPLEMENTED(); |
| 44 #endif // TARGET_ARCH_... |
| 45 return sp; |
24 } | 46 } |
25 | 47 |
26 | 48 |
27 void SignalHandler::Install(SignalAction action) { | 49 void SignalHandler::Install(SignalAction action) { |
28 UNIMPLEMENTED(); | 50 struct sigaction act; |
| 51 memset(&act, 0, sizeof(act)); |
| 52 act.sa_sigaction = action; |
| 53 act.sa_flags = SA_RESTART | SA_SIGINFO; |
| 54 sigemptyset(&act.sa_mask); |
| 55 // TODO(johnmccutchan): Do we care about restoring the signal handler? |
| 56 struct sigaction old_act; |
| 57 int r = sigaction(SIGPROF, &act, &old_act); |
| 58 ASSERT(r == 0); |
29 } | 59 } |
30 | 60 |
31 | 61 |
32 } // namespace dart | 62 } // namespace dart |
33 | 63 |
34 #endif // defined(TARGET_OS_ANDROID) | 64 #endif // defined(TARGET_OS_ANDROID) |
OLD | NEW |