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

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

Issue 108533005: Fixes Unimplemented crasher on MIPS. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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/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_LINUX)
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(TARGET_ARCH_IA32) 15 #if defined(TARGET_ARCH_IA32)
16 pc = static_cast<uintptr_t>(mcontext.gregs[REG_EIP]); 16 pc = static_cast<uintptr_t>(mcontext.gregs[REG_EIP]);
17 #elif defined(TARGET_ARCH_X64) 17 #elif defined(TARGET_ARCH_X64)
18 pc = static_cast<uintptr_t>(mcontext.gregs[REG_RIP]); 18 pc = static_cast<uintptr_t>(mcontext.gregs[REG_RIP]);
19 #elif defined(TARGET_ARCH_MIPS) && defined(USING_SIMULATOR) 19 #elif defined(TARGET_ARCH_MIPS) && defined(USING_SIMULATOR)
20 pc = static_cast<uintptr_t>(mcontext.gregs[REG_EIP]); 20 pc = static_cast<uintptr_t>(mcontext.gregs[REG_EIP]);
21 #elif defined(TARGET_ARCH_ARM) && defined(USING_SIMULATOR) 21 #elif defined(TARGET_ARCH_ARM) && defined(USING_SIMULATOR)
22 pc = static_cast<uintptr_t>(mcontext.gregs[REG_EIP]); 22 pc = static_cast<uintptr_t>(mcontext.gregs[REG_EIP]);
23 #elif defined(TARGET_ARCH_ARM) 23 #elif defined(TARGET_ARCH_ARM)
24 pc = static_cast<uintptr_t>(mcontext.arm_pc); 24 pc = static_cast<uintptr_t>(mcontext.arm_pc);
25 #elif defined(TARGET_ARCH_MIPS)
26 pc = static_cast<uintptr_t>(mcontext.pc);
25 #else 27 #else
26 UNIMPLEMENTED(); 28 UNIMPLEMENTED();
27 #endif // TARGET_ARCH_... 29 #endif // TARGET_ARCH_...
28 return pc; 30 return pc;
29 } 31 }
30 32
31 33
32 uintptr_t SignalHandler::GetFramePointer(const mcontext_t& mcontext) { 34 uintptr_t SignalHandler::GetFramePointer(const mcontext_t& mcontext) {
33 uintptr_t fp = 0; 35 uintptr_t fp = 0;
34 36
35 #if defined(TARGET_ARCH_IA32) 37 #if defined(TARGET_ARCH_IA32)
36 fp = static_cast<uintptr_t>(mcontext.gregs[REG_EBP]); 38 fp = static_cast<uintptr_t>(mcontext.gregs[REG_EBP]);
37 #elif defined(TARGET_ARCH_X64) 39 #elif defined(TARGET_ARCH_X64)
38 fp = static_cast<uintptr_t>(mcontext.gregs[REG_RBP]); 40 fp = static_cast<uintptr_t>(mcontext.gregs[REG_RBP]);
39 #elif defined(TARGET_ARCH_MIPS) && defined(USING_SIMULATOR) 41 #elif defined(TARGET_ARCH_MIPS) && defined(USING_SIMULATOR)
40 fp = static_cast<uintptr_t>(mcontext.gregs[REG_EBP]); 42 fp = static_cast<uintptr_t>(mcontext.gregs[REG_EBP]);
41 #elif defined(TARGET_ARCH_ARM) && defined(USING_SIMULATOR) 43 #elif defined(TARGET_ARCH_ARM) && defined(USING_SIMULATOR)
42 fp = static_cast<uintptr_t>(mcontext.gregs[REG_EBP]); 44 fp = static_cast<uintptr_t>(mcontext.gregs[REG_EBP]);
43 #elif defined(TARGET_ARCH_ARM) 45 #elif defined(TARGET_ARCH_ARM)
44 fp = static_cast<uintptr_t>(mcontext.arm_fp); 46 fp = static_cast<uintptr_t>(mcontext.arm_fp);
47 #elif defined(TARGET_ARCH_MIPS)
48 fp = static_cast<uintptr_t>(mcontext.gregs[30]);
45 #else 49 #else
46 UNIMPLEMENTED(); 50 UNIMPLEMENTED();
47 #endif // TARGET_ARCH_... 51 #endif // TARGET_ARCH_...
48 52
49 return fp; 53 return fp;
50 } 54 }
51 55
52 56
53 uintptr_t SignalHandler::GetStackPointer(const mcontext_t& mcontext) { 57 uintptr_t SignalHandler::GetStackPointer(const mcontext_t& mcontext) {
54 uintptr_t sp = 0; 58 uintptr_t sp = 0;
55 59
56 #if defined(TARGET_ARCH_IA32) 60 #if defined(TARGET_ARCH_IA32)
57 sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]); 61 sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]);
58 #elif defined(TARGET_ARCH_X64) 62 #elif defined(TARGET_ARCH_X64)
59 sp = static_cast<uintptr_t>(mcontext.gregs[REG_RSP]); 63 sp = static_cast<uintptr_t>(mcontext.gregs[REG_RSP]);
60 #elif defined(TARGET_ARCH_MIPS) && defined(USING_SIMULATOR) 64 #elif defined(TARGET_ARCH_MIPS) && defined(USING_SIMULATOR)
61 sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]); 65 sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]);
62 #elif defined(TARGET_ARCH_ARM) && defined(USING_SIMULATOR) 66 #elif defined(TARGET_ARCH_ARM) && defined(USING_SIMULATOR)
63 sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]); 67 sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]);
64 #elif defined(TARGET_ARCH_ARM) 68 #elif defined(TARGET_ARCH_ARM)
65 sp = static_cast<uintptr_t>(mcontext.arm_sp); 69 sp = static_cast<uintptr_t>(mcontext.arm_sp);
70 #elif defined(TARGET_ARCH_MIPS)
71 sp = static_cast<uintptr_t>(mcontext.gregs[29]);
66 #else 72 #else
67 UNIMPLEMENTED(); 73 UNIMPLEMENTED();
68 #endif // TARGET_ARCH_... 74 #endif // TARGET_ARCH_...
69 return sp; 75 return sp;
70 } 76 }
71 77
72 78
73 void SignalHandler::Install(SignalAction action) { 79 void SignalHandler::Install(SignalAction action) {
74 struct sigaction act; 80 struct sigaction act;
75 act.sa_handler = NULL; 81 act.sa_handler = NULL;
76 act.sa_sigaction = action; 82 act.sa_sigaction = action;
77 sigemptyset(&act.sa_mask); 83 sigemptyset(&act.sa_mask);
78 act.sa_flags = SA_RESTART | SA_SIGINFO; 84 act.sa_flags = SA_RESTART | SA_SIGINFO;
79 // TODO(johnmccutchan): Do we care about restoring the signal handler? 85 // TODO(johnmccutchan): Do we care about restoring the signal handler?
80 struct sigaction old_act; 86 struct sigaction old_act;
81 int r = sigaction(SIGPROF, &act, &old_act); 87 int r = sigaction(SIGPROF, &act, &old_act);
82 ASSERT(r == 0); 88 ASSERT(r == 0);
83 } 89 }
84 90
85 91
86 } // namespace dart 92 } // namespace dart
87 93
88 #endif // defined(TARGET_OS_LINUX) 94 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698