| 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/thread_interrupter.h" | 8 #include "vm/thread_interrupter.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| 11 | 11 |
| 12 DECLARE_FLAG(bool, thread_interrupter); | 12 DECLARE_FLAG(bool, thread_interrupter); |
| 13 DECLARE_FLAG(bool, trace_thread_interrupter); | 13 DECLARE_FLAG(bool, trace_thread_interrupter); |
| 14 | 14 |
| 15 #define kThreadError -1 | 15 #define kThreadError -1 |
| 16 | 16 |
| 17 class ThreadInterrupterWin : public AllStatic { | 17 class ThreadInterrupterWin : public AllStatic { |
| 18 public: | 18 public: |
| 19 static bool GrabRegisters(HANDLE handle, InterruptedThreadState* state) { | 19 static bool GrabRegisters(HANDLE handle, InterruptedThreadState* state) { |
| 20 CONTEXT context; | 20 CONTEXT context; |
| 21 memset(&context, 0, sizeof(context)); | 21 memset(&context, 0, sizeof(context)); |
| 22 #if defined(TARGET_ARCH_IA32) |
| 23 // On IA32, CONTEXT_CONTROL includes Eip, Ebp, and Esp. |
| 22 context.ContextFlags = CONTEXT_CONTROL; | 24 context.ContextFlags = CONTEXT_CONTROL; |
| 25 #elif defined(TARGET_ARCH_X64) |
| 26 // On X64, CONTEXT_CONTROL includes Rip and Rsp. Rbp is classified |
| 27 // as an "integer" register. |
| 28 context.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER; |
| 29 #else |
| 30 UNIMPLEMENTED(); |
| 31 #endif |
| 23 if (GetThreadContext(handle, &context) != 0) { | 32 if (GetThreadContext(handle, &context) != 0) { |
| 24 #if defined(TARGET_ARCH_IA32) | 33 #if defined(TARGET_ARCH_IA32) |
| 25 state->pc = static_cast<uintptr_t>(context.Eip); | 34 state->pc = static_cast<uintptr_t>(context.Eip); |
| 26 state->fp = static_cast<uintptr_t>(context.Ebp); | 35 state->fp = static_cast<uintptr_t>(context.Ebp); |
| 27 state->sp = static_cast<uintptr_t>(context.Esp); | 36 state->sp = static_cast<uintptr_t>(context.Esp); |
| 28 #elif defined(TARGET_ARCH_X64) | 37 #elif defined(TARGET_ARCH_X64) |
| 29 state->pc = static_cast<uintptr_t>(context.Rip); | 38 state->pc = static_cast<uintptr_t>(context.Rip); |
| 30 state->fp = static_cast<uintptr_t>(context.Rbp); | 39 state->fp = static_cast<uintptr_t>(context.Rbp); |
| 31 state->sp = static_cast<uintptr_t>(context.Rsp); | 40 state->sp = static_cast<uintptr_t>(context.Rsp); |
| 32 #else | 41 #else |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 104 |
| 96 void ThreadInterrupter::InstallSignalHandler() { | 105 void ThreadInterrupter::InstallSignalHandler() { |
| 97 // Nothing to do on Windows. | 106 // Nothing to do on Windows. |
| 98 } | 107 } |
| 99 | 108 |
| 100 | 109 |
| 101 } // namespace dart | 110 } // namespace dart |
| 102 | 111 |
| 103 #endif // defined(TARGET_OS_WINDOWS) | 112 #endif // defined(TARGET_OS_WINDOWS) |
| 104 | 113 |
| OLD | NEW |