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/thread_interrupter.h" | 10 #include "vm/thread_interrupter.h" |
11 | 11 |
12 namespace dart { | 12 namespace dart { |
13 | 13 |
14 DECLARE_FLAG(bool, thread_interrupter); | 14 DECLARE_FLAG(bool, thread_interrupter); |
15 DECLARE_FLAG(bool, trace_thread_interrupter); | 15 DECLARE_FLAG(bool, trace_thread_interrupter); |
16 | 16 |
17 #define kThreadError -1 | 17 #define kThreadError -1 |
18 | 18 |
19 class ThreadInterrupterWin : public AllStatic { | 19 class ThreadInterrupterWin : public AllStatic { |
20 public: | 20 public: |
21 static bool GrabRegisters(HANDLE handle, InterruptedThreadState* state) { | 21 static bool GrabRegisters(HANDLE handle, InterruptedThreadState* state) { |
22 CONTEXT context; | 22 CONTEXT context; |
23 memset(&context, 0, sizeof(context)); | 23 memset(&context, 0, sizeof(context)); |
24 #if defined(TARGET_ARCH_IA32) | 24 #if defined(HOST_ARCH_IA32) |
25 // On IA32, CONTEXT_CONTROL includes Eip, Ebp, and Esp. | 25 // On IA32, CONTEXT_CONTROL includes Eip, Ebp, and Esp. |
26 context.ContextFlags = CONTEXT_CONTROL; | 26 context.ContextFlags = CONTEXT_CONTROL; |
27 #elif defined(TARGET_ARCH_X64) | 27 #elif defined(HOST_ARCH_X64) |
28 // On X64, CONTEXT_CONTROL includes Rip and Rsp. Rbp is classified | 28 // On X64, CONTEXT_CONTROL includes Rip and Rsp. Rbp is classified |
29 // as an "integer" register. | 29 // as an "integer" register. |
30 context.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER; | 30 context.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER; |
31 #else | 31 #else |
32 UNIMPLEMENTED(); | 32 #error Unsupported architecture. |
33 #endif | 33 #endif |
34 if (GetThreadContext(handle, &context) != 0) { | 34 if (GetThreadContext(handle, &context) != 0) { |
35 #if defined(TARGET_ARCH_IA32) | 35 #if defined(HOST_ARCH_IA32) |
36 state->pc = static_cast<uintptr_t>(context.Eip); | 36 state->pc = static_cast<uintptr_t>(context.Eip); |
37 state->fp = static_cast<uintptr_t>(context.Ebp); | 37 state->fp = static_cast<uintptr_t>(context.Ebp); |
38 state->csp = static_cast<uintptr_t>(context.Esp); | 38 state->csp = static_cast<uintptr_t>(context.Esp); |
39 state->dsp = static_cast<uintptr_t>(context.Esp); | 39 state->dsp = static_cast<uintptr_t>(context.Esp); |
40 #elif defined(TARGET_ARCH_X64) | 40 #elif defined(HOST_ARCH_X64) |
41 state->pc = static_cast<uintptr_t>(context.Rip); | 41 state->pc = static_cast<uintptr_t>(context.Rip); |
42 state->fp = static_cast<uintptr_t>(context.Rbp); | 42 state->fp = static_cast<uintptr_t>(context.Rbp); |
43 state->csp = static_cast<uintptr_t>(context.Rsp); | 43 state->csp = static_cast<uintptr_t>(context.Rsp); |
44 state->dsp = static_cast<uintptr_t>(context.Rsp); | 44 state->dsp = static_cast<uintptr_t>(context.Rsp); |
45 #else | 45 #else |
46 UNIMPLEMENTED(); | 46 #error Unsupported architecture. |
47 #endif | 47 #endif |
48 return true; | 48 return true; |
49 } | 49 } |
50 return false; | 50 return false; |
51 } | 51 } |
52 | 52 |
53 | 53 |
54 static void Interrupt(InterruptableThreadState* state) { | 54 static void Interrupt(InterruptableThreadState* state) { |
55 ASSERT(!OSThread::Compare(GetCurrentThreadId(), state->id)); | 55 ASSERT(!OSThread::Compare(GetCurrentThreadId(), state->id)); |
56 HANDLE handle = OpenThread(THREAD_GET_CONTEXT | | 56 HANDLE handle = OpenThread(THREAD_GET_CONTEXT | |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 void ThreadInterrupter::RemoveSignalHandler() { | 114 void ThreadInterrupter::RemoveSignalHandler() { |
115 // Nothing to do on Windows. | 115 // Nothing to do on Windows. |
116 } | 116 } |
117 | 117 |
118 | 118 |
119 } // namespace dart | 119 } // namespace dart |
120 | 120 |
121 #endif // defined(TARGET_OS_WINDOWS) | 121 #endif // defined(TARGET_OS_WINDOWS) |
122 | 122 |
OLD | NEW |