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