9#if defined(DART_HOST_OS_ANDROID)
16#if defined(HOST_ARCH_IA32)
17 pc =
static_cast<uintptr_t
>(mcontext.gregs[REG_EIP]);
18#elif defined(HOST_ARCH_X64)
19 pc =
static_cast<uintptr_t
>(mcontext.gregs[REG_RIP]);
20#elif defined(HOST_ARCH_ARM)
21 pc =
static_cast<uintptr_t
>(mcontext.arm_pc);
22#elif defined(HOST_ARCH_ARM64)
23 pc =
static_cast<uintptr_t
>(mcontext.pc);
24#elif defined(HOST_ARCH_RISCV64)
25 pc =
static_cast<uintptr_t
>(mcontext.__gregs[REG_PC]);
27#error Unsupported architecture.
35#if defined(HOST_ARCH_IA32)
36 fp =
static_cast<uintptr_t
>(mcontext.gregs[REG_EBP]);
37#elif defined(HOST_ARCH_X64)
38 fp =
static_cast<uintptr_t
>(mcontext.gregs[REG_RBP]);
39#elif defined(HOST_ARCH_ARM)
41 if ((mcontext.arm_cpsr & (1 << 5)) != 0) {
43 fp =
static_cast<uintptr_t
>(mcontext.arm_r7);
46 fp =
static_cast<uintptr_t
>(mcontext.arm_fp);
48#elif defined(HOST_ARCH_ARM64)
49 fp =
static_cast<uintptr_t
>(mcontext.regs[29]);
50#elif defined(HOST_ARCH_RISCV64)
51 fp =
static_cast<uintptr_t
>(mcontext.__gregs[REG_S0]);
53#error Unsupported architecture.
62#if defined(HOST_ARCH_IA32)
63 sp =
static_cast<uintptr_t
>(mcontext.gregs[REG_ESP]);
64#elif defined(HOST_ARCH_X64)
65 sp =
static_cast<uintptr_t
>(mcontext.gregs[REG_RSP]);
66#elif defined(HOST_ARCH_ARM)
67 sp =
static_cast<uintptr_t
>(mcontext.arm_sp);
68#elif defined(HOST_ARCH_ARM64)
69 sp =
static_cast<uintptr_t
>(mcontext.sp);
70#elif defined(HOST_ARCH_RISCV64)
71 sp =
static_cast<uintptr_t
>(mcontext.__gregs[REG_SP]);
73#error Unsupported architecture.
79#if defined(TARGET_ARCH_ARM64) && !defined(USING_SIMULATOR)
80 return static_cast<uintptr_t
>(mcontext.regs[
SPREG]);
89#if defined(HOST_ARCH_IA32)
91#elif defined(HOST_ARCH_X64)
93#elif defined(HOST_ARCH_ARM)
94 lr =
static_cast<uintptr_t
>(mcontext.arm_lr);
95#elif defined(HOST_ARCH_ARM64)
96 lr =
static_cast<uintptr_t
>(mcontext.regs[30]);
97#elif defined(HOST_ARCH_RISCV64)
98 lr =
static_cast<uintptr_t
>(mcontext.__gregs[REG_RA]);
100#error Unsupported architecture.
120 struct sigaction act = {};
121 act.sa_sigaction =
action;
122 sigemptyset(&act.sa_mask);
123 sigaddset(&act.sa_mask, SIGPROF);
124 act.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK;
125 int r = sigaction(SIGPROF, &act,
nullptr);
132 struct sigaction act = {};
133 act.sa_handler = SIG_IGN;
134 sigemptyset(&act.sa_mask);
135 int r = sigaction(SIGPROF, &act,
nullptr);
139void* SignalHandler::PrepareCurrentThread() {
145 const intptr_t kGuardPageSize = 4 *
KB;
146#if defined(TARGET_ARCH_IS_64_BIT)
147 const intptr_t kSigAltStackSize = 32 *
KB;
149 const intptr_t kSigAltStackSize = 16 *
KB;
156 memset(&ss, 0,
sizeof(ss));
157 r = sigaltstack(
nullptr, &ss);
159 if (ss.ss_flags == 0 && ss.ss_size >= (kSigAltStackSize - kGuardPageSize)) {
166 ss.ss_sp =
malloc(kSigAltStackSize);
167 ss.ss_size = kSigAltStackSize;
169 r = sigaltstack(&ss,
nullptr);
175void SignalHandler::CleanupCurrentThreadState(
void* stack) {
176 if (stack !=
nullptr) {
179 memset(&ss, 0,
sizeof(ss));
180 ss.ss_flags = SS_DISABLE;
181 int r = sigaltstack(&ss, &old_ss);
183 ASSERT(old_ss.ss_sp == stack);
#define RELEASE_ASSERT(cond)
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)
void * malloc(size_t size)
void(* SignalAction)(int signal, siginfo_t *info, void *context)