| 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 <android/api-level.h> // NOLINT |
| 16 /* Android <= 19 doesn't have ucontext.h */ |
| 17 #if __ANDROID_API__ <= 19 |
| 15 #include <signal.h> // NOLINT | 18 #include <signal.h> // NOLINT |
| 16 #include <asm/sigcontext.h> // NOLINT | 19 #include <asm/sigcontext.h> // NOLINT |
| 17 // These are not defined on Android, so we have to define them here. | 20 // These are not defined on Android, so we have to define them here. |
| 18 typedef struct sigcontext mcontext_t; | 21 typedef struct sigcontext mcontext_t; |
| 19 typedef struct ucontext { | 22 typedef struct ucontext { |
| 20 uint32_t uc_flags; | 23 uint32_t uc_flags; |
| 21 struct ucontext *uc_link; | 24 struct ucontext *uc_link; |
| 22 stack_t uc_stack; | 25 stack_t uc_stack; |
| 23 struct sigcontext uc_mcontext; | 26 struct sigcontext uc_mcontext; |
| 24 uint32_t uc_sigmask; | 27 uint32_t uc_sigmask; |
| 25 } ucontext_t; | 28 } ucontext_t; |
| 29 #else |
| 30 // Android > 19 has ucontext.h |
| 31 #include <signal.h> // NOLINT |
| 32 #include <ucontext.h> // NOLINT |
| 33 #endif // __ANDROID_API__ <= 19 |
| 26 #elif defined(TARGET_OS_MACOS) | 34 #elif defined(TARGET_OS_MACOS) |
| 27 #include <signal.h> // NOLINT | 35 #include <signal.h> // NOLINT |
| 28 #include <sys/ucontext.h> // NOLINT | 36 #include <sys/ucontext.h> // NOLINT |
| 29 #elif defined(TARGET_OS_WINDOWS) | 37 #elif defined(TARGET_OS_WINDOWS) |
| 30 // Stub out for windows. | 38 // Stub out for windows. |
| 31 struct siginfo_t; | 39 struct siginfo_t; |
| 32 struct mcontext_t; | 40 struct mcontext_t; |
| 33 struct sigset_t { | 41 struct sigset_t { |
| 34 }; | 42 }; |
| 35 #endif | 43 #endif |
| 36 | 44 |
| 37 namespace dart { | 45 namespace dart { |
| 38 | 46 |
| 39 typedef void (*SignalAction)(int signal, siginfo_t* info, | 47 typedef void (*SignalAction)(int signal, siginfo_t* info, |
| 40 void* context); | 48 void* context); |
| 41 | 49 |
| 42 class SignalHandler : public AllStatic { | 50 class SignalHandler : public AllStatic { |
| 43 public: | 51 public: |
| 44 static void Install(SignalAction action); | 52 static void Install(SignalAction action); |
| 45 static uintptr_t GetProgramCounter(const mcontext_t& mcontext); | 53 static uintptr_t GetProgramCounter(const mcontext_t& mcontext); |
| 46 static uintptr_t GetFramePointer(const mcontext_t& mcontext); | 54 static uintptr_t GetFramePointer(const mcontext_t& mcontext); |
| 47 static uintptr_t GetStackPointer(const mcontext_t& mcontext); | 55 static uintptr_t GetStackPointer(const mcontext_t& mcontext); |
| 48 private: | 56 private: |
| 49 }; | 57 }; |
| 50 | 58 |
| 51 | 59 |
| 52 } // namespace dart | 60 } // namespace dart |
| 53 | 61 |
| 54 #endif // VM_SIGNAL_HANDLER_H_ | 62 #endif // VM_SIGNAL_HANDLER_H_ |
| OLD | NEW |