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

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

Issue 25909002: Sampling profiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 | « runtime/vm/signal_handler_linux.cc ('k') | runtime/vm/signal_handler_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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/simulator.h"
7 #include "vm/signal_handler.h"
8 #if defined(TARGET_OS_MACOS)
9
10 namespace dart {
11
12 uintptr_t SignalHandler::GetProgramCounter(const mcontext_t& mcontext) {
13 uintptr_t pc = 0;
14
15 #if defined(TARGET_ARCH_IA32)
16 pc = static_cast<uintptr_t>(mcontext->__ss.__eip);
17 #elif defined(TARGET_ARCH_X64)
18 pc = static_cast<uintptr_t>(mcontext->__ss.__rip);
19 #elif defined(TARGET_ARCH_MIPS) && defined(USING_SIMULATOR)
20 pc = static_cast<uintptr_t>(mcontext->__ss.__eip);
21 #elif defined(TARGET_ARCH_ARM) && defined(USING_SIMULATOR)
22 pc = static_cast<uintptr_t>(mcontext->__ss.__eip);
23 #else
24 UNIMPLEMENTED();
25 #endif // TARGET_ARCH_...
26
27 return pc;
28 }
29
30
31 uintptr_t SignalHandler::GetFramePointer(const mcontext_t& mcontext) {
32 uintptr_t fp = 0;
33
34 #if defined(TARGET_ARCH_IA32)
35 fp = static_cast<uintptr_t>(mcontext->__ss.__ebp);
36 #elif defined(TARGET_ARCH_X64)
37 fp = static_cast<uintptr_t>(mcontext->__ss.__rbp);
38 #elif defined(TARGET_ARCH_MIPS) && defined(USING_SIMULATOR)
39 fp = static_cast<uintptr_t>(mcontext->__ss.__ebp);
40 #elif defined(TARGET_ARCH_ARM) && defined(USING_SIMULATOR)
41 fp = static_cast<uintptr_t>(mcontext->__ss.__ebp);
42 #else
43 UNIMPLEMENTED();
44 #endif // TARGET_ARCH_...
45
46 return fp;
47 }
48
49
50 uintptr_t SignalHandler::GetStackPointer(const mcontext_t& mcontext) {
51 uintptr_t sp = 0;
52
53 #if defined(TARGET_ARCH_IA32)
54 sp = static_cast<uintptr_t>(mcontext->__ss.__esp);
55 #elif defined(TARGET_ARCH_X64)
56 sp = static_cast<uintptr_t>(mcontext->__ss.__rsp);
57 #elif defined(TARGET_ARCH_MIPS) && defined(USING_SIMULATOR)
58 sp = static_cast<uintptr_t>(mcontext->__ss.__esp);
59 #elif defined(TARGET_ARCH_ARM) && defined(USING_SIMULATOR)
60 sp = static_cast<uintptr_t>(mcontext->__ss.__esp);
61 #else
62 UNIMPLEMENTED();
63 #endif // TARGET_ARCH_...
64
65 return sp;
66 }
67
68
69 void SignalHandler::Install(SignalAction action) {
70 struct sigaction act;
71 act.sa_handler = NULL;
72 act.sa_sigaction = action;
73 sigemptyset(&act.sa_mask);
74 act.sa_flags = SA_RESTART | SA_SIGINFO;
75 // TODO(johnmccutchan): Do we care about restoring the signal handler?
76 struct sigaction old_act;
77 int r = sigaction(SIGPROF, &act, &old_act);
78 ASSERT(r == 0);
79 }
80
81
82 ScopedSignalBlocker::ScopedSignalBlocker() {
83 sigset_t set;
84 sigemptyset(&set);
85 sigaddset(&set, SIGPROF);
86 pthread_sigmask(SIG_SETMASK, &set, &old_);
87 }
88
89
90 ScopedSignalBlocker::~ScopedSignalBlocker() {
91 pthread_sigmask(SIG_SETMASK, &old_, NULL);
92 }
93
94 } // namespace dart
95
96 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/vm/signal_handler_linux.cc ('k') | runtime/vm/signal_handler_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698