1ac7ddfbfSEd Maste //===-- ThreadGDBRemote.cpp -------------------------------------*- C++ -*-===//
2ac7ddfbfSEd Maste //
3ac7ddfbfSEd Maste //                     The LLVM Compiler Infrastructure
4ac7ddfbfSEd Maste //
5ac7ddfbfSEd Maste // This file is distributed under the University of Illinois Open Source
6ac7ddfbfSEd Maste // License. See LICENSE.TXT for details.
7ac7ddfbfSEd Maste //
8ac7ddfbfSEd Maste //===----------------------------------------------------------------------===//
9ac7ddfbfSEd Maste 
10ac7ddfbfSEd Maste #include "ThreadGDBRemote.h"
11ac7ddfbfSEd Maste 
1235617911SEd Maste #include "lldb/Breakpoint/Watchpoint.h"
1335617911SEd Maste #include "lldb/Target/Platform.h"
14ac7ddfbfSEd Maste #include "lldb/Target/Process.h"
15ac7ddfbfSEd Maste #include "lldb/Target/RegisterContext.h"
16ac7ddfbfSEd Maste #include "lldb/Target/StopInfo.h"
1712b93ac6SEd Maste #include "lldb/Target/SystemRuntime.h"
18ac7ddfbfSEd Maste #include "lldb/Target/Target.h"
191c3bbb01SEd Maste #include "lldb/Target/UnixSignals.h"
20ac7ddfbfSEd Maste #include "lldb/Target/Unwind.h"
21f678e45dSDimitry Andric #include "lldb/Utility/DataExtractor.h"
22*b5893f02SDimitry Andric #include "lldb/Utility/State.h"
23f678e45dSDimitry Andric #include "lldb/Utility/StreamString.h"
24ac7ddfbfSEd Maste 
25ac7ddfbfSEd Maste #include "ProcessGDBRemote.h"
26ac7ddfbfSEd Maste #include "ProcessGDBRemoteLog.h"
274ba319b5SDimitry Andric #include "lldb/Utility/StringExtractorGDBRemote.h"
28ac7ddfbfSEd Maste 
29ac7ddfbfSEd Maste using namespace lldb;
30ac7ddfbfSEd Maste using namespace lldb_private;
311c3bbb01SEd Maste using namespace lldb_private::process_gdb_remote;
32ac7ddfbfSEd Maste 
33ac7ddfbfSEd Maste //----------------------------------------------------------------------
34ac7ddfbfSEd Maste // Thread Registers
35ac7ddfbfSEd Maste //----------------------------------------------------------------------
36ac7ddfbfSEd Maste 
ThreadGDBRemote(Process & process,lldb::tid_t tid)37435933ddSDimitry Andric ThreadGDBRemote::ThreadGDBRemote(Process &process, lldb::tid_t tid)
38435933ddSDimitry Andric     : Thread(process, tid), m_thread_name(), m_dispatch_queue_name(),
391c3bbb01SEd Maste       m_thread_dispatch_qaddr(LLDB_INVALID_ADDRESS),
40435933ddSDimitry Andric       m_dispatch_queue_t(LLDB_INVALID_ADDRESS), m_queue_kind(eQueueKindUnknown),
41444ed5c5SDimitry Andric       m_queue_serial_number(LLDB_INVALID_QUEUE_ID),
42435933ddSDimitry Andric       m_associated_with_libdispatch_queue(eLazyBoolCalculate) {
43f678e45dSDimitry Andric   Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_THREAD));
44f678e45dSDimitry Andric   LLDB_LOG(log, "this = {0}, pid = {1}, tid = {2}", this, process.GetID(),
45f678e45dSDimitry Andric            GetID());
46ac7ddfbfSEd Maste }
47ac7ddfbfSEd Maste 
~ThreadGDBRemote()48435933ddSDimitry Andric ThreadGDBRemote::~ThreadGDBRemote() {
49ac7ddfbfSEd Maste   ProcessSP process_sp(GetProcess());
50f678e45dSDimitry Andric   Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_THREAD));
51f678e45dSDimitry Andric   LLDB_LOG(log, "this = {0}, pid = {1}, tid = {2}", this,
52435933ddSDimitry Andric            process_sp ? process_sp->GetID() : LLDB_INVALID_PROCESS_ID, GetID());
53ac7ddfbfSEd Maste   DestroyThread();
54ac7ddfbfSEd Maste }
55ac7ddfbfSEd Maste 
GetName()56435933ddSDimitry Andric const char *ThreadGDBRemote::GetName() {
57ac7ddfbfSEd Maste   if (m_thread_name.empty())
584ba319b5SDimitry Andric     return nullptr;
59ac7ddfbfSEd Maste   return m_thread_name.c_str();
60ac7ddfbfSEd Maste }
61ac7ddfbfSEd Maste 
ClearQueueInfo()62435933ddSDimitry Andric void ThreadGDBRemote::ClearQueueInfo() {
631c3bbb01SEd Maste   m_dispatch_queue_name.clear();
641c3bbb01SEd Maste   m_queue_kind = eQueueKindUnknown;
65444ed5c5SDimitry Andric   m_queue_serial_number = 0;
66444ed5c5SDimitry Andric   m_dispatch_queue_t = LLDB_INVALID_ADDRESS;
67444ed5c5SDimitry Andric   m_associated_with_libdispatch_queue = eLazyBoolCalculate;
681c3bbb01SEd Maste }
691c3bbb01SEd Maste 
SetQueueInfo(std::string && queue_name,QueueKind queue_kind,uint64_t queue_serial,addr_t dispatch_queue_t,LazyBool associated_with_libdispatch_queue)70435933ddSDimitry Andric void ThreadGDBRemote::SetQueueInfo(std::string &&queue_name,
71435933ddSDimitry Andric                                    QueueKind queue_kind, uint64_t queue_serial,
72435933ddSDimitry Andric                                    addr_t dispatch_queue_t,
73435933ddSDimitry Andric                                    LazyBool associated_with_libdispatch_queue) {
741c3bbb01SEd Maste   m_dispatch_queue_name = queue_name;
751c3bbb01SEd Maste   m_queue_kind = queue_kind;
76444ed5c5SDimitry Andric   m_queue_serial_number = queue_serial;
77444ed5c5SDimitry Andric   m_dispatch_queue_t = dispatch_queue_t;
78444ed5c5SDimitry Andric   m_associated_with_libdispatch_queue = associated_with_libdispatch_queue;
791c3bbb01SEd Maste }
801c3bbb01SEd Maste 
GetQueueName()81435933ddSDimitry Andric const char *ThreadGDBRemote::GetQueueName() {
82435933ddSDimitry Andric   // If our cached queue info is valid, then someone called
834ba319b5SDimitry Andric   // ThreadGDBRemote::SetQueueInfo(...) with valid information that was gleaned
844ba319b5SDimitry Andric   // from the stop reply packet. In this case we trust that the info is valid
854ba319b5SDimitry Andric   // in m_dispatch_queue_name without refetching it
86435933ddSDimitry Andric   if (CachedQueueInfoIsValid()) {
871c3bbb01SEd Maste     if (m_dispatch_queue_name.empty())
881c3bbb01SEd Maste       return nullptr;
891c3bbb01SEd Maste     else
901c3bbb01SEd Maste       return m_dispatch_queue_name.c_str();
911c3bbb01SEd Maste   }
92ac7ddfbfSEd Maste   // Always re-fetch the dispatch queue name since it can change
93ac7ddfbfSEd Maste 
94444ed5c5SDimitry Andric   if (m_associated_with_libdispatch_queue == eLazyBoolNo)
95444ed5c5SDimitry Andric     return nullptr;
96444ed5c5SDimitry Andric 
97435933ddSDimitry Andric   if (m_thread_dispatch_qaddr != 0 &&
98435933ddSDimitry Andric       m_thread_dispatch_qaddr != LLDB_INVALID_ADDRESS) {
99ac7ddfbfSEd Maste     ProcessSP process_sp(GetProcess());
100435933ddSDimitry Andric     if (process_sp) {
10112b93ac6SEd Maste       SystemRuntime *runtime = process_sp->GetSystemRuntime();
10212b93ac6SEd Maste       if (runtime)
103435933ddSDimitry Andric         m_dispatch_queue_name =
104435933ddSDimitry Andric             runtime->GetQueueNameFromThreadQAddress(m_thread_dispatch_qaddr);
1051c3bbb01SEd Maste       else
1061c3bbb01SEd Maste         m_dispatch_queue_name.clear();
1071c3bbb01SEd Maste 
1081c3bbb01SEd Maste       if (!m_dispatch_queue_name.empty())
10935617911SEd Maste         return m_dispatch_queue_name.c_str();
11035617911SEd Maste     }
111ac7ddfbfSEd Maste   }
1124ba319b5SDimitry Andric   return nullptr;
113ac7ddfbfSEd Maste }
114ac7ddfbfSEd Maste 
GetQueueKind()115435933ddSDimitry Andric QueueKind ThreadGDBRemote::GetQueueKind() {
116435933ddSDimitry Andric   // If our cached queue info is valid, then someone called
1174ba319b5SDimitry Andric   // ThreadGDBRemote::SetQueueInfo(...) with valid information that was gleaned
1184ba319b5SDimitry Andric   // from the stop reply packet. In this case we trust that the info is valid
1194ba319b5SDimitry Andric   // in m_dispatch_queue_name without refetching it
120435933ddSDimitry Andric   if (CachedQueueInfoIsValid()) {
121444ed5c5SDimitry Andric     return m_queue_kind;
122444ed5c5SDimitry Andric   }
123444ed5c5SDimitry Andric 
124444ed5c5SDimitry Andric   if (m_associated_with_libdispatch_queue == eLazyBoolNo)
125444ed5c5SDimitry Andric     return eQueueKindUnknown;
126444ed5c5SDimitry Andric 
127435933ddSDimitry Andric   if (m_thread_dispatch_qaddr != 0 &&
128435933ddSDimitry Andric       m_thread_dispatch_qaddr != LLDB_INVALID_ADDRESS) {
129444ed5c5SDimitry Andric     ProcessSP process_sp(GetProcess());
130435933ddSDimitry Andric     if (process_sp) {
131444ed5c5SDimitry Andric       SystemRuntime *runtime = process_sp->GetSystemRuntime();
132444ed5c5SDimitry Andric       if (runtime)
133444ed5c5SDimitry Andric         m_queue_kind = runtime->GetQueueKind(m_thread_dispatch_qaddr);
134444ed5c5SDimitry Andric       return m_queue_kind;
135444ed5c5SDimitry Andric     }
136444ed5c5SDimitry Andric   }
137444ed5c5SDimitry Andric   return eQueueKindUnknown;
138444ed5c5SDimitry Andric }
139444ed5c5SDimitry Andric 
GetQueueID()140435933ddSDimitry Andric queue_id_t ThreadGDBRemote::GetQueueID() {
141435933ddSDimitry Andric   // If our cached queue info is valid, then someone called
1424ba319b5SDimitry Andric   // ThreadGDBRemote::SetQueueInfo(...) with valid information that was gleaned
1434ba319b5SDimitry Andric   // from the stop reply packet. In this case we trust that the info is valid
1444ba319b5SDimitry Andric   // in m_dispatch_queue_name without refetching it
1451c3bbb01SEd Maste   if (CachedQueueInfoIsValid())
146444ed5c5SDimitry Andric     return m_queue_serial_number;
1471c3bbb01SEd Maste 
148444ed5c5SDimitry Andric   if (m_associated_with_libdispatch_queue == eLazyBoolNo)
149444ed5c5SDimitry Andric     return LLDB_INVALID_QUEUE_ID;
150444ed5c5SDimitry Andric 
151435933ddSDimitry Andric   if (m_thread_dispatch_qaddr != 0 &&
152435933ddSDimitry Andric       m_thread_dispatch_qaddr != LLDB_INVALID_ADDRESS) {
15335617911SEd Maste     ProcessSP process_sp(GetProcess());
154435933ddSDimitry Andric     if (process_sp) {
15512b93ac6SEd Maste       SystemRuntime *runtime = process_sp->GetSystemRuntime();
156435933ddSDimitry Andric       if (runtime) {
15712b93ac6SEd Maste         return runtime->GetQueueIDFromThreadQAddress(m_thread_dispatch_qaddr);
15835617911SEd Maste       }
15935617911SEd Maste     }
16035617911SEd Maste   }
16135617911SEd Maste   return LLDB_INVALID_QUEUE_ID;
16235617911SEd Maste }
16335617911SEd Maste 
GetQueue()164435933ddSDimitry Andric QueueSP ThreadGDBRemote::GetQueue() {
1650127ef0fSEd Maste   queue_id_t queue_id = GetQueueID();
1660127ef0fSEd Maste   QueueSP queue;
167435933ddSDimitry Andric   if (queue_id != LLDB_INVALID_QUEUE_ID) {
1680127ef0fSEd Maste     ProcessSP process_sp(GetProcess());
169435933ddSDimitry Andric     if (process_sp) {
1700127ef0fSEd Maste       queue = process_sp->GetQueueList().FindQueueByID(queue_id);
1710127ef0fSEd Maste     }
1720127ef0fSEd Maste   }
1730127ef0fSEd Maste   return queue;
1740127ef0fSEd Maste }
1750127ef0fSEd Maste 
GetQueueLibdispatchQueueAddress()176435933ddSDimitry Andric addr_t ThreadGDBRemote::GetQueueLibdispatchQueueAddress() {
177435933ddSDimitry Andric   if (m_dispatch_queue_t == LLDB_INVALID_ADDRESS) {
178435933ddSDimitry Andric     if (m_thread_dispatch_qaddr != 0 &&
179435933ddSDimitry Andric         m_thread_dispatch_qaddr != LLDB_INVALID_ADDRESS) {
1800127ef0fSEd Maste       ProcessSP process_sp(GetProcess());
181435933ddSDimitry Andric       if (process_sp) {
1820127ef0fSEd Maste         SystemRuntime *runtime = process_sp->GetSystemRuntime();
183435933ddSDimitry Andric         if (runtime) {
184435933ddSDimitry Andric           m_dispatch_queue_t =
185435933ddSDimitry Andric               runtime->GetLibdispatchQueueAddressFromThreadQAddress(
186435933ddSDimitry Andric                   m_thread_dispatch_qaddr);
1870127ef0fSEd Maste         }
1880127ef0fSEd Maste       }
1890127ef0fSEd Maste     }
190444ed5c5SDimitry Andric   }
191444ed5c5SDimitry Andric   return m_dispatch_queue_t;
192444ed5c5SDimitry Andric }
193444ed5c5SDimitry Andric 
SetQueueLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t)194435933ddSDimitry Andric void ThreadGDBRemote::SetQueueLibdispatchQueueAddress(
195435933ddSDimitry Andric     lldb::addr_t dispatch_queue_t) {
196444ed5c5SDimitry Andric   m_dispatch_queue_t = dispatch_queue_t;
197444ed5c5SDimitry Andric }
198444ed5c5SDimitry Andric 
ThreadHasQueueInformation() const199435933ddSDimitry Andric bool ThreadGDBRemote::ThreadHasQueueInformation() const {
200*b5893f02SDimitry Andric   return m_thread_dispatch_qaddr != 0 &&
201435933ddSDimitry Andric          m_thread_dispatch_qaddr != LLDB_INVALID_ADDRESS &&
202435933ddSDimitry Andric          m_dispatch_queue_t != LLDB_INVALID_ADDRESS &&
203*b5893f02SDimitry Andric          m_queue_kind != eQueueKindUnknown && m_queue_serial_number != 0;
204444ed5c5SDimitry Andric }
205444ed5c5SDimitry Andric 
GetAssociatedWithLibdispatchQueue()206435933ddSDimitry Andric LazyBool ThreadGDBRemote::GetAssociatedWithLibdispatchQueue() {
207444ed5c5SDimitry Andric   return m_associated_with_libdispatch_queue;
208444ed5c5SDimitry Andric }
209444ed5c5SDimitry Andric 
SetAssociatedWithLibdispatchQueue(LazyBool associated_with_libdispatch_queue)210435933ddSDimitry Andric void ThreadGDBRemote::SetAssociatedWithLibdispatchQueue(
211435933ddSDimitry Andric     LazyBool associated_with_libdispatch_queue) {
212444ed5c5SDimitry Andric   m_associated_with_libdispatch_queue = associated_with_libdispatch_queue;
2130127ef0fSEd Maste }
2140127ef0fSEd Maste 
FetchThreadExtendedInfo()215435933ddSDimitry Andric StructuredData::ObjectSP ThreadGDBRemote::FetchThreadExtendedInfo() {
2160127ef0fSEd Maste   StructuredData::ObjectSP object_sp;
2170127ef0fSEd Maste   const lldb::user_id_t tid = GetProtocolID();
2181c3bbb01SEd Maste   Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_THREAD));
2190127ef0fSEd Maste   if (log)
2200127ef0fSEd Maste     log->Printf("Fetching extended information for thread %4.4" PRIx64, tid);
2210127ef0fSEd Maste   ProcessSP process_sp(GetProcess());
222435933ddSDimitry Andric   if (process_sp) {
223435933ddSDimitry Andric     ProcessGDBRemote *gdb_process =
224435933ddSDimitry Andric         static_cast<ProcessGDBRemote *>(process_sp.get());
2250127ef0fSEd Maste     object_sp = gdb_process->GetExtendedInfoForThread(tid);
2260127ef0fSEd Maste   }
2270127ef0fSEd Maste   return object_sp;
2280127ef0fSEd Maste }
2290127ef0fSEd Maste 
WillResume(StateType resume_state)230435933ddSDimitry Andric void ThreadGDBRemote::WillResume(StateType resume_state) {
231ac7ddfbfSEd Maste   int signo = GetResumeSignal();
232ac7ddfbfSEd Maste   const lldb::user_id_t tid = GetProtocolID();
2331c3bbb01SEd Maste   Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_THREAD));
234ac7ddfbfSEd Maste   if (log)
235435933ddSDimitry Andric     log->Printf("Resuming thread: %4.4" PRIx64 " with state: %s.", tid,
236435933ddSDimitry Andric                 StateAsCString(resume_state));
237ac7ddfbfSEd Maste 
238ac7ddfbfSEd Maste   ProcessSP process_sp(GetProcess());
239435933ddSDimitry Andric   if (process_sp) {
240435933ddSDimitry Andric     ProcessGDBRemote *gdb_process =
241435933ddSDimitry Andric         static_cast<ProcessGDBRemote *>(process_sp.get());
242435933ddSDimitry Andric     switch (resume_state) {
243ac7ddfbfSEd Maste     case eStateSuspended:
244ac7ddfbfSEd Maste     case eStateStopped:
245ac7ddfbfSEd Maste       // Don't append anything for threads that should stay stopped.
246ac7ddfbfSEd Maste       break;
247ac7ddfbfSEd Maste 
248ac7ddfbfSEd Maste     case eStateRunning:
249b91a7dfcSDimitry Andric       if (gdb_process->GetUnixSignals()->SignalIsValid(signo))
250ac7ddfbfSEd Maste         gdb_process->m_continue_C_tids.push_back(std::make_pair(tid, signo));
251ac7ddfbfSEd Maste       else
252ac7ddfbfSEd Maste         gdb_process->m_continue_c_tids.push_back(tid);
253ac7ddfbfSEd Maste       break;
254ac7ddfbfSEd Maste 
255ac7ddfbfSEd Maste     case eStateStepping:
256b91a7dfcSDimitry Andric       if (gdb_process->GetUnixSignals()->SignalIsValid(signo))
257ac7ddfbfSEd Maste         gdb_process->m_continue_S_tids.push_back(std::make_pair(tid, signo));
258ac7ddfbfSEd Maste       else
259ac7ddfbfSEd Maste         gdb_process->m_continue_s_tids.push_back(tid);
260ac7ddfbfSEd Maste       break;
261ac7ddfbfSEd Maste 
262ac7ddfbfSEd Maste     default:
263ac7ddfbfSEd Maste       break;
264ac7ddfbfSEd Maste     }
265ac7ddfbfSEd Maste   }
266ac7ddfbfSEd Maste }
267ac7ddfbfSEd Maste 
RefreshStateAfterStop()268435933ddSDimitry Andric void ThreadGDBRemote::RefreshStateAfterStop() {
269ac7ddfbfSEd Maste   // Invalidate all registers in our register context. We don't set "force" to
270ac7ddfbfSEd Maste   // true because the stop reply packet might have had some register values
271ac7ddfbfSEd Maste   // that were expedited and these will already be copied into the register
2724ba319b5SDimitry Andric   // context by the time this function gets called. The
2734ba319b5SDimitry Andric   // GDBRemoteRegisterContext class has been made smart enough to detect when
2744ba319b5SDimitry Andric   // it needs to invalidate which registers are valid by putting hooks in the
2754ba319b5SDimitry Andric   // register read and register supply functions where they check the process
2764ba319b5SDimitry Andric   // stop ID and do the right thing.
277ac7ddfbfSEd Maste   const bool force = false;
278ac7ddfbfSEd Maste   GetRegisterContext()->InvalidateIfNeeded(force);
279ac7ddfbfSEd Maste }
280ac7ddfbfSEd Maste 
ThreadIDIsValid(lldb::tid_t thread)281435933ddSDimitry Andric bool ThreadGDBRemote::ThreadIDIsValid(lldb::tid_t thread) {
282ac7ddfbfSEd Maste   return thread != 0;
283ac7ddfbfSEd Maste }
284ac7ddfbfSEd Maste 
Dump(Log * log,uint32_t index)285435933ddSDimitry Andric void ThreadGDBRemote::Dump(Log *log, uint32_t index) {}
286ac7ddfbfSEd Maste 
ShouldStop(bool & step_more)287435933ddSDimitry Andric bool ThreadGDBRemote::ShouldStop(bool &step_more) { return true; }
GetRegisterContext()288435933ddSDimitry Andric lldb::RegisterContextSP ThreadGDBRemote::GetRegisterContext() {
2894ba319b5SDimitry Andric   if (!m_reg_context_sp)
2904ba319b5SDimitry Andric     m_reg_context_sp = CreateRegisterContextForFrame(nullptr);
291ac7ddfbfSEd Maste   return m_reg_context_sp;
292ac7ddfbfSEd Maste }
293ac7ddfbfSEd Maste 
294ac7ddfbfSEd Maste lldb::RegisterContextSP
CreateRegisterContextForFrame(StackFrame * frame)295435933ddSDimitry Andric ThreadGDBRemote::CreateRegisterContextForFrame(StackFrame *frame) {
296ac7ddfbfSEd Maste   lldb::RegisterContextSP reg_ctx_sp;
297ac7ddfbfSEd Maste   uint32_t concrete_frame_idx = 0;
298ac7ddfbfSEd Maste 
299ac7ddfbfSEd Maste   if (frame)
300ac7ddfbfSEd Maste     concrete_frame_idx = frame->GetConcreteFrameIndex();
301ac7ddfbfSEd Maste 
302435933ddSDimitry Andric   if (concrete_frame_idx == 0) {
303ac7ddfbfSEd Maste     ProcessSP process_sp(GetProcess());
304435933ddSDimitry Andric     if (process_sp) {
305435933ddSDimitry Andric       ProcessGDBRemote *gdb_process =
306435933ddSDimitry Andric           static_cast<ProcessGDBRemote *>(process_sp.get());
3074ba319b5SDimitry Andric       // read_all_registers_at_once will be true if 'p' packet is not
3084ba319b5SDimitry Andric       // supported.
309435933ddSDimitry Andric       bool read_all_registers_at_once =
310435933ddSDimitry Andric           !gdb_process->GetGDBRemote().GetpPacketSupported(GetID());
311435933ddSDimitry Andric       reg_ctx_sp.reset(new GDBRemoteRegisterContext(
312435933ddSDimitry Andric           *this, concrete_frame_idx, gdb_process->m_register_info,
313435933ddSDimitry Andric           read_all_registers_at_once));
314ac7ddfbfSEd Maste     }
315435933ddSDimitry Andric   } else {
316ac7ddfbfSEd Maste     Unwind *unwinder = GetUnwinder();
3174ba319b5SDimitry Andric     if (unwinder != nullptr)
318ac7ddfbfSEd Maste       reg_ctx_sp = unwinder->CreateRegisterContextForFrame(frame);
319ac7ddfbfSEd Maste   }
320ac7ddfbfSEd Maste   return reg_ctx_sp;
321ac7ddfbfSEd Maste }
322ac7ddfbfSEd Maste 
PrivateSetRegisterValue(uint32_t reg,llvm::ArrayRef<uint8_t> data)323435933ddSDimitry Andric bool ThreadGDBRemote::PrivateSetRegisterValue(uint32_t reg,
324435933ddSDimitry Andric                                               llvm::ArrayRef<uint8_t> data) {
325435933ddSDimitry Andric   GDBRemoteRegisterContext *gdb_reg_ctx =
326435933ddSDimitry Andric       static_cast<GDBRemoteRegisterContext *>(GetRegisterContext().get());
327ac7ddfbfSEd Maste   assert(gdb_reg_ctx);
328435933ddSDimitry Andric   return gdb_reg_ctx->PrivateSetRegisterValue(reg, data);
329ac7ddfbfSEd Maste }
330ac7ddfbfSEd Maste 
PrivateSetRegisterValue(uint32_t reg,uint64_t regval)331435933ddSDimitry Andric bool ThreadGDBRemote::PrivateSetRegisterValue(uint32_t reg, uint64_t regval) {
332435933ddSDimitry Andric   GDBRemoteRegisterContext *gdb_reg_ctx =
333435933ddSDimitry Andric       static_cast<GDBRemoteRegisterContext *>(GetRegisterContext().get());
3349f2f44ceSEd Maste   assert(gdb_reg_ctx);
3359f2f44ceSEd Maste   return gdb_reg_ctx->PrivateSetRegisterValue(reg, regval);
3369f2f44ceSEd Maste }
3379f2f44ceSEd Maste 
CalculateStopInfo()338435933ddSDimitry Andric bool ThreadGDBRemote::CalculateStopInfo() {
339ac7ddfbfSEd Maste   ProcessSP process_sp(GetProcess());
340ac7ddfbfSEd Maste   if (process_sp)
341435933ddSDimitry Andric     return static_cast<ProcessGDBRemote *>(process_sp.get())
342435933ddSDimitry Andric         ->CalculateThreadStopInfo(this);
343ac7ddfbfSEd Maste   return false;
344ac7ddfbfSEd Maste }
345