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 #ifndef VM_SIGNAL_HANDLER_H_ | 5 #ifndef VM_SIGNAL_HANDLER_H_ |
6 #define VM_SIGNAL_HANDLER_H_ | 6 #define VM_SIGNAL_HANDLER_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
10 | 10 |
11 #if defined(TARGET_OS_LINUX) | 11 #if defined(TARGET_OS_LINUX) |
12 #include <signal.h> // NOLINT | 12 #include <signal.h> // NOLINT |
13 #include <ucontext.h> // NOLINT | 13 #include <ucontext.h> // NOLINT |
14 #elif defined(TARGET_OS_ANDROID) | 14 #elif defined(TARGET_OS_ANDROID) |
15 #include <signal.h> // NOLINT | 15 #include <signal.h> // NOLINT |
16 struct mcontext_t; | 16 #include <asm/sigcontext.h> // NOLINT |
| 17 // These are not defined on Android, so we have to define them here. |
| 18 typedef struct sigcontext mcontext_t; |
| 19 typedef struct ucontext { |
| 20 uint32_t uc_flags; |
| 21 struct ucontext *uc_link; |
| 22 stack_t uc_stack; |
| 23 struct sigcontext uc_mcontext; |
| 24 uint32_t uc_sigmask; |
| 25 } ucontext_t; |
17 #elif defined(TARGET_OS_MACOS) | 26 #elif defined(TARGET_OS_MACOS) |
18 #include <signal.h> // NOLINT | 27 #include <signal.h> // NOLINT |
19 #include <sys/ucontext.h> // NOLINT | 28 #include <sys/ucontext.h> // NOLINT |
20 #elif defined(TARGET_OS_WINDOWS) | 29 #elif defined(TARGET_OS_WINDOWS) |
21 // Stub out for windows. | 30 // Stub out for windows. |
22 struct siginfo_t; | 31 struct siginfo_t; |
23 struct mcontext_t; | 32 struct mcontext_t; |
24 struct sigset_t { | 33 struct sigset_t { |
25 }; | 34 }; |
26 #endif | 35 #endif |
27 | 36 |
28 namespace dart { | 37 namespace dart { |
29 | 38 |
30 typedef void (*SignalAction)(int signal, siginfo_t* info, | 39 typedef void (*SignalAction)(int signal, siginfo_t* info, |
31 void* context); | 40 void* context); |
32 | 41 |
33 class SignalHandler : public AllStatic { | 42 class SignalHandler : public AllStatic { |
34 public: | 43 public: |
35 static void Install(SignalAction action); | 44 static void Install(SignalAction action); |
36 static uintptr_t GetProgramCounter(const mcontext_t& mcontext); | 45 static uintptr_t GetProgramCounter(const mcontext_t& mcontext); |
37 static uintptr_t GetFramePointer(const mcontext_t& mcontext); | 46 static uintptr_t GetFramePointer(const mcontext_t& mcontext); |
38 static uintptr_t GetStackPointer(const mcontext_t& mcontext); | 47 static uintptr_t GetStackPointer(const mcontext_t& mcontext); |
39 private: | 48 private: |
40 }; | 49 }; |
41 | 50 |
42 | 51 |
43 } // namespace dart | 52 } // namespace dart |
44 | 53 |
45 #endif // VM_SIGNAL_HANDLER_H_ | 54 #endif // VM_SIGNAL_HANDLER_H_ |
OLD | NEW |