Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
signal_handler_macos.cc
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#include "vm/globals.h"
6#include "vm/instructions.h"
7#include "vm/signal_handler.h"
8#include "vm/simulator.h"
9#if defined(DART_HOST_OS_MACOS)
10
11namespace dart {
12
13uintptr_t SignalHandler::GetProgramCounter(const mcontext_t& mcontext) {
14 uintptr_t pc = 0;
15
16#if defined(HOST_ARCH_IA32)
17 pc = static_cast<uintptr_t>(mcontext->__ss.__eip);
18#elif defined(HOST_ARCH_X64)
19 pc = static_cast<uintptr_t>(mcontext->__ss.__rip);
20#elif defined(HOST_ARCH_ARM)
21 pc = static_cast<uintptr_t>(mcontext->__ss.__pc);
22#elif defined(HOST_ARCH_ARM64)
23 pc = static_cast<uintptr_t>(mcontext->__ss.__pc);
24#else
25#error Unsupported architecture.
26#endif // HOST_ARCH_...
27
28 return pc;
29}
30
31uintptr_t SignalHandler::GetFramePointer(const mcontext_t& mcontext) {
32 uintptr_t fp = 0;
33
34#if defined(HOST_ARCH_IA32)
35 fp = static_cast<uintptr_t>(mcontext->__ss.__ebp);
36#elif defined(HOST_ARCH_X64)
37 fp = static_cast<uintptr_t>(mcontext->__ss.__rbp);
38#elif defined(HOST_ARCH_ARM)
39 fp = static_cast<uintptr_t>(mcontext->__ss.__r[7]);
40#elif defined(HOST_ARCH_ARM64)
41 fp = static_cast<uintptr_t>(mcontext->__ss.__fp);
42#else
43#error Unsupported architecture.
44#endif // HOST_ARCH_...
45
46 return fp;
47}
48
49uintptr_t SignalHandler::GetCStackPointer(const mcontext_t& mcontext) {
50 uintptr_t sp = 0;
51
52#if defined(HOST_ARCH_IA32)
53 sp = static_cast<uintptr_t>(mcontext->__ss.__esp);
54#elif defined(HOST_ARCH_X64)
55 sp = static_cast<uintptr_t>(mcontext->__ss.__rsp);
56#elif defined(HOST_ARCH_ARM)
57 sp = static_cast<uintptr_t>(mcontext->__ss.__sp);
58#elif defined(HOST_ARCH_ARM64)
59 sp = static_cast<uintptr_t>(mcontext->__ss.__sp);
60#else
62#endif // HOST_ARCH_...
63
64 return sp;
65}
66
67uintptr_t SignalHandler::GetDartStackPointer(const mcontext_t& mcontext) {
68#if defined(TARGET_ARCH_ARM64) && !defined(USING_SIMULATOR)
69 return static_cast<uintptr_t>(mcontext->__ss.__x[SPREG]);
70#else
71 return GetCStackPointer(mcontext);
72#endif
73}
74
75uintptr_t SignalHandler::GetLinkRegister(const mcontext_t& mcontext) {
76 uintptr_t lr = 0;
77
78#if defined(HOST_ARCH_IA32)
79 lr = 0;
80#elif defined(HOST_ARCH_X64)
81 lr = 0;
82#elif defined(HOST_ARCH_ARM)
83 lr = static_cast<uintptr_t>(mcontext->__ss.__lr);
84#elif defined(HOST_ARCH_ARM64)
85 lr = static_cast<uintptr_t>(mcontext->__ss.__lr);
86#else
87#error Unsupported architecture.
88#endif // HOST_ARCH_...
89
90 return lr;
91}
92
94 // Nothing to do on MacOS.
95}
96
98 // Nothing to do on MacOS.
99}
100
101} // namespace dart
102
103#endif // defined(DART_HOST_OS_MACOS)
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)
#define UNIMPLEMENTED
void(* SignalAction)(int signal, siginfo_t *info, void *context)
const uint32_t fp
const Register SPREG