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

Side by Side Diff: runtime/vm/signal_handler_linux.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_android.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
(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_LINUX)
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.gregs[REG_EIP]);
17 #elif defined(TARGET_ARCH_X64)
18 pc = static_cast<uintptr_t>(mcontext.gregs[REG_RIP]);
19 #elif defined(TARGET_ARCH_MIPS) && defined(USING_SIMULATOR)
20 pc = static_cast<uintptr_t>(mcontext.gregs[REG_EIP]);
21 #elif defined(TARGET_ARCH_ARM) && defined(USING_SIMULATOR)
22 pc = static_cast<uintptr_t>(mcontext.gregs[REG_EIP]);
23 #else
24 UNIMPLEMENTED();
25 #endif // TARGET_ARCH_...
26 return pc;
27 }
28
29
30 uintptr_t SignalHandler::GetFramePointer(const mcontext_t& mcontext) {
31 uintptr_t fp = 0;
32
33 #if defined(TARGET_ARCH_IA32)
34 fp = static_cast<uintptr_t>(mcontext.gregs[REG_EBP]);
35 #elif defined(TARGET_ARCH_X64)
36 fp = static_cast<uintptr_t>(mcontext.gregs[REG_RBP]);
37 #elif defined(TARGET_ARCH_MIPS) && defined(USING_SIMULATOR)
38 fp = static_cast<uintptr_t>(mcontext.gregs[REG_EBP]);
39 #elif defined(TARGET_ARCH_ARM) && defined(USING_SIMULATOR)
40 fp = static_cast<uintptr_t>(mcontext.gregs[REG_EBP]);
41 #else
42 UNIMPLEMENTED();
43 #endif // TARGET_ARCH_...
44
45 return fp;
46 }
47
48
49 uintptr_t SignalHandler::GetStackPointer(const mcontext_t& mcontext) {
50 uintptr_t sp = 0;
51
52 #if defined(TARGET_ARCH_IA32)
53 sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]);
54 #elif defined(TARGET_ARCH_X64)
55 sp = static_cast<uintptr_t>(mcontext.gregs[REG_RSP]);
56 #elif defined(TARGET_ARCH_MIPS) && defined(USING_SIMULATOR)
57 sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]);
58 #elif defined(TARGET_ARCH_ARM) && defined(USING_SIMULATOR)
59 sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]);
60 #else
61 UNIMPLEMENTED();
62 #endif // TARGET_ARCH_...
63 return sp;
64 }
65
66
67 void SignalHandler::Install(SignalAction action) {
68 struct sigaction act;
69 act.sa_handler = NULL;
70 act.sa_sigaction = action;
71 sigemptyset(&act.sa_mask);
72 act.sa_flags = SA_RESTART | SA_SIGINFO;
73 // TODO(johnmccutchan): Do we care about restoring the signal handler?
74 struct sigaction old_act;
75 int r = sigaction(SIGPROF, &act, &old_act);
76 ASSERT(r == 0);
77 }
78
79
80 ScopedSignalBlocker::ScopedSignalBlocker() {
81 sigset_t set;
82 sigemptyset(&set);
83 sigaddset(&set, SIGPROF);
84 pthread_sigmask(SIG_SETMASK, &set, &old_);
85 }
86
87
88 ScopedSignalBlocker::~ScopedSignalBlocker() {
89 pthread_sigmask(SIG_SETMASK, &old_, NULL);
90 }
91
92 } // namespace dart
93
94 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/vm/signal_handler_android.cc ('k') | runtime/vm/signal_handler_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698