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/profiler.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 static void Interrupt(OSThread* os_thread) { | 57 static void Interrupt(OSThread* os_thread) { |
58 ASSERT(!OSThread::Compare(GetCurrentThreadId(), os_thread->id())); | 58 ASSERT(!OSThread::Compare(GetCurrentThreadId(), os_thread->id())); |
59 HANDLE handle = OpenThread( | 59 HANDLE handle = OpenThread( |
60 THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION | THREAD_SUSPEND_RESUME, | 60 THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION | THREAD_SUSPEND_RESUME, |
61 false, os_thread->id()); | 61 false, os_thread->id()); |
62 ASSERT(handle != NULL); | 62 ASSERT(handle != NULL); |
63 DWORD result = SuspendThread(handle); | 63 DWORD result = SuspendThread(handle); |
64 if (result == kThreadError) { | 64 if (result == kThreadError) { |
65 if (FLAG_trace_thread_interrupter) { | 65 if (FLAG_trace_thread_interrupter) { |
66 OS::Print("ThreadInterrupter failed to suspend thread %p\n", | 66 OS::PrintErr("ThreadInterrupter failed to suspend thread %p\n", |
67 reinterpret_cast<void*>(os_thread->id())); | 67 reinterpret_cast<void*>(os_thread->id())); |
68 } | 68 } |
69 CloseHandle(handle); | 69 CloseHandle(handle); |
70 return; | 70 return; |
71 } | 71 } |
72 InterruptedThreadState its; | 72 InterruptedThreadState its; |
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::PrintErr("ThreadInterrupter failed to get registers for %p\n", |
78 reinterpret_cast<void*>(os_thread->id())); | 78 reinterpret_cast<void*>(os_thread->id())); |
79 } | 79 } |
80 CloseHandle(handle); | 80 CloseHandle(handle); |
81 return; | 81 return; |
82 } | 82 } |
83 // Currently we sample only threads that are associated | 83 // Currently we sample only threads that are associated |
84 // with an isolate. It is safe to call 'os_thread->thread()' | 84 // with an isolate. It is safe to call 'os_thread->thread()' |
85 // here as the thread which is being queried is suspended. | 85 // here as the thread which is being queried is suspended. |
86 Thread* thread = os_thread->thread(); | 86 Thread* thread = os_thread->thread(); |
87 if (thread != NULL) { | 87 if (thread != NULL) { |
88 Profiler::SampleThread(thread, its); | 88 Profiler::SampleThread(thread, its); |
89 } | 89 } |
90 ResumeThread(handle); | 90 ResumeThread(handle); |
91 CloseHandle(handle); | 91 CloseHandle(handle); |
92 } | 92 } |
93 }; | 93 }; |
94 | 94 |
95 | 95 |
| 96 bool ThreadInterrupter::IsDebuggerAttached() { |
| 97 return false; |
| 98 } |
| 99 |
| 100 |
96 void ThreadInterrupter::InterruptThread(OSThread* thread) { | 101 void ThreadInterrupter::InterruptThread(OSThread* thread) { |
97 if (FLAG_trace_thread_interrupter) { | 102 if (FLAG_trace_thread_interrupter) { |
98 OS::Print("ThreadInterrupter suspending %p\n", | 103 OS::PrintErr("ThreadInterrupter suspending %p\n", |
99 reinterpret_cast<void*>(thread->id())); | 104 reinterpret_cast<void*>(thread->id())); |
100 } | 105 } |
101 ThreadInterrupterWin::Interrupt(thread); | 106 ThreadInterrupterWin::Interrupt(thread); |
102 if (FLAG_trace_thread_interrupter) { | 107 if (FLAG_trace_thread_interrupter) { |
103 OS::Print("ThreadInterrupter resuming %p\n", | 108 OS::PrintErr("ThreadInterrupter resuming %p\n", |
104 reinterpret_cast<void*>(thread->id())); | 109 reinterpret_cast<void*>(thread->id())); |
105 } | 110 } |
106 } | 111 } |
107 | 112 |
108 | 113 |
109 void ThreadInterrupter::InstallSignalHandler() { | 114 void ThreadInterrupter::InstallSignalHandler() { |
110 // Nothing to do on Windows. | 115 // Nothing to do on Windows. |
111 } | 116 } |
112 | 117 |
113 | 118 |
114 void ThreadInterrupter::RemoveSignalHandler() { | 119 void ThreadInterrupter::RemoveSignalHandler() { |
115 // Nothing to do on Windows. | 120 // Nothing to do on Windows. |
116 } | 121 } |
117 | 122 |
118 #endif // !PRODUCT | 123 #endif // !PRODUCT |
119 | 124 |
120 } // namespace dart | 125 } // namespace dart |
121 | 126 |
122 #endif // defined(TARGET_OS_WINDOWS) | 127 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |