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(TARGET_OS_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
7 | 7 |
8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
9 #include "vm/os.h" | 9 #include "vm/os.h" |
| 10 #include "vm/profiler.h" |
10 #include "vm/thread_interrupter.h" | 11 #include "vm/thread_interrupter.h" |
11 | 12 |
12 namespace dart { | 13 namespace dart { |
13 | 14 |
14 DECLARE_FLAG(bool, thread_interrupter); | 15 DECLARE_FLAG(bool, thread_interrupter); |
15 DECLARE_FLAG(bool, trace_thread_interrupter); | 16 DECLARE_FLAG(bool, trace_thread_interrupter); |
16 | 17 |
17 #define kThreadError -1 | 18 #define kThreadError -1 |
18 | 19 |
19 class ThreadInterrupterWin : public AllStatic { | 20 class ThreadInterrupterWin : public AllStatic { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 DWORD result = SuspendThread(handle); | 63 DWORD result = SuspendThread(handle); |
63 if (result == kThreadError) { | 64 if (result == kThreadError) { |
64 if (FLAG_trace_thread_interrupter) { | 65 if (FLAG_trace_thread_interrupter) { |
65 OS::Print("ThreadInterrupter failed to suspend thread %p\n", | 66 OS::Print("ThreadInterrupter failed to suspend thread %p\n", |
66 reinterpret_cast<void*>(thread->id())); | 67 reinterpret_cast<void*>(thread->id())); |
67 } | 68 } |
68 CloseHandle(handle); | 69 CloseHandle(handle); |
69 return; | 70 return; |
70 } | 71 } |
71 InterruptedThreadState its; | 72 InterruptedThreadState its; |
72 its.tid = thread->id(); | |
73 if (!GrabRegisters(handle, &its)) { | 73 if (!GrabRegisters(handle, &its)) { |
74 // Failed to get thread registers. | 74 // Failed to get thread registers. |
75 ResumeThread(handle); | 75 ResumeThread(handle); |
76 if (FLAG_trace_thread_interrupter) { | 76 if (FLAG_trace_thread_interrupter) { |
77 OS::Print("ThreadInterrupter failed to get registers for %p\n", | 77 OS::Print("ThreadInterrupter failed to get registers for %p\n", |
78 reinterpret_cast<void*>(thread->id())); | 78 reinterpret_cast<void*>(thread->id())); |
79 } | 79 } |
80 CloseHandle(handle); | 80 CloseHandle(handle); |
81 return; | 81 return; |
82 } | 82 } |
83 ThreadInterruptCallback callback = NULL; | 83 Profiler::SampleThread(thread, its); |
84 void* callback_data = NULL; | |
85 if (thread->IsThreadInterrupterEnabled(&callback, &callback_data)) { | |
86 callback(its, callback_data); | |
87 } | |
88 ResumeThread(handle); | 84 ResumeThread(handle); |
89 CloseHandle(handle); | 85 CloseHandle(handle); |
90 } | 86 } |
91 }; | 87 }; |
92 | 88 |
93 | 89 |
94 void ThreadInterrupter::InterruptThread(Thread* thread) { | 90 void ThreadInterrupter::InterruptThread(Thread* thread) { |
95 if (FLAG_trace_thread_interrupter) { | 91 if (FLAG_trace_thread_interrupter) { |
96 OS::Print("ThreadInterrupter suspending %p\n", | 92 OS::Print("ThreadInterrupter suspending %p\n", |
97 reinterpret_cast<void*>(thread->id())); | 93 reinterpret_cast<void*>(thread->id())); |
(...skipping 13 matching lines...) Expand all Loading... |
111 | 107 |
112 void ThreadInterrupter::RemoveSignalHandler() { | 108 void ThreadInterrupter::RemoveSignalHandler() { |
113 // Nothing to do on Windows. | 109 // Nothing to do on Windows. |
114 } | 110 } |
115 | 111 |
116 | 112 |
117 } // namespace dart | 113 } // namespace dart |
118 | 114 |
119 #endif // defined(TARGET_OS_WINDOWS) | 115 #endif // defined(TARGET_OS_WINDOWS) |
120 | 116 |
OLD | NEW |