| OLD | NEW |
| 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(HOST_OS_MACOS) | 6 #if defined(HOST_OS_MACOS) |
| 7 | 7 |
| 8 #include <errno.h> // NOLINT | |
| 9 #include <assert.h> // NOLINT | 8 #include <assert.h> // NOLINT |
| 9 #include <errno.h> // NOLINT |
| 10 #include <stdbool.h> // NOLINT | 10 #include <stdbool.h> // NOLINT |
| 11 #include <sys/sysctl.h> // NOLINT |
| 11 #include <sys/types.h> // NOLINT | 12 #include <sys/types.h> // NOLINT |
| 12 #include <unistd.h> // NOLINT | 13 #include <unistd.h> // NOLINT |
| 13 #include <sys/sysctl.h> // NOLINT | |
| 14 | 14 |
| 15 #include "vm/flags.h" | 15 #include "vm/flags.h" |
| 16 #include "vm/os.h" | 16 #include "vm/os.h" |
| 17 #include "vm/profiler.h" | 17 #include "vm/profiler.h" |
| 18 #include "vm/signal_handler.h" | 18 #include "vm/signal_handler.h" |
| 19 #include "vm/thread_interrupter.h" | 19 #include "vm/thread_interrupter.h" |
| 20 | 20 |
| 21 namespace dart { | 21 namespace dart { |
| 22 | 22 |
| 23 #ifndef PRODUCT | 23 #ifndef PRODUCT |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 InterruptedThreadState its; | 64 InterruptedThreadState its; |
| 65 its.pc = SignalHandler::GetProgramCounter(mcontext); | 65 its.pc = SignalHandler::GetProgramCounter(mcontext); |
| 66 its.fp = SignalHandler::GetFramePointer(mcontext); | 66 its.fp = SignalHandler::GetFramePointer(mcontext); |
| 67 its.csp = SignalHandler::GetCStackPointer(mcontext); | 67 its.csp = SignalHandler::GetCStackPointer(mcontext); |
| 68 its.dsp = SignalHandler::GetDartStackPointer(mcontext); | 68 its.dsp = SignalHandler::GetDartStackPointer(mcontext); |
| 69 its.lr = SignalHandler::GetLinkRegister(mcontext); | 69 its.lr = SignalHandler::GetLinkRegister(mcontext); |
| 70 Profiler::SampleThread(thread, its); | 70 Profiler::SampleThread(thread, its); |
| 71 } | 71 } |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 | |
| 75 void ThreadInterrupter::InterruptThread(OSThread* thread) { | 74 void ThreadInterrupter::InterruptThread(OSThread* thread) { |
| 76 if (FLAG_trace_thread_interrupter) { | 75 if (FLAG_trace_thread_interrupter) { |
| 77 OS::PrintErr("ThreadInterrupter interrupting %p\n", thread->id()); | 76 OS::PrintErr("ThreadInterrupter interrupting %p\n", thread->id()); |
| 78 } | 77 } |
| 79 int result = pthread_kill(thread->id(), SIGPROF); | 78 int result = pthread_kill(thread->id(), SIGPROF); |
| 80 ASSERT((result == 0) || (result == ESRCH)); | 79 ASSERT((result == 0) || (result == ESRCH)); |
| 81 } | 80 } |
| 82 | 81 |
| 83 | |
| 84 void ThreadInterrupter::InstallSignalHandler() { | 82 void ThreadInterrupter::InstallSignalHandler() { |
| 85 SignalHandler::Install< | 83 SignalHandler::Install< |
| 86 ThreadInterrupterMacOS::ThreadInterruptSignalHandler>(); | 84 ThreadInterrupterMacOS::ThreadInterruptSignalHandler>(); |
| 87 } | 85 } |
| 88 | 86 |
| 89 | |
| 90 void ThreadInterrupter::RemoveSignalHandler() { | 87 void ThreadInterrupter::RemoveSignalHandler() { |
| 91 SignalHandler::Remove(); | 88 SignalHandler::Remove(); |
| 92 } | 89 } |
| 93 | 90 |
| 94 #endif // !PRODUCT | 91 #endif // !PRODUCT |
| 95 | 92 |
| 96 } // namespace dart | 93 } // namespace dart |
| 97 | 94 |
| 98 #endif // defined(HOST_OS_MACOS) | 95 #endif // defined(HOST_OS_MACOS) |
| OLD | NEW |