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

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

Issue 1559053002: Refs #10260 OpenBSD support #25327 Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address code review issues Created 4 years, 11 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_openbsd.cc ('k') | runtime/vm/virtual_memory_openbsd.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 "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_LINUX) 6 #if defined(TARGET_OS_OPENBSD)
7 7
8 #include <errno.h> // NOLINT 8 #include <errno.h>
9 9
10 #include "vm/flags.h" 10 #include "vm/flags.h"
11 #include "vm/os.h" 11 #include "vm/os.h"
12 #include "vm/profiler.h" 12 #include "vm/profiler.h"
13 #include "vm/signal_handler.h" 13 #include "vm/signal_handler.h"
14 #include "vm/thread_interrupter.h" 14 #include "vm/thread_interrupter.h"
15 15
16 namespace dart { 16 namespace dart {
17 17
18 DECLARE_FLAG(bool, thread_interrupter); 18 DECLARE_FLAG(bool, thread_interrupter);
19 DECLARE_FLAG(bool, trace_thread_interrupter); 19 DECLARE_FLAG(bool, trace_thread_interrupter);
20 20
21 class ThreadInterrupterLinux : public AllStatic { 21 class ThreadInterrupterOpenBSD : public AllStatic {
22 public: 22 public:
23 static void ThreadInterruptSignalHandler(int signal, siginfo_t* info, 23 static void ThreadInterruptSignalHandler(int signal, siginfo_t* info,
24 void* context_) { 24 void* context_) {
25 if (signal != SIGPROF) { 25 if (signal != SIGPROF) {
26 return; 26 return;
27 } 27 }
28 Thread* thread = Thread::Current(); 28 Thread* thread = Thread::Current();
29 if (thread == NULL) { 29 if (thread == NULL) {
30 return; 30 return;
31 } 31 }
32 // Extract thread state. 32 // Extract thread state.
33 ucontext_t* context = reinterpret_cast<ucontext_t*>(context_); 33 mcontext_t mcontext = reinterpret_cast<mcontext_t &>(context_);
34 mcontext_t mcontext = context->uc_mcontext;
35 InterruptedThreadState its; 34 InterruptedThreadState its;
36 its.pc = SignalHandler::GetProgramCounter(mcontext); 35 its.pc = SignalHandler::GetProgramCounter(mcontext);
37 its.fp = SignalHandler::GetFramePointer(mcontext); 36 its.fp = SignalHandler::GetFramePointer(mcontext);
38 its.csp = SignalHandler::GetCStackPointer(mcontext); 37 its.csp = SignalHandler::GetCStackPointer(mcontext);
39 its.dsp = SignalHandler::GetDartStackPointer(mcontext); 38 its.dsp = SignalHandler::GetDartStackPointer(mcontext);
40 its.lr = SignalHandler::GetLinkRegister(mcontext); 39 its.lr = SignalHandler::GetLinkRegister(mcontext);
41 Profiler::SampleThread(thread, its); 40 Profiler::SampleThread(thread, its);
42 } 41 }
43 }; 42 };
44 43
45
46 void ThreadInterrupter::InterruptThread(OSThread* thread) { 44 void ThreadInterrupter::InterruptThread(OSThread* thread) {
47 if (FLAG_trace_thread_interrupter) { 45 if (FLAG_trace_thread_interrupter) {
48 OS::Print("ThreadInterrupter interrupting %p\n", 46 OS::Print("ThreadInterrupter interrupting %p\n",
49 reinterpret_cast<void*>(thread->id())); 47 reinterpret_cast<void*>(thread->id()));
50 } 48 }
51 int result = pthread_kill(thread->id(), SIGPROF); 49 int result = pthread_kill(thread->id(), SIGPROF);
52 ASSERT((result == 0) || (result == ESRCH)); 50 ASSERT((result == 0) || (result == ESRCH));
53 } 51 }
54 52
55 53
56 void ThreadInterrupter::InstallSignalHandler() { 54 void ThreadInterrupter::InstallSignalHandler() {
57 SignalHandler::Install(ThreadInterrupterLinux::ThreadInterruptSignalHandler); 55 SignalHandler::Install(ThreadInterrupterOpenBSD::
56 ThreadInterruptSignalHandler);
58 } 57 }
59 58
60 59
61 void ThreadInterrupter::RemoveSignalHandler() { 60 void ThreadInterrupter::RemoveSignalHandler() {
62 SignalHandler::Remove(); 61 SignalHandler::Remove();
63 } 62 }
64 63
65 64
66 } // namespace dart 65 } // namespace dart
67 66
68 #endif // defined(TARGET_OS_LINUX) 67 #endif // defined(TARGET_OS_OPENBSD)
OLDNEW
« no previous file with comments | « runtime/vm/signal_handler_openbsd.cc ('k') | runtime/vm/virtual_memory_openbsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698