blob: 2ca55d7391018d1357c18d7df8de57d023c79939 [file] [log] [blame]
Zachary Turner119767d2014-11-17 17:46:43 +00001//===-- 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
16using namespace lldb;
17using namespace lldb_private;
18
19TargetThreadWindows::TargetThreadWindows(ProcessWindows &process, const HostThread &thread)
Zachary Turnerc3018992014-11-17 22:42:57 +000020 : Thread(process, thread.GetNativeThread().GetThreadId())
Zachary Turner119767d2014-11-17 17:46:43 +000021 , m_host_thread(thread)
22{
23}
24
25TargetThreadWindows::~TargetThreadWindows()
26{
27 DestroyThread();
28}
29
30void
31TargetThreadWindows::RefreshStateAfterStop()
32{
33}
34
35void
36TargetThreadWindows::WillResume(lldb::StateType resume_state)
37{
38}
39
40void
41TargetThreadWindows::DidStop()
42{
43}
44
45RegisterContextSP
46TargetThreadWindows::GetRegisterContext()
47{
48 return RegisterContextSP();
49}
50
51RegisterContextSP
52TargetThreadWindows::CreateRegisterContextForFrame(StackFrame *frame)
53{
54 return RegisterContextSP();
55}
56
57bool
58TargetThreadWindows::CalculateStopInfo()
59{
60 return false;
61}
62
63bool
64TargetThreadWindows::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}