| 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 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #include "vm/simulator.h" | 6 #include "vm/simulator.h" |
| 7 #include "vm/signal_handler.h" | 7 #include "vm/signal_handler.h" |
| 8 #if defined(TARGET_OS_LINUX) | 8 #if defined(TARGET_OS_OPENBSD) |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| 11 | 11 |
| 12 uintptr_t SignalHandler::GetProgramCounter(const mcontext_t& mcontext) { | 12 uintptr_t SignalHandler::GetProgramCounter(const mcontext_t& mcontext) { |
| 13 uintptr_t pc = 0; | 13 uintptr_t pc = 0; |
| 14 | 14 |
| 15 #if defined(HOST_ARCH_IA32) | 15 #if defined(HOST_ARCH_IA32) |
| 16 pc = static_cast<uintptr_t>(mcontext.gregs[REG_EIP]); | 16 pc = static_cast<uintptr_t>(mcontext.sc_eip); |
| 17 #elif defined(HOST_ARCH_X64) | 17 #elif defined(HOST_ARCH_X64) |
| 18 pc = static_cast<uintptr_t>(mcontext.gregs[REG_RIP]); | 18 pc = static_cast<uintptr_t>(mcontext.sc_rip); |
| 19 #elif defined(HOST_ARCH_ARM) | |
| 20 pc = static_cast<uintptr_t>(mcontext.arm_pc); | |
| 21 #elif defined(HOST_ARCH_ARM64) | |
| 22 pc = static_cast<uintptr_t>(mcontext.pc); | |
| 23 #elif defined(HOST_ARCH_MIPS) | |
| 24 pc = static_cast<uintptr_t>(mcontext.pc); | |
| 25 #else | 19 #else |
| 26 #error Unsupported architecture. | 20 #error Unsupported architecture. |
| 27 #endif // HOST_ARCH_... | 21 #endif // HOST_ARCH_... |
| 28 return pc; | 22 return pc; |
| 29 } | 23 } |
| 30 | 24 |
| 31 | 25 |
| 32 uintptr_t SignalHandler::GetFramePointer(const mcontext_t& mcontext) { | 26 uintptr_t SignalHandler::GetFramePointer(const mcontext_t& mcontext) { |
| 33 uintptr_t fp = 0; | 27 uintptr_t fp = 0; |
| 34 | 28 |
| 35 #if defined(HOST_ARCH_IA32) | 29 #if defined(HOST_ARCH_IA32) |
| 36 fp = static_cast<uintptr_t>(mcontext.gregs[REG_EBP]); | 30 fp = static_cast<uintptr_t>(mcontext.sc_ebp); |
| 37 #elif defined(HOST_ARCH_X64) | 31 #elif defined(HOST_ARCH_X64) |
| 38 fp = static_cast<uintptr_t>(mcontext.gregs[REG_RBP]); | 32 fp = static_cast<uintptr_t>(mcontext.sc_rbp); |
| 39 #elif defined(HOST_ARCH_ARM) | |
| 40 fp = static_cast<uintptr_t>(mcontext.arm_fp); | |
| 41 #elif defined(HOST_ARCH_ARM64) | |
| 42 fp = static_cast<uintptr_t>(mcontext.regs[29]); | |
| 43 #elif defined(HOST_ARCH_MIPS) | |
| 44 fp = static_cast<uintptr_t>(mcontext.gregs[30]); | |
| 45 #else | 33 #else |
| 46 #error Unsupported architecture. | 34 #error Unsupported architecture. |
| 47 #endif // HOST_ARCH_... | 35 #endif // HOST_ARCH_... |
| 48 | 36 |
| 49 return fp; | 37 return fp; |
| 50 } | 38 } |
| 51 | 39 |
| 52 | 40 |
| 53 uintptr_t SignalHandler::GetCStackPointer(const mcontext_t& mcontext) { | 41 uintptr_t SignalHandler::GetCStackPointer(const mcontext_t& mcontext) { |
| 54 uintptr_t sp = 0; | 42 uintptr_t sp = 0; |
| 55 | 43 |
| 56 #if defined(HOST_ARCH_IA32) | 44 #if defined(HOST_ARCH_IA32) |
| 57 sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]); | 45 sp = static_cast<uintptr_t>(mcontext.sc_esp); |
| 58 #elif defined(HOST_ARCH_X64) | 46 #elif defined(HOST_ARCH_X64) |
| 59 sp = static_cast<uintptr_t>(mcontext.gregs[REG_RSP]); | 47 sp = static_cast<uintptr_t>(mcontext.sc_rsp); |
| 60 #elif defined(HOST_ARCH_ARM) | |
| 61 sp = static_cast<uintptr_t>(mcontext.arm_sp); | |
| 62 #elif defined(HOST_ARCH_ARM64) | |
| 63 sp = static_cast<uintptr_t>(mcontext.sp); | |
| 64 #elif defined(HOST_ARCH_MIPS) | |
| 65 sp = static_cast<uintptr_t>(mcontext.gregs[29]); | |
| 66 #else | 48 #else |
| 67 #error Unsupported architecture. | 49 #error Unsupported architecture. |
| 68 #endif // HOST_ARCH_... | 50 #endif // HOST_ARCH_... |
| 69 return sp; | 51 return sp; |
| 70 } | 52 } |
| 71 | 53 |
| 72 | 54 |
| 73 uintptr_t SignalHandler::GetDartStackPointer(const mcontext_t& mcontext) { | 55 uintptr_t SignalHandler::GetDartStackPointer(const mcontext_t& mcontext) { |
| 74 #if defined(TARGET_ARCH_ARM64) && !defined(USING_SIMULATOR) | 56 #if defined(TARGET_ARCH_ARM64) && !defined(USING_SIMULATOR) |
| 75 return static_cast<uintptr_t>(mcontext.regs[19]); | 57 return static_cast<uintptr_t>(mcontext.regs[18]); |
| 76 #else | 58 #else |
| 77 return GetCStackPointer(mcontext); | 59 return GetCStackPointer(mcontext); |
| 78 #endif | 60 #endif |
| 79 } | 61 } |
| 80 | 62 |
| 81 | 63 |
| 82 uintptr_t SignalHandler::GetLinkRegister(const mcontext_t& mcontext) { | 64 uintptr_t SignalHandler::GetLinkRegister(const mcontext_t& mcontext) { |
| 83 uintptr_t lr = 0; | 65 uintptr_t lr = 0; |
| 84 | 66 |
| 85 #if defined(HOST_ARCH_IA32) | 67 #if defined(HOST_ARCH_IA32) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 act.sa_handler = SIG_IGN; | 99 act.sa_handler = SIG_IGN; |
| 118 sigemptyset(&act.sa_mask); | 100 sigemptyset(&act.sa_mask); |
| 119 act.sa_flags = 0; | 101 act.sa_flags = 0; |
| 120 int r = sigaction(SIGPROF, &act, NULL); | 102 int r = sigaction(SIGPROF, &act, NULL); |
| 121 ASSERT(r == 0); | 103 ASSERT(r == 0); |
| 122 } | 104 } |
| 123 | 105 |
| 124 | 106 |
| 125 } // namespace dart | 107 } // namespace dart |
| 126 | 108 |
| 127 #endif // defined(TARGET_OS_LINUX) | 109 #endif // defined(TARGET_OS_OPENBSD) |
| OLD | NEW |