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

Unified Diff: dart/runtime/vm/thread_interrupter_win.cc

Issue 298153002: Version 1.4.1 (Closed) Base URL: http://dart.googlecode.com/svn/branches/1.4/
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: dart/runtime/vm/thread_interrupter_win.cc
===================================================================
--- dart/runtime/vm/thread_interrupter_win.cc (revision 36615)
+++ dart/runtime/vm/thread_interrupter_win.cc (working copy)
@@ -16,11 +16,11 @@
class ThreadInterrupterWin : public AllStatic {
public:
- static bool GrabRegisters(ThreadId thread, InterruptedThreadState* state) {
+ static bool GrabRegisters(HANDLE handle, InterruptedThreadState* state) {
CONTEXT context;
memset(&context, 0, sizeof(context));
- context.ContextFlags = CONTEXT_FULL;
- if (GetThreadContext(thread, &context) != 0) {
+ context.ContextFlags = CONTEXT_CONTROL;
+ if (GetThreadContext(handle, &context) != 0) {
#if defined(TARGET_ARCH_IA32)
state->pc = static_cast<uintptr_t>(context.Eip);
state->fp = static_cast<uintptr_t>(context.Ebp);
@@ -39,33 +39,43 @@
static void Interrupt(InterruptableThreadState* state) {
- ASSERT(GetCurrentThread() != state->id);
- DWORD result = SuspendThread(state->id);
+ ASSERT(!Thread::Compare(GetCurrentThreadId(), state->id));
+ HANDLE handle = OpenThread(THREAD_GET_CONTEXT |
+ THREAD_QUERY_INFORMATION |
+ THREAD_SUSPEND_RESUME,
+ false,
+ state->id);
+ ASSERT(handle != NULL);
+ DWORD result = SuspendThread(handle);
if (result == kThreadError) {
if (FLAG_trace_thread_interrupter) {
OS::Print("ThreadInterrupted failed to suspend thread %p\n",
reinterpret_cast<void*>(state->id));
}
+ CloseHandle(handle);
return;
}
InterruptedThreadState its;
its.tid = state->id;
- if (!GrabRegisters(state->id, &its)) {
+ if (!GrabRegisters(handle, &its)) {
// Failed to get thread registers.
- ResumeThread(state->id);
+ ResumeThread(handle);
if (FLAG_trace_thread_interrupter) {
OS::Print("ThreadInterrupted failed to get registers for %p\n",
reinterpret_cast<void*>(state->id));
}
+ CloseHandle(handle);
return;
}
if (state->callback == NULL) {
// No callback registered.
- ResumeThread(state->id);
+ ResumeThread(handle);
+ CloseHandle(handle);
return;
}
state->callback(its, state->data);
- ResumeThread(state->id);
+ ResumeThread(handle);
+ CloseHandle(handle);
}
};
« no previous file with comments | « dart/runtime/vm/thread_interrupter.cc ('k') | dart/sdk/lib/_internal/compiler/implementation/js_backend/constant_emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698