Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
signal_handler.h
Go to the documentation of this 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
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_SIGNAL_HANDLER_H_
6#define RUNTIME_VM_SIGNAL_HANDLER_H_
7
8#include "vm/allocation.h"
9#include "vm/globals.h"
10
11#if defined(DART_HOST_OS_LINUX)
12#include <signal.h> // NOLINT
13#include <ucontext.h> // NOLINT
14#elif defined(DART_HOST_OS_ANDROID)
15#include <signal.h> // NOLINT
16#if !defined(__BIONIC_HAVE_UCONTEXT_T)
17#include <asm/sigcontext.h> // NOLINT
18// If ucontext_t is not defined on Android, define it here.
19typedef struct sigcontext mcontext_t;
20typedef struct ucontext {
21 uint32_t uc_flags;
22 struct ucontext* uc_link;
23 stack_t uc_stack;
24 struct sigcontext uc_mcontext;
25 uint32_t uc_sigmask;
26} ucontext_t;
27#endif // !defined(__BIONIC_HAVE_UCONTEXT_T)
28#elif defined(DART_HOST_OS_MACOS)
29#include <signal.h> // NOLINT
30#include <sys/ucontext.h> // NOLINT
31#elif defined(DART_HOST_OS_WINDOWS)
32// Stub out for windows.
33struct siginfo_t;
34struct mcontext_t;
35struct sigset_t {};
36#elif defined(DART_HOST_OS_FUCHSIA)
37#include <signal.h> // NOLINT
38#include <ucontext.h> // NOLINT
39#endif
40
41namespace dart {
42
43typedef void (*SignalAction)(int signal, siginfo_t* info, void* context);
44
45class SignalHandler : public AllStatic {
46 public:
48 static void Remove();
49 static uintptr_t GetProgramCounter(const mcontext_t& mcontext);
50 static uintptr_t GetFramePointer(const mcontext_t& mcontext);
51 static uintptr_t GetCStackPointer(const mcontext_t& mcontext);
52 static uintptr_t GetDartStackPointer(const mcontext_t& mcontext);
53 static uintptr_t GetLinkRegister(const mcontext_t& mcontext);
54
55#if defined(DART_HOST_OS_ANDROID)
56 // Prepare current thread for handling interrupts. Returns
57 // opaque pointer to the allocated state (if any).
58 static void* PrepareCurrentThread();
59
60 // Cleanup any state which was created by |PrepareCurrentThread|.
61 static void CleanupCurrentThreadState(void* state);
62#endif
63};
64
65#undef USE_SIGNAL_HANDLER_TRAMPOLINE
66
67} // namespace dart
68
69#endif // RUNTIME_VM_SIGNAL_HANDLER_H_
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
static void Remove()
static uintptr_t GetDartStackPointer(const mcontext_t &mcontext)
static uintptr_t GetCStackPointer(const mcontext_t &mcontext)
static uintptr_t GetFramePointer(const mcontext_t &mcontext)
static uintptr_t GetProgramCounter(const mcontext_t &mcontext)
static void Install(SignalAction action)
static uintptr_t GetLinkRegister(const mcontext_t &mcontext)
AtkStateType state
void(* SignalAction)(int signal, siginfo_t *info, void *context)