Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: runtime/vm/signal_handler_linux.cc

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/signal_handler_fuchsia.cc ('k') | runtime/vm/signal_handler_macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/instructions.h" 6 #include "vm/instructions.h"
7 #include "vm/signal_handler.h"
7 #include "vm/simulator.h" 8 #include "vm/simulator.h"
8 #include "vm/signal_handler.h"
9 #if defined(HOST_OS_LINUX) 9 #if defined(HOST_OS_LINUX)
10 10
11 namespace dart { 11 namespace dart {
12 12
13 uintptr_t SignalHandler::GetProgramCounter(const mcontext_t& mcontext) { 13 uintptr_t SignalHandler::GetProgramCounter(const mcontext_t& mcontext) {
14 uintptr_t pc = 0; 14 uintptr_t pc = 0;
15 15
16 #if defined(HOST_ARCH_IA32) 16 #if defined(HOST_ARCH_IA32)
17 pc = static_cast<uintptr_t>(mcontext.gregs[REG_EIP]); 17 pc = static_cast<uintptr_t>(mcontext.gregs[REG_EIP]);
18 #elif defined(HOST_ARCH_X64) 18 #elif defined(HOST_ARCH_X64)
19 pc = static_cast<uintptr_t>(mcontext.gregs[REG_RIP]); 19 pc = static_cast<uintptr_t>(mcontext.gregs[REG_RIP]);
20 #elif defined(HOST_ARCH_ARM) 20 #elif defined(HOST_ARCH_ARM)
21 pc = static_cast<uintptr_t>(mcontext.arm_pc); 21 pc = static_cast<uintptr_t>(mcontext.arm_pc);
22 #elif defined(HOST_ARCH_ARM64) 22 #elif defined(HOST_ARCH_ARM64)
23 pc = static_cast<uintptr_t>(mcontext.pc); 23 pc = static_cast<uintptr_t>(mcontext.pc);
24 #else 24 #else
25 #error Unsupported architecture. 25 #error Unsupported architecture.
26 #endif // HOST_ARCH_... 26 #endif // HOST_ARCH_...
27 return pc; 27 return pc;
28 } 28 }
29 29
30
31 uintptr_t SignalHandler::GetFramePointer(const mcontext_t& mcontext) { 30 uintptr_t SignalHandler::GetFramePointer(const mcontext_t& mcontext) {
32 uintptr_t fp = 0; 31 uintptr_t fp = 0;
33 32
34 #if defined(HOST_ARCH_IA32) 33 #if defined(HOST_ARCH_IA32)
35 fp = static_cast<uintptr_t>(mcontext.gregs[REG_EBP]); 34 fp = static_cast<uintptr_t>(mcontext.gregs[REG_EBP]);
36 #elif defined(HOST_ARCH_X64) 35 #elif defined(HOST_ARCH_X64)
37 fp = static_cast<uintptr_t>(mcontext.gregs[REG_RBP]); 36 fp = static_cast<uintptr_t>(mcontext.gregs[REG_RBP]);
38 #elif defined(HOST_ARCH_ARM) 37 #elif defined(HOST_ARCH_ARM)
39 // B1.3.3 Program Status Registers (PSRs) 38 // B1.3.3 Program Status Registers (PSRs)
40 if ((mcontext.arm_cpsr & (1 << 5)) != 0) { 39 if ((mcontext.arm_cpsr & (1 << 5)) != 0) {
41 // Thumb mode. 40 // Thumb mode.
42 fp = static_cast<uintptr_t>(mcontext.arm_r7); 41 fp = static_cast<uintptr_t>(mcontext.arm_r7);
43 } else { 42 } else {
44 // ARM mode. 43 // ARM mode.
45 fp = static_cast<uintptr_t>(mcontext.arm_fp); 44 fp = static_cast<uintptr_t>(mcontext.arm_fp);
46 } 45 }
47 #elif defined(HOST_ARCH_ARM64) 46 #elif defined(HOST_ARCH_ARM64)
48 fp = static_cast<uintptr_t>(mcontext.regs[29]); 47 fp = static_cast<uintptr_t>(mcontext.regs[29]);
49 #else 48 #else
50 #error Unsupported architecture. 49 #error Unsupported architecture.
51 #endif // HOST_ARCH_... 50 #endif // HOST_ARCH_...
52 51
53 return fp; 52 return fp;
54 } 53 }
55 54
56
57 uintptr_t SignalHandler::GetCStackPointer(const mcontext_t& mcontext) { 55 uintptr_t SignalHandler::GetCStackPointer(const mcontext_t& mcontext) {
58 uintptr_t sp = 0; 56 uintptr_t sp = 0;
59 57
60 #if defined(HOST_ARCH_IA32) 58 #if defined(HOST_ARCH_IA32)
61 sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]); 59 sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]);
62 #elif defined(HOST_ARCH_X64) 60 #elif defined(HOST_ARCH_X64)
63 sp = static_cast<uintptr_t>(mcontext.gregs[REG_RSP]); 61 sp = static_cast<uintptr_t>(mcontext.gregs[REG_RSP]);
64 #elif defined(HOST_ARCH_ARM) 62 #elif defined(HOST_ARCH_ARM)
65 sp = static_cast<uintptr_t>(mcontext.arm_sp); 63 sp = static_cast<uintptr_t>(mcontext.arm_sp);
66 #elif defined(HOST_ARCH_ARM64) 64 #elif defined(HOST_ARCH_ARM64)
67 sp = static_cast<uintptr_t>(mcontext.sp); 65 sp = static_cast<uintptr_t>(mcontext.sp);
68 #else 66 #else
69 #error Unsupported architecture. 67 #error Unsupported architecture.
70 #endif // HOST_ARCH_... 68 #endif // HOST_ARCH_...
71 return sp; 69 return sp;
72 } 70 }
73 71
74
75 uintptr_t SignalHandler::GetDartStackPointer(const mcontext_t& mcontext) { 72 uintptr_t SignalHandler::GetDartStackPointer(const mcontext_t& mcontext) {
76 #if defined(TARGET_ARCH_ARM64) && !defined(USING_SIMULATOR) 73 #if defined(TARGET_ARCH_ARM64) && !defined(USING_SIMULATOR)
77 return static_cast<uintptr_t>(mcontext.regs[SPREG]); 74 return static_cast<uintptr_t>(mcontext.regs[SPREG]);
78 #else 75 #else
79 return GetCStackPointer(mcontext); 76 return GetCStackPointer(mcontext);
80 #endif 77 #endif
81 } 78 }
82 79
83
84 uintptr_t SignalHandler::GetLinkRegister(const mcontext_t& mcontext) { 80 uintptr_t SignalHandler::GetLinkRegister(const mcontext_t& mcontext) {
85 uintptr_t lr = 0; 81 uintptr_t lr = 0;
86 82
87 #if defined(HOST_ARCH_IA32) 83 #if defined(HOST_ARCH_IA32)
88 lr = 0; 84 lr = 0;
89 #elif defined(HOST_ARCH_X64) 85 #elif defined(HOST_ARCH_X64)
90 lr = 0; 86 lr = 0;
91 #elif defined(HOST_ARCH_ARM) 87 #elif defined(HOST_ARCH_ARM)
92 lr = static_cast<uintptr_t>(mcontext.arm_lr); 88 lr = static_cast<uintptr_t>(mcontext.arm_lr);
93 #elif defined(HOST_ARCH_ARM64) 89 #elif defined(HOST_ARCH_ARM64)
94 lr = static_cast<uintptr_t>(mcontext.regs[30]); 90 lr = static_cast<uintptr_t>(mcontext.regs[30]);
95 #else 91 #else
96 #error Unsupported architecture. 92 #error Unsupported architecture.
97 #endif // HOST_ARCH_... 93 #endif // HOST_ARCH_...
98 return lr; 94 return lr;
99 } 95 }
100 96
101
102 void SignalHandler::InstallImpl(SignalAction action) { 97 void SignalHandler::InstallImpl(SignalAction action) {
103 struct sigaction act; 98 struct sigaction act;
104 act.sa_handler = NULL; 99 act.sa_handler = NULL;
105 act.sa_sigaction = action; 100 act.sa_sigaction = action;
106 sigemptyset(&act.sa_mask); 101 sigemptyset(&act.sa_mask);
107 act.sa_flags = SA_RESTART | SA_SIGINFO; 102 act.sa_flags = SA_RESTART | SA_SIGINFO;
108 int r = sigaction(SIGPROF, &act, NULL); 103 int r = sigaction(SIGPROF, &act, NULL);
109 ASSERT(r == 0); 104 ASSERT(r == 0);
110 } 105 }
111 106
112
113 void SignalHandler::Remove() { 107 void SignalHandler::Remove() {
114 // Ignore future SIGPROF signals because by default SIGPROF will terminate 108 // Ignore future SIGPROF signals because by default SIGPROF will terminate
115 // the process and we may have some signals in flight. 109 // the process and we may have some signals in flight.
116 struct sigaction act; 110 struct sigaction act;
117 act.sa_handler = SIG_IGN; 111 act.sa_handler = SIG_IGN;
118 sigemptyset(&act.sa_mask); 112 sigemptyset(&act.sa_mask);
119 act.sa_flags = 0; 113 act.sa_flags = 0;
120 int r = sigaction(SIGPROF, &act, NULL); 114 int r = sigaction(SIGPROF, &act, NULL);
121 ASSERT(r == 0); 115 ASSERT(r == 0);
122 } 116 }
123 117
124
125 } // namespace dart 118 } // namespace dart
126 119
127 #endif // defined(HOST_OS_LINUX) 120 #endif // defined(HOST_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/vm/signal_handler_fuchsia.cc ('k') | runtime/vm/signal_handler_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698