Zachary Turner | 119767d | 2014-11-17 17:46:43 +0000 | [diff] [blame] | 1 | //===-- TargetThreadWindows.cpp----------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "TargetThreadWindows.h" |
| 11 | #include "ProcessWindows.h" |
| 12 | #include "lldb/Host/HostNativeThreadBase.h" |
| 13 | #include "lldb/Host/windows/HostThreadWindows.h" |
| 14 | #include "lldb/Host/windows/windows.h" |
| 15 | |
| 16 | using namespace lldb; |
| 17 | using namespace lldb_private; |
| 18 | |
| 19 | TargetThreadWindows::TargetThreadWindows(ProcessWindows &process, const HostThread &thread) |
Zachary Turner | c301899 | 2014-11-17 22:42:57 +0000 | [diff] [blame^] | 20 | : Thread(process, thread.GetNativeThread().GetThreadId()) |
Zachary Turner | 119767d | 2014-11-17 17:46:43 +0000 | [diff] [blame] | 21 | , m_host_thread(thread) |
| 22 | { |
| 23 | } |
| 24 | |
| 25 | TargetThreadWindows::~TargetThreadWindows() |
| 26 | { |
| 27 | DestroyThread(); |
| 28 | } |
| 29 | |
| 30 | void |
| 31 | TargetThreadWindows::RefreshStateAfterStop() |
| 32 | { |
| 33 | } |
| 34 | |
| 35 | void |
| 36 | TargetThreadWindows::WillResume(lldb::StateType resume_state) |
| 37 | { |
| 38 | } |
| 39 | |
| 40 | void |
| 41 | TargetThreadWindows::DidStop() |
| 42 | { |
| 43 | } |
| 44 | |
| 45 | RegisterContextSP |
| 46 | TargetThreadWindows::GetRegisterContext() |
| 47 | { |
| 48 | return RegisterContextSP(); |
| 49 | } |
| 50 | |
| 51 | RegisterContextSP |
| 52 | TargetThreadWindows::CreateRegisterContextForFrame(StackFrame *frame) |
| 53 | { |
| 54 | return RegisterContextSP(); |
| 55 | } |
| 56 | |
| 57 | bool |
| 58 | TargetThreadWindows::CalculateStopInfo() |
| 59 | { |
| 60 | return false; |
| 61 | } |
| 62 | |
| 63 | bool |
| 64 | TargetThreadWindows::DoResume() |
| 65 | { |
| 66 | StateType resume_state = GetResumeState(); |
| 67 | StateType current_state = GetState(); |
| 68 | if (resume_state == current_state) |
| 69 | return true; |
| 70 | |
| 71 | bool success = false; |
| 72 | DWORD suspend_count = 0; |
| 73 | switch (resume_state) |
| 74 | { |
| 75 | case eStateRunning: |
| 76 | SetState(resume_state); |
| 77 | do |
| 78 | { |
| 79 | suspend_count = ::ResumeThread(m_host_thread.GetNativeThread().GetSystemHandle()); |
| 80 | } while (suspend_count > 1 && suspend_count != (DWORD)-1); |
| 81 | success = (suspend_count != (DWORD)-1); |
| 82 | break; |
| 83 | case eStateStopped: |
| 84 | case eStateSuspended: |
| 85 | if (current_state != eStateStopped && current_state != eStateSuspended) |
| 86 | { |
| 87 | suspend_count = SuspendThread(m_host_thread.GetNativeThread().GetSystemHandle()); |
| 88 | success = (suspend_count != (DWORD)-1); |
| 89 | } |
| 90 | break; |
| 91 | default: |
| 92 | success = false; |
| 93 | } |
| 94 | return success; |
| 95 | } |